[CRIU] [PATCH v2 20/30] files: Teach collect_fd() mark fake files
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jun 7 14:29:09 MSK 2017
Add new argument to this function.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/autofs.c | 2 +-
criu/files.c | 9 +++++----
criu/include/files.h | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
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 2b3d2a8f1..d0a7a0dcf 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);
More information about the CRIU
mailing list