mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
restorer: move map code to separated function
SYSV IPC segment map will be added there in further patch in the series Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org> Acked-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
committed by
Cyrill Gorcunov
parent
a5c6c02f49
commit
e967566565
43
restorer.c
43
restorer.c
@@ -286,6 +286,29 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u64 restore_mapping(const struct vma_entry *vma_entry)
|
||||
{
|
||||
int prot;
|
||||
|
||||
prot = vma_entry->prot;
|
||||
|
||||
/* A mapping of file with MAP_SHARED is up to date */
|
||||
if (vma_entry->fd == -1 || !(vma_entry->flags & MAP_SHARED))
|
||||
prot |= PROT_WRITE;
|
||||
|
||||
/*
|
||||
* Should map memory here. Note we map them as
|
||||
* writable since we're going to restore page
|
||||
* contents.
|
||||
*/
|
||||
return sys_mmap((void *)vma_entry->start,
|
||||
vma_entry_len(vma_entry),
|
||||
prot,
|
||||
vma_entry->flags | MAP_FIXED,
|
||||
vma_entry->fd,
|
||||
vma_entry->pgoff);
|
||||
}
|
||||
|
||||
/*
|
||||
* The main routine to restore task via sigreturn.
|
||||
* This one is very special, we never return there
|
||||
@@ -358,8 +381,6 @@ long restore_task(struct task_restore_core_args *args)
|
||||
*/
|
||||
sys_lseek(args->fd_core, GET_FILE_OFF_AFTER(struct core_entry), SEEK_SET);
|
||||
while (1) {
|
||||
int prot;
|
||||
|
||||
ret = sys_read(args->fd_core, vma_entry, sizeof(*vma_entry));
|
||||
if (!ret)
|
||||
break;
|
||||
@@ -386,23 +407,7 @@ long restore_task(struct task_restore_core_args *args)
|
||||
vma_entry->flags &= ~MAP_ANONYMOUS;
|
||||
}
|
||||
|
||||
prot = vma_entry->prot;
|
||||
|
||||
/* A mapping of file with MAP_SHARED is up to date */
|
||||
if (vma_entry->fd == -1 || !(vma_entry->flags & MAP_SHARED))
|
||||
prot |= PROT_WRITE;
|
||||
|
||||
/*
|
||||
* Should map memory here. Note we map them as
|
||||
* writable since we're going to restore page
|
||||
* contents.
|
||||
*/
|
||||
va = sys_mmap((void *)vma_entry->start,
|
||||
vma_entry_len(vma_entry),
|
||||
prot,
|
||||
vma_entry->flags | MAP_FIXED,
|
||||
vma_entry->fd,
|
||||
vma_entry->pgoff);
|
||||
va = restore_mapping(vma_entry);
|
||||
|
||||
if (va != vma_entry->start) {
|
||||
write_num_n(__LINE__);
|
||||
|
Reference in New Issue
Block a user