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;
|
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.
|
* The main routine to restore task via sigreturn.
|
||||||
* This one is very special, we never return there
|
* 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);
|
sys_lseek(args->fd_core, GET_FILE_OFF_AFTER(struct core_entry), SEEK_SET);
|
||||||
while (1) {
|
while (1) {
|
||||||
int prot;
|
|
||||||
|
|
||||||
ret = sys_read(args->fd_core, vma_entry, sizeof(*vma_entry));
|
ret = sys_read(args->fd_core, vma_entry, sizeof(*vma_entry));
|
||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
@@ -386,23 +407,7 @@ long restore_task(struct task_restore_core_args *args)
|
|||||||
vma_entry->flags &= ~MAP_ANONYMOUS;
|
vma_entry->flags &= ~MAP_ANONYMOUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
prot = vma_entry->prot;
|
va = restore_mapping(vma_entry);
|
||||||
|
|
||||||
/* 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);
|
|
||||||
|
|
||||||
if (va != vma_entry->start) {
|
if (va != vma_entry->start) {
|
||||||
write_num_n(__LINE__);
|
write_num_n(__LINE__);
|
||||||
|
Reference in New Issue
Block a user