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
dfe814aa
Commit
dfe814aa
authored
Oct 27, 2011
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restore: Unmap running VMAs
Signed-off-by:
Cyrill Gorcunov
<
gorcunov@gmail.com
>
parent
44596497
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
5 deletions
+69
-5
cr-restore.c
cr-restore.c
+3
-0
restorer.c
restorer.c
+66
-5
No files found.
cr-restore.c
View file @
dfe814aa
...
...
@@ -1237,6 +1237,8 @@ static void restorer_test(pid_t pid)
if
(
parse_maps
(
getpid
(),
&
self_vma_list
,
false
))
goto
err
;
pr_info_vma_list
(
&
self_vma_list
);
snprintf
(
path
,
sizeof
(
path
),
"vmas-%d.img"
,
getpid
());
unlink
(
path
);
fd_vmas
=
open
(
path
,
O_CREAT
|
O_WRONLY
,
CR_FD_PERM
);
...
...
@@ -1304,6 +1306,7 @@ static void restorer_test(pid_t pid)
args
->
self_size
=
vma_len
;
strcpy
(
args
->
self_vmas_path
,
path
);
snprintf
(
path
,
sizeof
(
path
),
"core-%d.img"
,
pid
);
strcpy
(
args
->
core_path
,
path
);
...
...
restorer.c
View file @
dfe814aa
...
...
@@ -29,6 +29,14 @@
: "memory"); \
} while (0)
#define add_ord(c) \
do { \
if (c < 10) \
c += '0'; \
else \
c += 'a' - 10; \
} while (0)
static
void
always_inline
write_string
(
char
*
str
)
{
int
len
=
0
;
...
...
@@ -39,6 +47,35 @@ static void always_inline write_string(char *str)
sys_write
(
1
,
str
,
len
);
}
static
void
always_inline
write_string_n
(
char
*
str
)
{
char
new_line
=
'\n'
;
write_string
(
str
);
sys_write
(
1
,
&
new_line
,
1
);
}
static
void
always_inline
write_hex_n
(
unsigned
long
num
)
{
bool
tailing
=
false
;
unsigned
char
*
s
=
(
unsigned
char
*
)
&
num
;
unsigned
char
c
;
int
i
;
for
(
i
=
sizeof
(
long
)
/
sizeof
(
char
)
-
1
;
i
>=
0
;
i
--
)
{
c
=
(
s
[
i
]
&
0xf0
)
>>
4
;
add_ord
(
c
);
sys_write
(
1
,
&
c
,
1
);
c
=
(
s
[
i
]
&
0x0f
);
add_ord
(
c
);
sys_write
(
1
,
&
c
,
1
);
}
c
=
'\n'
;
sys_write
(
1
,
&
c
,
1
);
}
long
restorer
(
long
cmd
)
{
long
ret
=
-
1
;
...
...
@@ -82,6 +119,7 @@ self_len_end:
case
RESTORER_CMD__RESTORE_CORE
:
{
struct
restore_core_args
*
args
;
int
fd_self_vmas
;
int
fd_core
;
struct
core_entry
core_entry
;
...
...
@@ -92,11 +130,8 @@ self_len_end:
lea_args_off
(
args
);
write_string
(
args
->
core_path
);
write_string
(
"
\n
"
);
write_string
(
args
->
self_vmas_path
);
write_string
(
"
\n
"
);
write_string_n
(
args
->
core_path
);
write_string_n
(
args
->
self_vmas_path
);
fd_core
=
sys_open
(
args
->
core_path
,
O_RDONLY
,
CR_FD_PERM
);
if
(
fd_core
<
0
)
...
...
@@ -107,6 +142,32 @@ self_len_end:
if
(
ret
!=
sizeof
(
core_entry
))
goto
core_restore_end
;
fd_self_vmas
=
sys_open
(
args
->
self_vmas_path
,
O_RDONLY
,
CR_FD_PERM
);
if
(
fd_self_vmas
<
0
)
goto
core_restore_end
;
write_hex_n
(
__LINE__
);
/* Note no magic constant on fd_self_vmas */
sys_lseek
(
fd_self_vmas
,
0
,
SEEK_SET
);
while
(
1
)
{
ret
=
sys_read
(
fd_self_vmas
,
&
vma_entry
,
sizeof
(
vma_entry
));
if
(
!
ret
)
break
;
if
(
ret
!=
sizeof
(
vma_entry
))
goto
core_restore_end
;
write_hex_n
(
__LINE__
);
write_hex_n
(
vma_entry
.
start
);
if
(
sys_munmap
((
void
*
)
vma_entry
.
start
,
vma_entry
.
end
-
vma_entry
.
start
))
goto
core_restore_end
;
write_hex_n
(
__LINE__
);
}
sys_close
(
fd_self_vmas
);
sys_close
(
fd_core
);
goto
core_restore_end
;
...
...
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