Commit 5b44cbd8 authored by Pavel Emelyanov's avatar Pavel Emelyanov

restore: Restore cwd with fchdir

Use the open_fe_fd everywhere to obtain an fd from image.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent fb6f2274
...@@ -183,19 +183,18 @@ static int open_fe_fd(struct fdinfo_entry *fe, int fd) ...@@ -183,19 +183,18 @@ static int open_fe_fd(struct fdinfo_entry *fe, int fd)
static int restore_cwd(struct fdinfo_entry *fe, int fd) static int restore_cwd(struct fdinfo_entry *fe, int fd)
{ {
char path[PATH_MAX]; int cfd;
int ret;
if (get_file_path(path, fe, fd)) cfd = open_fe_fd(fe, fd);
return -1; if (cfd < 0)
return cfd;
pr_info("Restore CWD %s\n", path); if (fchdir(cfd)) {
ret = chdir(path); pr_perror("Can't chdir");
if (ret < 0) {
pr_perror("Can't change dir %s", path);
return -1; return -1;
} }
close(cfd);
return 0; return 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