]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fix issue #1702, do remount with the MS_REMOUNT flag when mounts with MS_RDONLY
authorLi Feng <lifeng68@huawei.com>
Mon, 17 Jul 2017 09:09:16 +0000 (17:09 +0800)
committerLi Feng <lifeng68@huawei.com>
Mon, 17 Jul 2017 09:09:16 +0000 (17:09 +0800)
Signed-off-by: Li Feng <lifeng68@huawei.com>
src/lxc/bdev/lxcdir.c

index 652d7e08f0b4030705178e60c4fe3d8ffc169585..0778df1ccfca28f14533fb0fb30b629721376bdd 100644 (file)
@@ -151,6 +151,12 @@ int dir_mount(struct bdev *bdev)
        src = lxc_storage_get_path(bdev->src, bdev->type);
 
        ret = mount(src, bdev->dest, "bind", MS_BIND | MS_REC | mntflags, mntdata);
+       if ((0 == ret) && (mntflags & MS_RDONLY)) {
+               DEBUG("remounting %s on %s with readonly options",
+                       src ? src : "(none)", bdev->dest ? bdev->dest : "(none)");
+               ret = mount(src, bdev->dest, "bind", MS_BIND | MS_REC | mntflags | MS_REMOUNT, mntdata);
+       }
+
        free(mntdata);
        return ret;
 }