[CRIU] [PATCH 10/16] dump: use switch for dumping fd
Kinsbursky Stanislav
skinsbursky at openvz.org
Thu Mar 1 12:57:23 EST 2012
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
cr-dump.c | 61 +++++++++++++++++++++++++++++++++++--------------------------
1 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index c6bf919..295be26 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -337,39 +337,48 @@ static int dump_one_fd(pid_t pid, char *d_name, struct cr_fdset *cr_fdset,
return -1;
lfd = open(file_path, O_RDONLY);
- if (lfd < 0) {
+
+ switch (fd_stat.st_mode & S_IFMT) {
+ case S_IFCHR:
+ if (major(fd_stat.st_rdev) != MEM_MAJOR) {
+ if ((major(fd_stat.st_rdev) == TTY_MAJOR) ||
+ (major(fd_stat.st_rdev) == UNIX98_PTY_SLAVE_MAJOR)) {
+ /* skip only standard destriptors */
+ if (atoi(d_name) < 3) {
+ err = 0;
+ pr_info("... Skipping tty ... '%s'\n",
+ file_path);
+ }
+ }
+ break;
+ }
+ /*
+ * This is a TMPFS file.
+ * Proceed to dump_one_reg_file().
+ */
+ case S_IFREG:
+ err = dump_one_reg_file(&p, lfd, cr_fdset, 0);
+ break;
+ case S_IFIFO:
+ err = dump_one_pipe(&p, lfd, cr_fdset);
+ break;
+ case S_IFSOCK:
err = try_dump_socket(pid, p.fd_name, cr_fdset, sk_queue);
if (err != 1)
return err;
pr_perror("Failed to open '%s'", file_path);
return -1;
+ case S_IFDIR:
+ case S_IFLNK:
+ case S_IFBLK:
+ break;
+ default:
+ pr_err("%s: unknown file type: %o\n", __func__, fd_stat.st_mode & S_IFMT);
+ break;
}
-
- if (S_ISCHR(fd_stat.st_mode) &&
- (major(fd_stat.st_rdev) == TTY_MAJOR ||
- major(fd_stat.st_rdev) == UNIX98_PTY_SLAVE_MAJOR)) {
- /* skip only standard destriptors */
- if (p.fd_name < 3) {
- err = 0;
- pr_info("... Skipping tty ... '%s'\n",
- file_path);
- goto out_close;
- }
- goto err;
- }
-
- if (S_ISREG(fd_stat.st_mode) ||
- (S_ISCHR(fd_stat.st_mode) && major(fd_stat.st_rdev) == MEM_MAJOR))
- return dump_one_reg_file(&p, lfd, cr_fdset, 1);
-
- if (S_ISFIFO(fd_stat.st_mode))
- return dump_one_pipe(&p, lfd, cr_fdset);
-
-err:
- pr_err("Can't dump file %ld of that type [%x]\n", p.fd_name, fd_stat.st_mode);
-
-out_close:
+ if (err)
+ pr_err("Can't dump file %ld of that type [%x]\n", p.fd_name, fd_stat.st_mode);
close_safe(&lfd);
return err;
}
More information about the CRIU
mailing list