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
f8ad351f
Commit
f8ad351f
authored
Oct 24, 2011
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util: Make open_fmt being more general
Signed-off-by:
Cyrill Gorcunov
<
gorcunov@gmail.com
>
parent
26857cc4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
10 deletions
+14
-10
cr-restore.c
cr-restore.c
+7
-7
util.h
include/util.h
+1
-1
util.c
util.c
+6
-2
No files found.
cr-restore.c
View file @
f8ad351f
...
...
@@ -292,7 +292,7 @@ static int prepare_shmem_pid(int pid)
int
sh_fd
;
u32
type
=
0
;
sh_fd
=
open_fmt
(
"shmem-%d.img"
,
pid
,
O_RDONLY
);
sh_fd
=
open_fmt
(
"shmem-%d.img"
,
O_RDONLY
,
pid
);
if
(
sh_fd
<
0
)
{
perror
(
"Can't open shmem info"
);
return
1
;
...
...
@@ -330,7 +330,7 @@ static int prepare_pipes_pid(int pid)
int
p_fd
;
u32
type
=
0
;
p_fd
=
open_fmt
(
"pipes-%d.img"
,
pid
,
O_RDONLY
);
p_fd
=
open_fmt
(
"pipes-%d.img"
,
O_RDONLY
,
pid
);
if
(
p_fd
<
0
)
{
perror
(
"Can't open pipes image"
);
return
1
;
...
...
@@ -511,7 +511,7 @@ static int prepare_fds(int pid)
pr_info
(
"%d: Opening files img
\n
"
,
pid
);
fdinfo_fd
=
open_fmt
(
"fdinfo-%d.img"
,
pid
,
O_RDONLY
);
fdinfo_fd
=
open_fmt
(
"fdinfo-%d.img"
,
O_RDONLY
,
pid
);
if
(
fdinfo_fd
<
0
)
{
pr_perror
(
"Can't open %d fdinfo"
,
pid
);
return
1
;
...
...
@@ -590,7 +590,7 @@ static int prepare_shmem(int pid)
int
sh_fd
;
u32
type
=
0
;
sh_fd
=
open_fmt
(
"shmem-%d.img"
,
pid
,
O_RDONLY
);
sh_fd
=
open_fmt
(
"shmem-%d.img"
,
O_RDONLY
,
pid
);
if
(
sh_fd
<
0
)
{
perror
(
"Can't open shmem info"
);
return
1
;
...
...
@@ -744,7 +744,7 @@ static int fixup_pages_data(int pid, int fd)
pr_info
(
"%d: Reading shmem pages img
\n
"
,
pid
);
shfd
=
open_fmt
(
"pages-shmem-%d.img"
,
pid
,
O_RDONLY
);
shfd
=
open_fmt
(
"pages-shmem-%d.img"
,
O_RDONLY
,
pid
);
if
(
shfd
<
0
)
{
pr_perror
(
"Can't open %d shmem image %s"
,
pid
);
return
1
;
...
...
@@ -826,7 +826,7 @@ static int prepare_and_execute_image(int pid)
int
fd
,
fd_new
;
struct
stat
buf
;
fd
=
open_fmt
(
"core-%d.img"
,
pid
,
O_RDONLY
);
fd
=
open_fmt
(
"core-%d.img"
,
O_RDONLY
,
pid
);
if
(
fd
<
0
)
{
perror
(
"Can't open exec image"
);
return
1
;
...
...
@@ -1037,7 +1037,7 @@ static int prepare_pipes(int pid)
pr_info
(
"%d: Opening pipes
\n
"
,
pid
);
pipes_fd
=
open_fmt
(
"pipes-%d.img"
,
pid
,
O_RDONLY
);
pipes_fd
=
open_fmt
(
"pipes-%d.img"
,
O_RDONLY
,
pid
);
if
(
pipes_fd
<
0
)
{
perror
(
"Can't open pipes img"
);
return
1
;
...
...
include/util.h
View file @
f8ad351f
...
...
@@ -156,7 +156,7 @@ 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
);
int
open_fmt
(
char
*
fmt
,
int
mode
,
...
);
#define __xalloc(op, size, ...) \
({ \
...
...
util.c
View file @
f8ad351f
...
...
@@ -420,10 +420,14 @@ FILE *fopen_proc(char *fmt, char *mode, ...)
return
fopen
(
fname
,
mode
);
}
int
open_fmt
(
char
*
fmt
,
int
pid
,
int
mode
)
int
open_fmt
(
char
*
fmt
,
int
mode
,
...
)
{
char
fname
[
128
];
va_list
args
;
va_start
(
args
,
mode
);
vsnprintf
(
fname
,
sizeof
(
fname
),
fmt
,
args
);
va_end
(
args
);
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