Commit d0eec0e2 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

restore: Drop self-vmas file once it's not needed

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent d9aa7f02
......@@ -1295,6 +1295,7 @@ static void sigreturn_restore(pid_t pstree_pid, pid_t pid)
struct task_restore_core_args *task_args;
struct thread_restore_args *thread_args;
char self_vmas_path[64];
char path[64];
LIST_HEAD(self_vma_list);
......@@ -1334,9 +1335,9 @@ static void sigreturn_restore(pid_t pstree_pid, pid_t pid)
goto err;
}
snprintf(path, sizeof(path), FMT_FNAME_VMAS, getpid());
unlink(path);
fd_self_vmas = open(path, O_CREAT | O_RDWR, CR_FD_PERM);
snprintf(self_vmas_path, sizeof(self_vmas_path), FMT_FNAME_VMAS, getpid());
unlink(self_vmas_path);
fd_self_vmas = open(self_vmas_path, O_CREAT | O_RDWR, CR_FD_PERM);
if (fd_self_vmas < 0) {
pr_perror("Can't open %s\n", path);
goto err;
......@@ -1453,6 +1454,9 @@ static void sigreturn_restore(pid_t pstree_pid, pid_t pid)
task_args->pid = pid;
task_args->fd_core = fd_core;
task_args->fd_self_vmas = fd_self_vmas;
strncpy(task_args->self_vmas_path,
self_vmas_path,
sizeof(task_args->self_vmas_path));
rst_mutex_init(&task_args->rst_lock);
......
......@@ -65,6 +65,7 @@ struct task_restore_core_args {
int pid; /* task pid */
int fd_core; /* opened core file */
int fd_self_vmas; /* opened file with running VMAs to unmap */
char self_vmas_path[64]; /* path to it, to unlink it once we're done */
bool restore_threads; /* if to restore threads */
rst_mutex_t rst_lock;
......
......@@ -201,6 +201,7 @@ self_len_end:
}
sys_close(args->fd_self_vmas);
sys_unlink(args->self_vmas_path);
/*
* OK, lets try to map new one.
......
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