[CRIU] [PATCH v7 07/15] files: new dup_fdinfo() and dup_fle() helpers introduced
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Mon Mar 14 07:59:11 PDT 2016
This helpers will be used by autofs restore to create temporary pipe
descriptors.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
criu/files.c | 29 +++++++++++++++++++++++++++++
criu/include/files.h | 4 ++++
2 files changed, 33 insertions(+)
diff --git a/criu/files.c b/criu/files.c
index 5f59110..145032b 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -652,6 +652,35 @@ static int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
return 0;
}
+FdinfoEntry *dup_fdinfo(FdinfoEntry *old, int fd, unsigned flags)
+{
+ FdinfoEntry *e;
+
+ e = shmalloc(sizeof(*e));
+ if (!e)
+ return NULL;
+
+ fdinfo_entry__init(e);
+
+ e->id = old->id;
+ e->type = old->type;
+ e->fd = fd;
+ e->flags = flags;
+ return e;
+}
+
+int dup_fle(struct pstree_item *task, struct fdinfo_list_entry *ple,
+ int fd, unsigned flags)
+{
+ FdinfoEntry *e;
+
+ e = dup_fdinfo(ple->fe, fd, flags);
+ if (!e)
+ return -1;
+
+ return collect_fd(task->pid.virt, e, rsti(task));
+}
+
int prepare_ctl_tty(int pid, struct rst_info *rst_info, u32 ctl_tty_id)
{
FdinfoEntry *e;
diff --git a/criu/include/files.h b/criu/include/files.h
index 9d7a500..fbe9a07 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -210,4 +210,8 @@ extern int inherit_fd_lookup_id(char *id);
extern bool inherited_fd(struct file_desc *, int *fdp);
+extern FdinfoEntry *dup_fdinfo(FdinfoEntry *old, int fd, unsigned flags);
+int dup_fle(struct pstree_item *task, struct fdinfo_list_entry *ple,
+ int fd, unsigned flags);
+
#endif /* __CR_FILES_H__ */
More information about the CRIU
mailing list