[CRIU] [PATCH 14/16] dump: hide cwd and exe open
Kinsbursky Stanislav
skinsbursky at openvz.org
Thu Mar 1 12:57:51 EST 2012
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
cr-dump.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index 91fba5f..299df6f 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -155,7 +155,17 @@ static int dump_one_reg_file(struct fd_parms *p, struct cr_fdset *cr_fdset)
int ret;
int lfd;
- snprintf(fd_str, sizeof(fd_str), "/proc/%d/fd/%ld", p->pid, p->fd_name);
+ switch ((unsigned long)p->fd_name) {
+ case FDINFO_CWD:
+ snprintf(fd_str, sizeof(fd_str), "/proc/%d/cwd", p->pid);
+ break;
+ case FDINFO_EXE:
+ snprintf(fd_str, sizeof(fd_str), "/proc/%d/exe", p->pid);
+ break;
+ default:
+ snprintf(fd_str, sizeof(fd_str), "/proc/%d/fd/%ld", p->pid, p->fd_name);
+ break;
+ }
lfd = open(fd_str, O_RDONLY);
if (lfd < 0) {
pr_perror("Failed to open regular file '%s'\n", fd_str);
@@ -175,32 +185,23 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
params = (struct fd_parms) {
.fd_name = FDINFO_CWD,
.id = FD_ID_INVALID,
- .pid = FD_PID_INVALID,
+ .pid = pid,
.type = FDINFO_FD,
};
- fd = open_proc(pid, "cwd");
- if (fd < 0)
- return -1;
- ret = dump_one_reg_file_fd(¶ms, fd, cr_fdset);
+ ret = dump_one_reg_file(¶ms, cr_fdset);
if (ret)
return ret;
- close(fd);
/* Dump /proc/pid/exe */
params = (struct fd_parms) {
.fd_name = FDINFO_EXE,
.id = FD_ID_INVALID,
- .pid = FD_PID_INVALID,
+ .pid = pid,
.type = FDINFO_FD,
};
- fd = open_proc(pid, "exe");
- if (fd < 0)
- return -1;
- ret = dump_one_reg_file_fd(¶ms, fd, cr_fdset);
- close(fd);
-
+ ret = dump_one_reg_file(¶ms, cr_fdset);
return ret;
}
More information about the CRIU
mailing list