[CRIU] [PATCH 3/5] Dump all special files in one place
Cyrill Gorcunov
gorcunov at openvz.org
Tue Feb 7 10:25:03 EST 2012
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
cr-dump.c | 45 ++++++++++++++-------------------------------
files.c | 12 ++++++------
2 files changed, 20 insertions(+), 37 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index a5ca0e6..acee6ee 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -138,44 +138,32 @@ err:
return ret;
}
-static int dump_cwd(int pid_dir, struct cr_fdset *cr_fdset)
+static int dump_task_special_files(int pid_dir, struct cr_fdset *cr_fdset)
{
- int ret = -1;
- int fd;
- struct fd_parms p = {
- .fd_name = FDINFO_CWD,
- .pos = 0,
- .flags = 0,
- .id = NULL,
- };
+ struct fd_parms params;
+ int fd, ret;
+ /* Dump /proc/pid/cwd */
+ params = (struct fd_parms){ .fd_name = FDINFO_CWD, };
fd = open_proc(pid_dir, "cwd");
if (fd < 0) {
pr_perror("Failed to openat cwd");
return -1;
}
+ ret = dump_one_reg_file(FDINFO_FD, ¶ms, fd, cr_fdset, 1);
+ if (ret)
+ return ret;
- return dump_one_reg_file(FDINFO_FD, &p, fd, cr_fdset, 1);
-}
-
-static int dump_exe(int pid_dir, struct cr_fdset *cr_fdset)
-{
- int ret = -1;
- int fd;
- struct fd_parms p = {
- .fd_name = FDINFO_EXE,
- .pos = 0,
- .flags = 0,
- .id = NULL,
- };
-
+ /* Dump /proc/pid/exe */
+ params = (struct fd_parms){ .fd_name = FDINFO_EXE, };
fd = open_proc(pid_dir, "exe");
if (fd < 0) {
pr_perror("Failed to openat exe");
return -1;
}
+ ret = dump_one_reg_file(FDINFO_FD, ¶ms, fd, cr_fdset, 1);
- return dump_one_reg_file(FDINFO_FD, &p, fd, cr_fdset, 1);
+ return ret;
}
static int dump_pipe_and_data(int lfd, struct pipe_entry *e,
@@ -360,13 +348,8 @@ static int dump_task_files(pid_t pid, int pid_dir, struct cr_fdset *cr_fdset)
* to re-read them in restorer, so better to make it
* fast.
*/
- if (dump_cwd(pid_dir, cr_fdset)) {
- pr_perror("Can't dump %d's cwd", pid);
- return -1;
- }
-
- if (dump_exe(pid_dir, cr_fdset)) {
- pr_perror("Can't dump %d's exe", pid);
+ if (dump_task_special_files(pid_dir, cr_fdset)) {
+ pr_err("Can't dump special files\n");
return -1;
}
diff --git a/files.c b/files.c
index 4dd5a4b..39f03e3 100644
--- a/files.c
+++ b/files.c
@@ -229,12 +229,12 @@ static int restore_cwd(struct fdinfo_entry *fe, int fd)
static int restore_exe_early(struct fdinfo_entry *fe, int fd)
{
- char path[PATH_MAX];
-
- if (get_file_path(path, fe, fd))
- return -1;
-
- pr_info("Skips restoring EXE (%s) symlink at this stage\n", path);
+ /*
+ * We restore the EXE symlink at very late stage
+ * because of restrictions applied from kernel side,
+ * so simply skip it for a while.
+ */
+ lseek(fd, fe->len, SEEK_CUR);
return 0;
}
--
1.7.7.6
More information about the CRIU
mailing list