[CRIU] [PATCH v2] files-reg: Adjust file position for /dev/kmsg
Cyrill Gorcunov
gorcunov at gmail.com
Tue Jul 21 00:23:41 PDT 2015
On Mon, Jul 20, 2015 at 08:11:58PM +0300, Cyrill Gorcunov wrote:
> On Mon, Jul 20, 2015 at 08:09:49PM +0300, Pavel Emelyanov wrote:
> > >
> > > + adjust_file_pos(p, &rfe);
> >
> > Plz, don't put it into generic function. Declare ops for dump_chrdev's
> > MEM_MAJOR case and fix this up there.
>
> Managed to miss it. OK, will redo.
Attached.
-------------- next part --------------
>From dc9a1f5c4ea619ac716f8b6fab0f35166d1f4bf3 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Mon, 20 Jul 2015 12:40:16 +0300
Subject: [PATCH] files: Adjust file position for /dev/kmsg
The kernel doesnt allow to call lseek on /dev/kmsg
if it has been opened with O_WRONLY mode so our
restore procedure fails.
Thus if we meet a file which fits the condition
above -- set it's position to predefined value
which tells criu to not call lseek on restore.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
files.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/files.c b/files.c
index 3e69be731a5a..071fa69c48f4 100644
--- a/files.c
+++ b/files.c
@@ -271,6 +271,29 @@ static const struct fdtype_ops *get_misc_dev_ops(int minor)
return NULL;
}
+static const struct fdtype_ops *get_mem_dev_ops(struct fd_parms *p, int minor)
+{
+ const struct fdtype_ops *ops = NULL;
+
+ switch (minor) {
+ case 11:
+ /*
+ * If /dev/kmsg is opened in write-only mode the file position
+ * should not be set up upon restore, kernel doesn't allow that.
+ */
+ if ((p->flags & O_ACCMODE) == O_WRONLY && p->pos == 0)
+ p->pos = -1ULL;
+ /*
+ * Fallthrough.
+ */
+ default:
+ ops = ®file_dump_ops;
+ break;
+ };
+
+ return ops;
+}
+
static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
{
int maj = major(p->stat.st_rdev);
@@ -278,7 +301,7 @@ static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
switch (maj) {
case MEM_MAJOR:
- ops = ®file_dump_ops;
+ ops = get_mem_dev_ops(p, minor(p->stat.st_rdev));
break;
case MISC_MAJOR:
ops = get_misc_dev_ops(minor(p->stat.st_rdev));
--
2.4.3
More information about the CRIU
mailing list