2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

dump: use fd_params->type for cwd and exe magic

This is a cleanup patch. Use file entry type variable for special files
instead of file entry addr variable.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Kinsbursky Stanislav
2012-03-06 15:52:00 +04:00
committed by Pavel Emelyanov
parent fede33e047
commit c1999ec58e
4 changed files with 14 additions and 15 deletions

View File

@@ -164,10 +164,9 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
/* Dump /proc/pid/cwd */ /* Dump /proc/pid/cwd */
params = (struct fd_parms) { params = (struct fd_parms) {
.fd_name = FDINFO_CWD,
.id = FD_ID_INVALID, .id = FD_ID_INVALID,
.pid = FD_PID_INVALID, .pid = FD_PID_INVALID,
.type = FDINFO_FD, .type = FDINFO_CWD,
}; };
fd = open_proc(pid, "cwd"); fd = open_proc(pid, "cwd");
@@ -179,10 +178,9 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
/* Dump /proc/pid/exe */ /* Dump /proc/pid/exe */
params = (struct fd_parms) { params = (struct fd_parms) {
.fd_name = FDINFO_EXE,
.id = FD_ID_INVALID, .id = FD_ID_INVALID,
.pid = FD_PID_INVALID, .pid = FD_PID_INVALID,
.type = FDINFO_FD, .type = FDINFO_EXE,
}; };
fd = open_proc(pid, "exe"); fd = open_proc(pid, "exe");
@@ -358,7 +356,7 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
(S_ISCHR(fd_stat.st_mode) && major(fd_stat.st_rdev) == MEM_MAJOR)) { (S_ISCHR(fd_stat.st_mode) && major(fd_stat.st_rdev) == MEM_MAJOR)) {
p.id = MAKE_FD_GENID(fd_stat.st_dev, fd_stat.st_ino, p.pos); p.id = MAKE_FD_GENID(fd_stat.st_dev, fd_stat.st_ino, p.pos);
p.type = FDINFO_FD; p.type = FDINFO_REG;
return dump_one_reg_file(&p, lfd, cr_fdset, 1); return dump_one_reg_file(&p, lfd, cr_fdset, 1);
} }

View File

@@ -403,7 +403,7 @@ static int open_fdinfo(int pid, struct fdinfo_entry *fe, int *fdinfo_fd, int sta
pr_info("\t%d: Got fd for %lx type %d namelen %d users %d\n", pid, pr_info("\t%d: Got fd for %lx type %d namelen %d users %d\n", pid,
(unsigned long)fe->addr, fe->type, fe->len, fi->users); (unsigned long)fe->addr, fe->type, fe->len, fi->users);
BUG_ON(fe->type != FDINFO_FD); BUG_ON(fe->type != FDINFO_REG);
switch (state) { switch (state) {
@@ -431,11 +431,12 @@ static int open_special_fdinfo(int pid, struct fdinfo_entry *fe,
if (fe->type == FDINFO_MAP) if (fe->type == FDINFO_MAP)
return open_fmap(pid, fe, fdinfo_fd); return open_fmap(pid, fe, fdinfo_fd);
if (fe->addr == FDINFO_CWD) if (fe->type == FDINFO_CWD)
return restore_cwd(fe, fdinfo_fd); return restore_cwd(fe, fdinfo_fd);
if (fe->addr == FDINFO_EXE) if (fe->type == FDINFO_EXE)
return restore_exe_early(fe, fdinfo_fd); return restore_exe_early(fe, fdinfo_fd);
pr_info("%d: fe->type: %d\n", pid, fe->type);
BUG_ON(1); BUG_ON(1);
return -1; return -1;
} }

View File

@@ -29,12 +29,12 @@
#define PIPEFS_MAGIC 0x50495045 #define PIPEFS_MAGIC 0x50495045
#define FDINFO_FD 1 #define FDINFO_REG 1
#define FDINFO_MAP 2 #define FDINFO_MAP 2
/* Specials */ /* Specials */
#define FDINFO_CWD (-1ULL) #define FDINFO_CWD 3
#define FDINFO_EXE (-2ULL) #define FDINFO_EXE 4
#define PAGE_IMAGE_SIZE 4096 #define PAGE_IMAGE_SIZE 4096
#define PAGE_RSS 1 #define PAGE_RSS 1
@@ -51,9 +51,9 @@ struct fdinfo_entry {
} __packed; } __packed;
#define fd_is_special(fe) \ #define fd_is_special(fe) \
(((fe)->type != FDINFO_FD) || \ (((fe)->type == FDINFO_MAP) || \
((fe)->addr == FDINFO_CWD) || \ ((fe)->type == FDINFO_CWD) || \
((fe)->addr == FDINFO_EXE)) ((fe)->type == FDINFO_EXE))
struct shmem_entry { struct shmem_entry {
u64 start; u64 start;

View File

@@ -248,7 +248,7 @@ static long restore_self_exe_late(struct task_restore_core_args *args)
goto err; goto err;
} }
if (fe.type == FDINFO_FD && fe.addr == FDINFO_EXE) if (fe.type == FDINFO_EXE)
break; break;
if (fe.len) if (fe.len)