[CRIU] [PATCH v5 08/15] files: new dup_fdinfo() and dup_fle() helpers introduced
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Wed Jan 27 04:04:25 PST 2016
This helpers will be used by autofs restore to create temporary pipe
descriptors.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
files.c | 29 +++++++++++++++++++++++++++++
include/files.h | 4 ++++
2 files changed, 33 insertions(+)
diff --git a/files.c b/files.c
index 0928649..f605a51 100644
--- a/files.c
+++ b/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/include/files.h b/include/files.h
index da38d88..df236ab 100644
--- a/include/files.h
+++ b/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