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
8e21401a
Commit
8e21401a
authored
Jul 02, 2014
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
files: Split ghost collecting routine
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
731dc183
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
29 deletions
+41
-29
files-reg.c
files-reg.c
+41
-29
No files found.
files-reg.c
View file @
8e21401a
...
@@ -68,13 +68,51 @@ static LIST_HEAD(link_remaps);
...
@@ -68,13 +68,51 @@ static LIST_HEAD(link_remaps);
*/
*/
#define MAX_GHOST_FILE_SIZE (1 * 1024 * 1024)
#define MAX_GHOST_FILE_SIZE (1 * 1024 * 1024)
static
int
create_ghost
(
struct
ghost_file
*
gf
,
GhostFileEntry
*
gfe
,
char
*
root
,
int
ifd
)
{
int
gfd
,
ghost_flags
,
ret
=
-
1
;
char
path
[
PATH_MAX
];
if
(
S_ISFIFO
(
gfe
->
mode
))
{
if
(
mknod
(
gf
->
remap
.
path
,
gfe
->
mode
,
0
))
{
pr_perror
(
"Can't create node for ghost file"
);
goto
err
;
}
ghost_flags
=
O_RDWR
;
/* To not block */
}
else
ghost_flags
=
O_WRONLY
|
O_CREAT
|
O_EXCL
;
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
root
,
gf
->
remap
.
path
);
gfd
=
open
(
path
,
ghost_flags
,
gfe
->
mode
);
if
(
gfd
<
0
)
{
pr_perror
(
"Can't open ghost file %s"
,
path
);
goto
err
;
}
if
(
fchown
(
gfd
,
gfe
->
uid
,
gfe
->
gid
)
<
0
)
{
pr_perror
(
"Can't reset user/group on ghost %s"
,
path
);
goto
err_c
;
}
if
(
S_ISREG
(
gfe
->
mode
))
{
if
(
copy_file
(
ifd
,
gfd
,
0
)
<
0
)
goto
err_c
;
}
ret
=
0
;
err_c:
close
(
gfd
);
err:
return
ret
;
}
static
int
open_remap_ghost
(
struct
reg_file_info
*
rfi
,
static
int
open_remap_ghost
(
struct
reg_file_info
*
rfi
,
RemapFilePathEntry
*
rfe
)
RemapFilePathEntry
*
rfe
)
{
{
struct
ghost_file
*
gf
;
struct
ghost_file
*
gf
;
GhostFileEntry
*
gfe
=
NULL
;
GhostFileEntry
*
gfe
=
NULL
;
int
gfd
,
ifd
,
ghost_flags
;
int
ifd
;
char
*
root
,
path
[
PATH_MAX
]
;
char
*
root
;
rfe
->
remap_id
&=
~
REMAP_GHOST
;
rfe
->
remap_id
&=
~
REMAP_GHOST
;
list_for_each_entry
(
gf
,
&
ghost_files
,
list
)
list_for_each_entry
(
gf
,
&
ghost_files
,
list
)
...
@@ -119,35 +157,11 @@ static int open_remap_ghost(struct reg_file_info *rfi,
...
@@ -119,35 +157,11 @@ static int open_remap_ghost(struct reg_file_info *rfi,
snprintf
(
gf
->
remap
.
path
,
PATH_MAX
,
"%s.cr.%x.ghost"
,
rfi
->
path
,
rfe
->
remap_id
);
snprintf
(
gf
->
remap
.
path
,
PATH_MAX
,
"%s.cr.%x.ghost"
,
rfi
->
path
,
rfe
->
remap_id
);
if
(
S_ISFIFO
(
gfe
->
mode
))
{
if
(
create_ghost
(
gf
,
gfe
,
root
,
ifd
))
if
(
mknod
(
gf
->
remap
.
path
,
gfe
->
mode
,
0
))
{
pr_perror
(
"Can't create node for ghost file"
);
goto
close_ifd
;
}
ghost_flags
=
O_RDWR
;
/* To not block */
}
else
ghost_flags
=
O_WRONLY
|
O_CREAT
|
O_EXCL
;
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
root
,
gf
->
remap
.
path
);
gfd
=
open
(
path
,
ghost_flags
,
gfe
->
mode
);
if
(
gfd
<
0
)
{
pr_perror
(
"Can't open ghost file %s"
,
path
);
goto
close_ifd
;
goto
close_ifd
;
}
if
(
fchown
(
gfd
,
gfe
->
uid
,
gfe
->
gid
)
<
0
)
{
pr_perror
(
"Can't reset user/group on ghost %#x"
,
rfe
->
remap_id
);
goto
close_all
;
}
if
(
S_ISREG
(
gfe
->
mode
))
{
if
(
copy_file
(
ifd
,
gfd
,
0
)
<
0
)
goto
close_all
;
}
ghost_file_entry__free_unpacked
(
gfe
,
NULL
);
ghost_file_entry__free_unpacked
(
gfe
,
NULL
);
close
(
ifd
);
close
(
ifd
);
close
(
gfd
);
gf
->
id
=
rfe
->
remap_id
;
gf
->
id
=
rfe
->
remap_id
;
gf
->
remap
.
users
=
0
;
gf
->
remap
.
users
=
0
;
...
@@ -156,8 +170,6 @@ gf_found:
...
@@ -156,8 +170,6 @@ gf_found:
rfi
->
remap
=
&
gf
->
remap
;
rfi
->
remap
=
&
gf
->
remap
;
return
0
;
return
0
;
close_all:
close_safe
(
&
gfd
);
close_ifd:
close_ifd:
close_safe
(
&
ifd
);
close_safe
(
&
ifd
);
err:
err:
...
...
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