[CRIU] [PATCH] mount: Add ability to restore ro tmpfs
Cyrill Gorcunov
gorcunov at gmail.com
Wed May 27 05:54:24 PDT 2015
On Wed, May 27, 2015 at 03:45:35PM +0300, Pavel Emelyanov wrote:
> > + bool remount_ro = (tp->code == FSTYPE__TMPFS && mi->flags & MS_RDONLY);
>
> The same can be required for devtmpfs too. I would say that any fs with ->restore
> callback might want to see the mountpoint writable :)
>
-------------- next part --------------
>From 4ac828f5e52adff7a80f0a4f1670dcd4136c811a Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Wed, 27 May 2015 15:22:00 +0300
Subject: [PATCH] mount: Add ability to restore ro tmpfs
In case if we've dumped read only tmpfs we fail restoring it
because it's mounted with ro flags. Lets mount it with rw,
restore content and then remount as ro.
upd (by xemul@): any fs with restore method likely to
need rw permission on restore.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
mount.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/mount.c b/mount.c
index e45b8b29866e..58478da1940e 100644
--- a/mount.c
+++ b/mount.c
@@ -1843,20 +1843,22 @@ skip_parent:
return 0;
}
-#define MS_CHANGE_TYPE_MASK \
- (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)
-
static int do_new_mount(struct mount_info *mi)
{
+ unsigned long mflags = MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE;
char *src;
struct fstype *tp = mi->fstype;
+ bool remount_ro = (tp->restore && mi->flags & MS_RDONLY);
src = resolve_source(mi);
if (!src)
return -1;
+ if (remount_ro)
+ mflags |= MS_RDONLY;
+
if (mount(src, mi->mountpoint, tp->name,
- mi->flags & ~MS_CHANGE_TYPE_MASK, mi->options) < 0) {
+ mi->flags & ~mflags, mi->options) < 0) {
pr_perror("Can't mount at %s", mi->mountpoint);
return -1;
}
@@ -1871,6 +1873,9 @@ static int do_new_mount(struct mount_info *mi)
if (tp->restore && tp->restore(mi))
return -1;
+ if (remount_ro)
+ return mount(NULL, mi->mountpoint, tp->name,
+ MS_REMOUNT | MS_RDONLY, NULL);
return 0;
}
--
2.1.0
More information about the CRIU
mailing list