]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Remounts bind mounts if read-only flag is provided
authorAbin Shahab <ashahab@altiscale.com>
Wed, 12 Nov 2014 00:06:52 +0000 (00:06 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 26 Nov 2014 15:33:54 +0000 (10:33 -0500)
Bind mounts do not honor filesystem mount options. This change will
remount filesystems that are bind mounted if there are changes to
filesystem mount options, specifically if the mount is readonly.

Signed-off-by: Abin Shahab <ashahab@altiscale.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c

index 9400dd3caa17de79055985aa756539ec4a874123..ac21c77130f2a6562eac06a29be319405f603c20 100644 (file)
@@ -1921,10 +1921,12 @@ static int mount_entry(const char *fsname, const char *target,
        if ((mountflags & MS_REMOUNT) || (mountflags & MS_BIND)) {
                DEBUG("remounting %s on %s to respect bind or remount options",
                      fsname ? fsname : "(none)", target ? target : "(none)");
-
+               unsigned long rqd_flags = 0;
+               if (mountflags & MS_RDONLY)
+                       rqd_flags |= MS_RDONLY;
 #ifdef HAVE_STATVFS
                if (statvfs(fsname, &sb) == 0) {
-                       unsigned long required_flags = 0;
+                       unsigned long required_flags = rqd_flags;
                        if (sb.f_flag & MS_NOSUID)
                                required_flags |= MS_NOSUID;
                        if (sb.f_flag & MS_NODEV)
@@ -1940,7 +1942,7 @@ static int mount_entry(const char *fsname, const char *target,
                         * mountflags, then skip the remount
                         */
                        if (!(mountflags & MS_REMOUNT)) {
-                               if (!(required_flags & ~mountflags)) {
+                               if (!(required_flags & ~mountflags) && rqd_flags == 0) {
                                        DEBUG("mountflags already was %lu, skipping remount",
                                                mountflags);
                                        goto skipremount;