[CRIU] [PATCH] files: Don't call lseek on some restored files
Pavel Emelyanov
xemul at parallels.com
Thu Feb 6 11:20:00 PST 2014
Those opened for cwd, root, exe link and vma-s do not
care about the pos value.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
files-reg.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/files-reg.c b/files-reg.c
index 78d96de..e4ea09f 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -633,7 +633,7 @@ int open_path_by_id(u32 id, int (*open_cb)(struct reg_file_info *, void *), void
return open_path(fd, open_cb, arg);
}
-static int do_open_reg(struct reg_file_info *rfi, void *arg)
+static int do_open_reg_noseek(struct reg_file_info *rfi, void *arg)
{
int fd;
@@ -643,6 +643,17 @@ static int do_open_reg(struct reg_file_info *rfi, void *arg)
return fd;
}
+ return fd;
+}
+
+static int do_open_reg(struct reg_file_info *rfi, void *arg)
+{
+ int fd;
+
+ fd = do_open_reg_noseek(rfi, arg);
+ if (fd < 0)
+ return fd;
+
if ((rfi->rfe->pos != -1ULL) &&
lseek(fd, rfi->rfe->pos, SEEK_SET) < 0) {
pr_perror("Can't restore file pos");
@@ -660,7 +671,13 @@ static int open_fe_fd(struct file_desc *fd)
int open_reg_by_id(u32 id)
{
- return open_path_by_id(id, do_open_reg, NULL);
+ /*
+ * This one gets called by exe link, chroot,
+ * cwd and file vmas restoring code. No need
+ * in calling lseek on either of them.
+ */
+
+ return open_path_by_id(id, do_open_reg_noseek, NULL);
}
static void remap_get(struct file_desc *fdesc, char typ)
--
1.8.4.2
More information about the CRIU
mailing list