Commit e1cac86b authored by Kinsbursky Stanislav's avatar Kinsbursky Stanislav Committed by Cyrill Gorcunov

restorer: Move vma flags ANON bit manipulations to restore_mapping()

This looks clearer, because this check has nothing with SYSV IPC
mappings. Also we don't modify the vma_entry itself anymore but
operate with local 'flags' copy.
Signed-off-by: 's avatarStanislav Kinsbursky <skinsbursky@openvz.org>
[gorcunov@: A few tune ups]
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 4fc8bb0a
...@@ -289,13 +289,23 @@ err: ...@@ -289,13 +289,23 @@ err:
static u64 restore_mapping(const struct vma_entry *vma_entry) static u64 restore_mapping(const struct vma_entry *vma_entry)
{ {
int prot; int prot = vma_entry->prot;
int flags = vma_entry->flags | MAP_FIXED;
if (vma_entry_is(vma_entry, VMA_AREA_SYSVIPC)) if (vma_entry_is(vma_entry, VMA_AREA_SYSVIPC))
return sys_shmat(vma_entry->fd, (void *)vma_entry->start, return sys_shmat(vma_entry->fd, (void *)vma_entry->start,
(vma_entry->prot & PROT_WRITE) ? 0 : SHM_RDONLY); (vma_entry->prot & PROT_WRITE) ? 0 : SHM_RDONLY);
prot = vma_entry->prot; /*
* Restore or shared mappings are tricky, since
* we open anonymous mapping via map_files/
* MAP_ANONYMOUS should be eliminated so fd would
* be taken into account by a kernel.
*/
if (vma_entry_is(vma_entry, VMA_ANON_SHARED)) {
if (vma_entry->fd != -1UL)
flags &= ~MAP_ANONYMOUS;
}
/* A mapping of file with MAP_SHARED is up to date */ /* A mapping of file with MAP_SHARED is up to date */
if (vma_entry->fd == -1 || !(vma_entry->flags & MAP_SHARED)) if (vma_entry->fd == -1 || !(vma_entry->flags & MAP_SHARED))
...@@ -308,8 +318,7 @@ static u64 restore_mapping(const struct vma_entry *vma_entry) ...@@ -308,8 +318,7 @@ static u64 restore_mapping(const struct vma_entry *vma_entry)
*/ */
return sys_mmap((void *)vma_entry->start, return sys_mmap((void *)vma_entry->start,
vma_entry_len(vma_entry), vma_entry_len(vma_entry),
prot, prot, flags,
vma_entry->flags | MAP_FIXED,
vma_entry->fd, vma_entry->fd,
vma_entry->pgoff); vma_entry->pgoff);
} }
...@@ -401,17 +410,6 @@ long restore_task(struct task_restore_core_args *args) ...@@ -401,17 +410,6 @@ long restore_task(struct task_restore_core_args *args)
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR)) if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
continue; continue;
/*
* Restore or shared mappings are tricky, since
* we open anonymous mapping via map_files/
* MAP_ANONYMOUS should be eliminated so fd would
* be taken into account by a kernel.
*/
if (vma_entry_is(vma_entry, VMA_ANON_SHARED)) {
if (vma_entry->fd != -1UL)
vma_entry->flags &= ~MAP_ANONYMOUS;
}
va = restore_mapping(vma_entry); va = restore_mapping(vma_entry);
if (va != vma_entry->start) { if (va != vma_entry->start) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment