Commit d463b15b authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

restorer: Switch restoring of /proc/pid/exe symlink to new kernel interface

This patch makes crtools to work with new /proc/pid/exe symlink
restoration (the kernel part was reviewed by Oleg).

So this patch is for new shiny kernel only (!), thus I suggest
all developers to move on kernel crtools-3.3 (which can be
found at usual place) and pick up this patch for crtools itself.

(again, with this patch anything but crtools-3.3 will not work)
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4b1f8d08
...@@ -238,6 +238,7 @@ static long restore_self_exe_late(struct task_restore_core_args *args) ...@@ -238,6 +238,7 @@ static long restore_self_exe_late(struct task_restore_core_args *args)
struct fdinfo_entry fe; struct fdinfo_entry fe;
long ret = -1; long ret = -1;
char *path; char *path;
int fd;
/* /*
* Path to exe file and its len is in image. * Path to exe file and its len is in image.
...@@ -275,10 +276,20 @@ static long restore_self_exe_late(struct task_restore_core_args *args) ...@@ -275,10 +276,20 @@ static long restore_self_exe_late(struct task_restore_core_args *args)
write_string(path); write_string(path);
write_string(")\n"); write_string(")\n");
ret = sys_prctl_safe(PR_SET_MM, PR_SET_MM_EXE_FILE, (long)path, fe.len + 1); fd = sys_open(path, fe.flags, 0744);
if (fd >= 0) {
ret = sys_prctl_safe(PR_SET_MM, PR_SET_MM_EXE_FILE, fd, 0);
sys_close(fd);
} else {
write_string("sys_open failed\n");
write_num_n((long)fd);
ret = fd;
}
sys_munmap(path, fe.len + 1); sys_munmap(path, fe.len + 1);
/* FIXME Once kernel side stabilized -- drop next line */
ret = 0;
return ret; return ret;
err: err:
...@@ -513,13 +524,10 @@ long restore_task(struct task_restore_core_args *args) ...@@ -513,13 +524,10 @@ long restore_task(struct task_restore_core_args *args)
goto core_restore_end; goto core_restore_end;
/* /*
* Restoring own /proc/pid/exe symlink is a bit * Because of requirements applied from kernel side
* tricky -- we are to be sure no mmaps are * we need to restore /proc/pid/exe symlink late,
* done over exec we're going to change, that's * after old existing VMAs are superseded with
* why it's don that lately. Moreover, we are * new ones from image file.
* to pass a path to new exec which means the
* code should allocate memory enough for (maybe!)
* pretty long file name.
*/ */
ret = restore_self_exe_late(args); ret = restore_self_exe_late(args);
sys_close(args->fd_fdinfo); sys_close(args->fd_fdinfo);
......
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