Commit e189efc1 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

restore: shmems -- Fix /proc path

The remapping of /proc path to shmem should be
done with pid of process which did mmap() call
initially.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 58ad0888
...@@ -343,7 +343,7 @@ static int prepare_pipes_pid(int pid) ...@@ -343,7 +343,7 @@ static int prepare_pipes_pid(int pid)
return 0; return 0;
} }
static int shmem_remap(struct shmems *old_addr, static int shmem_remap(pid_t pid, struct shmems *old_addr,
struct shmems *new_addr) struct shmems *new_addr)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
...@@ -351,7 +351,7 @@ static int shmem_remap(struct shmems *old_addr, ...@@ -351,7 +351,7 @@ static int shmem_remap(struct shmems *old_addr,
void *ret; void *ret;
sprintf(path, "/proc/%d/map_files/%p-%p", sprintf(path, "/proc/%d/map_files/%p-%p",
getpid(), old_addr, (void *)old_addr + SHMEMS_SIZE); pid, old_addr, (void *)old_addr + SHMEMS_SIZE);
fd = open(path, O_RDWR); fd = open(path, O_RDWR);
if (fd < 0) { if (fd < 0) {
...@@ -382,6 +382,7 @@ static int prepare_shared(int ps_fd) ...@@ -382,6 +382,7 @@ static int prepare_shared(int ps_fd)
return -1; return -1;
} }
shmems->pid = getpid();
shmems->nr_shmems = 0; shmems->nr_shmems = 0;
pipes = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, 0, 0); pipes = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, 0, 0);
...@@ -1612,7 +1613,7 @@ static void sigreturn_restore(pid_t pstree_pid, pid_t pid) ...@@ -1612,7 +1613,7 @@ static void sigreturn_restore(pid_t pstree_pid, pid_t pid)
shmems_ref = (struct shmems *)(exec_mem_hint + shmems_ref = (struct shmems *)(exec_mem_hint +
restore_task_vma_len + restore_task_vma_len +
restore_thread_vma_len); restore_thread_vma_len);
ret = shmem_remap(shmems, shmems_ref); ret = shmem_remap(shmems->pid, shmems, shmems_ref);
if (ret) if (ret)
goto err; goto err;
......
...@@ -300,6 +300,7 @@ struct shmem_info { ...@@ -300,6 +300,7 @@ struct shmem_info {
}; };
struct shmems { struct shmems {
int pid;
int nr_shmems; int nr_shmems;
struct shmem_info entries[0]; struct shmem_info entries[0];
}; };
......
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