mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
dump: Add should_ignore_fd helper
We should ignore tty devices for a while. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
51
cr-dump.c
51
cr-dump.c
@@ -221,6 +221,34 @@ err:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool should_ignore_fd(char *pid_fd_dir, int dir, char *fd_name)
|
||||||
|
{
|
||||||
|
if (!strcmp(fd_name, "0")) {
|
||||||
|
pr_info("... Skipping stdin ...\n");
|
||||||
|
return true;
|
||||||
|
} else if (!strcmp(fd_name, "1")) {
|
||||||
|
pr_info("... Skipping stdout ...\n");
|
||||||
|
return true;
|
||||||
|
} else if (!strcmp(fd_name, "2")) {
|
||||||
|
pr_info("... Skipping stderr ...\n");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
char ttybuf[32];
|
||||||
|
|
||||||
|
if (readlinkat(dir, fd_name, ttybuf, sizeof(ttybuf)) > 0) {
|
||||||
|
if (!strncmp(ttybuf, "/dev/tty", 8)) {
|
||||||
|
pr_info("... Skipping tty ...\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pr_perror("Failed to readlink %s/%d %s\n", pid_fd_dir, dir, fd_name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long pos,
|
static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long pos,
|
||||||
unsigned int flags, struct cr_fdset *cr_fdset)
|
unsigned int flags, struct cr_fdset *cr_fdset)
|
||||||
{
|
{
|
||||||
@@ -228,6 +256,9 @@ static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long p
|
|||||||
struct stat st_buf;
|
struct stat st_buf;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
if (should_ignore_fd(pid_fd_dir, dir, fd_name))
|
||||||
|
return 0;
|
||||||
|
|
||||||
fd = openat(dir, fd_name, O_RDONLY);
|
fd = openat(dir, fd_name, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
pr_perror("Failed to openat %s/%d %s\n", pid_fd_dir, dir, fd_name);
|
pr_perror("Failed to openat %s/%d %s\n", pid_fd_dir, dir, fd_name);
|
||||||
@@ -254,26 +285,6 @@ static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long p
|
|||||||
st_buf.st_ino, flags, cr_fdset);
|
st_buf.st_ino, flags, cr_fdset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(fd_name, "0")) {
|
|
||||||
pr_info("... Skipping stdin ...\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(fd_name, "1")) {
|
|
||||||
pr_info("... Skipping stdout ...\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(fd_name, "2")) {
|
|
||||||
pr_info("... Skipping stderr ...\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(fd_name, "3")) {
|
|
||||||
pr_info("... Skipping tty ...\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pr_err("Can't dump file %s of that type [%x]\n", fd_name, st_buf.st_mode);
|
pr_err("Can't dump file %s of that type [%x]\n", fd_name, st_buf.st_mode);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user