]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: mount_entry()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 1 Aug 2017 20:46:14 +0000 (22:46 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 15 Aug 2017 20:36:24 +0000 (16:36 -0400)
non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 73d378667c1710a59b771319c487abfff15666c5..8cb6a291d0b9f320bb0bd73d829b707892d07945 100644 (file)
@@ -1687,77 +1687,91 @@ static char *get_field(char *src, int nfields)
 
 static int mount_entry(const char *fsname, const char *target,
                       const char *fstype, unsigned long mountflags,
-                      const char *data, int optional, int dev, const char *rootfs)
+                      const char *data, int optional, int dev,
+                      const char *rootfs)
 {
+       int ret;
 #ifdef HAVE_STATVFS
        struct statvfs sb;
 #endif
 
-       if (safe_mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data, rootfs)) {
+       ret = safe_mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data,
+                        rootfs);
+       if (ret < 0) {
                if (optional) {
-                       INFO("failed to mount '%s' on '%s' (optional): %s", fsname,
-                            target, strerror(errno));
+                       INFO("Failed to mount \"%s\" on \"%s\" (optional): %s",
+                            fsname, target, strerror(errno));
                        return 0;
                }
-               else {
-                       SYSERROR("failed to mount '%s' on '%s'", fsname, target);
-                       return -1;
-               }
+
+               SYSERROR("Failed to mount \"%s\" on \"%s\"", fsname, target);
+               return -1;
        }
 
        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;
+
+               DEBUG("Remounting \"%s\" on \"%s\" to respect bind or remount "
+                     "options",
+                     fsname ? fsname : "(none)", target ? target : "(none)");
+
                if (mountflags & MS_RDONLY)
                        rqd_flags |= MS_RDONLY;
 #ifdef HAVE_STATVFS
                if (statvfs(fsname, &sb) == 0) {
                        unsigned long required_flags = rqd_flags;
+
                        if (sb.f_flag & MS_NOSUID)
                                required_flags |= MS_NOSUID;
+
                        if (sb.f_flag & MS_NODEV && !dev)
                                required_flags |= MS_NODEV;
+
                        if (sb.f_flag & MS_RDONLY)
                                required_flags |= MS_RDONLY;
+
                        if (sb.f_flag & MS_NOEXEC)
                                required_flags |= MS_NOEXEC;
-                       DEBUG("(at remount) flags for %s was %lu, required extra flags are %lu", fsname, sb.f_flag, required_flags);
-                       /*
-                        * If this was a bind mount request, and required_flags
+
+                       DEBUG("Flags for \"%s\" were %lu, required extra flags "
+                             "are %lu", fsname, sb.f_flag, required_flags);
+
+                       /* If this was a bind mount request, and required_flags
                         * does not have any flags which are not already in
-                        * mountflags, then skip the remount
+                        * mountflags, then skip the remount.
                         */
                        if (!(mountflags & MS_REMOUNT)) {
-                               if (!(required_flags & ~mountflags) && rqd_flags == 0) {
-                                       DEBUG("mountflags already was %lu, skipping remount",
-                                               mountflags);
+                               if (!(required_flags & ~mountflags) &&
+                                   rqd_flags == 0) {
+                                       DEBUG("Mountflags already were %lu, "
+                                             "skipping remount", mountflags);
                                        goto skipremount;
                                }
                        }
+
                        mountflags |= required_flags;
                }
 #endif
 
-               if (mount(fsname, target, fstype,
-                         mountflags | MS_REMOUNT, data) < 0) {
+               ret = mount(fsname, target, fstype, mountflags | MS_REMOUNT, data);
+               if (ret < 0) {
                        if (optional) {
-                               INFO("failed to mount '%s' on '%s' (optional): %s",
-                                        fsname, target, strerror(errno));
+                               INFO("Failed to mount \"%s\" on \"%s\" "
+                                    "(optional): %s", fsname, target,
+                                    strerror(errno));
                                return 0;
                        }
-                       else {
-                               SYSERROR("failed to mount '%s' on '%s'",
-                                        fsname, target);
-                               return -1;
-                       }
+
+                       SYSERROR("Failed to mount \"%s\" on \"%s\"", fsname, target);
+                       return -1;
                }
        }
 
 #ifdef HAVE_STATVFS
 skipremount:
 #endif
-       DEBUG("mounted '%s' on '%s', type '%s'", fsname, target, fstype);
+       DEBUG("Mounted \"%s\" on \"%s\" with filesystem type \"%s\"", fsname,
+             target, fstype);
 
        return 0;
 }