Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
26857cc4
Commit
26857cc4
authored
Oct 24, 2011
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util: Move various helpers there
Signed-off-by:
Cyrill Gorcunov
<
gorcunov@gmail.com
>
parent
c475bccd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
35 deletions
+40
-35
cr-dump.c
cr-dump.c
+0
-27
cr-restore.c
cr-restore.c
+0
-8
util.h
include/util.h
+6
-0
util.c
util.c
+34
-0
No files found.
cr-dump.c
View file @
26857cc4
...
...
@@ -40,34 +40,7 @@
# error No x86-32 support yet
#endif
static
DIR
*
opendir_proc
(
char
*
fmt
,
...)
{
va_list
args
;
char
path
[
128
];
sprintf
(
path
,
"/proc/"
);
va_start
(
args
,
fmt
);
vsnprintf
(
path
+
6
,
sizeof
(
path
)
-
6
,
fmt
,
args
);
va_end
(
args
);
return
opendir
(
path
);
}
static
FILE
*
fopen_proc
(
char
*
fmt
,
char
*
mode
,
...)
{
va_list
args
;
char
fname
[
128
];
sprintf
(
fname
,
"/proc/"
);
va_start
(
args
,
mode
);
vsnprintf
(
fname
+
6
,
sizeof
(
fname
)
-
6
,
fmt
,
args
);
va_end
(
args
);
return
fopen
(
fname
,
mode
);
}
static
char
big_buffer
[
PATH_MAX
];
static
char
loc_buf
[
PAGE_SIZE
];
static
void
free_pstree
(
struct
list_head
*
pstree_list
)
...
...
cr-restore.c
View file @
26857cc4
...
...
@@ -89,14 +89,6 @@ static int nr_pipes;
static
int
restore_task_with_children
(
int
my_pid
,
char
*
pstree_path
);
static
int
open_fmt
(
char
*
fmt
,
int
pid
,
int
mode
)
{
char
fname
[
64
];
snprintf
(
fname
,
sizeof
(
fname
),
fmt
,
pid
);
return
open
(
fname
,
mode
);
}
static
void
show_saved_shmems
(
void
)
{
int
i
;
...
...
include/util.h
View file @
26857cc4
...
...
@@ -7,8 +7,10 @@
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include "compiler.h"
#include "types.h"
...
...
@@ -152,6 +154,10 @@ int reopen_fd_as(int new_fd, int old_fd);
int
parse_maps
(
pid_t
pid
,
struct
list_head
*
vma_list
);
int
close_safe
(
int
*
fd
);
DIR
*
opendir_proc
(
char
*
fmt
,
...);
FILE
*
fopen_proc
(
char
*
fmt
,
char
*
mode
,
...);
int
open_fmt
(
char
*
fmt
,
int
pid
,
int
mode
);
#define __xalloc(op, size, ...) \
({ \
void *___p = op( __VA_ARGS__ ); \
...
...
util.c
View file @
26857cc4
...
...
@@ -393,3 +393,37 @@ err_bogus_mapping:
vma_area
->
vma
.
end
);
goto
err
;
}
DIR
*
opendir_proc
(
char
*
fmt
,
...)
{
char
path
[
128
];
va_list
args
;
sprintf
(
path
,
"/proc/"
);
va_start
(
args
,
fmt
);
vsnprintf
(
path
+
6
,
sizeof
(
path
)
-
6
,
fmt
,
args
);
va_end
(
args
);
return
opendir
(
path
);
}
FILE
*
fopen_proc
(
char
*
fmt
,
char
*
mode
,
...)
{
char
fname
[
128
];
va_list
args
;
sprintf
(
fname
,
"/proc/"
);
va_start
(
args
,
mode
);
vsnprintf
(
fname
+
6
,
sizeof
(
fname
)
-
6
,
fmt
,
args
);
va_end
(
args
);
return
fopen
(
fname
,
mode
);
}
int
open_fmt
(
char
*
fmt
,
int
pid
,
int
mode
)
{
char
fname
[
128
];
snprintf
(
fname
,
sizeof
(
fname
),
fmt
,
pid
);
return
open
(
fname
,
mode
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment