[26/28] files: Teach collect_fd() mark fake files

Submitted by Kirill Tkhai on June 5, 2017, 5:27 p.m.

Details

Message ID 149668363537.25229.4651738213072908250.stgit@localhost.localdomain
State Accepted
Series "Support sockets leaked to child user_ns task"
Commit ef3f9c660c59114480a0ef740c2a74bbbb244963
Headers show

Commit Message

Kirill Tkhai June 5, 2017, 5:27 p.m.
Add new argument to this function.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/autofs.c        |    2 +-
 criu/files.c         |    9 +++++----
 criu/include/files.h |    2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/autofs.c b/criu/autofs.c
index 31aabfe9f..b0c5cab64 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -907,7 +907,7 @@  static int autofs_create_pipe(struct pstree_item *task, autofs_info_t *i,
 
 	pr_info("autofs: adding pipe fd %d, flags %#x to %d (with post_open)\n",
 		fe->fd, fe->flags, vpid(task));
-	return collect_fd(vpid(task), fe, rsti(task));
+	return collect_fd(vpid(task), fe, rsti(task), false);
 }
 
 static int autofs_add_mount_info(struct pprep_head *ph)
diff --git a/criu/files.c b/criu/files.c
index f97b7a0a2..b66217c02 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -768,7 +768,7 @@  static void collect_desc_fle(struct fdinfo_list_entry *new_le, struct file_desc
 	list_add_tail(&new_le->desc_list, &le->desc_list);
 }
 
-int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
+int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info, bool fake)
 {
 	struct fdinfo_list_entry *new_le;
 	struct file_desc *fdesc;
@@ -779,6 +779,7 @@  int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
 	new_le = alloc_fle(pid, e);
 	if (!new_le)
 		return -1;
+	new_le->fake = (!!fake);
 
 	fdesc = find_file_desc(e);
 	if (fdesc == NULL) {
@@ -817,7 +818,7 @@  int dup_fle(struct pstree_item *task, struct fdinfo_list_entry *ple,
 	if (!e)
 		return -1;
 
-	return collect_fd(vpid(task), e, rsti(task));
+	return collect_fd(vpid(task), e, rsti(task), false);
 }
 
 int prepare_ctl_tty(int pid, struct rst_info *rst_info, u32 ctl_tty_id)
@@ -839,7 +840,7 @@  int prepare_ctl_tty(int pid, struct rst_info *rst_info, u32 ctl_tty_id)
 	e->fd		= reserve_service_fd(CTL_TTY_OFF);
 	e->type		= FD_TYPES__TTY;
 
-	if (collect_fd(pid, e, rst_info)) {
+	if (collect_fd(pid, e, rst_info, false)) {
 		xfree(e);
 		return -1;
 	}
@@ -879,7 +880,7 @@  int prepare_fd_pid(struct pstree_item *item)
 			break;
 		}
 
-		ret = collect_fd(pid, e, rst_info);
+		ret = collect_fd(pid, e, rst_info, false);
 		if (ret < 0) {
 			fdinfo_entry__free_unpacked(e, NULL);
 			break;
diff --git a/criu/include/files.h b/criu/include/files.h
index fb47eb879..812ef8947 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -108,7 +108,7 @@  struct file_desc_ops {
 	char *			(*name)(struct file_desc *, char *b, size_t s);
 };
 
-int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info);
+int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info, bool ghost);
 
 unsigned int find_unused_fd(struct pstree_item *, int hint_fd);
 struct fdinfo_list_entry *find_used_fd(struct pstree_item *, int fd);