Commit d9fb2011 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent aef7ff04
...@@ -1841,20 +1841,22 @@ skip_parent: ...@@ -1841,20 +1841,22 @@ skip_parent:
return 0; return 0;
} }
#define MS_CHANGE_TYPE_MASK \
(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)
static int do_new_mount(struct mount_info *mi) static int do_new_mount(struct mount_info *mi)
{ {
unsigned long mflags = MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE;
char *src; char *src;
struct fstype *tp = mi->fstype; struct fstype *tp = mi->fstype;
bool remount_ro = (tp->restore && mi->flags & MS_RDONLY);
src = resolve_source(mi); src = resolve_source(mi);
if (!src) if (!src)
return -1; return -1;
if (remount_ro)
mflags |= MS_RDONLY;
if (mount(src, mi->mountpoint, tp->name, 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); pr_perror("Can't mount at %s", mi->mountpoint);
return -1; return -1;
} }
...@@ -1869,6 +1871,9 @@ static int do_new_mount(struct mount_info *mi) ...@@ -1869,6 +1871,9 @@ static int do_new_mount(struct mount_info *mi)
if (tp->restore && tp->restore(mi)) if (tp->restore && tp->restore(mi))
return -1; return -1;
if (remount_ro)
return mount(NULL, mi->mountpoint, tp->name,
MS_REMOUNT | MS_RDONLY, NULL);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment