]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Don't trigger SYSERROR for optional mounts
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Mar 2014 21:18:15 +0000 (16:18 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Sat, 8 Mar 2014 00:13:09 +0000 (19:13 -0500)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c

index 58a9b4f275eeeab76c2643097dddf4a22dcb07f3..43465855278580ddffa1c04cea2e78788da00fb6 100644 (file)
@@ -1821,11 +1821,18 @@ int parse_mntopts(const char *mntopts, unsigned long *mntflags,
 
 static int mount_entry(const char *fsname, const char *target,
                       const char *fstype, unsigned long mountflags,
-                      const char *data)
+                      const char *data, int optional)
 {
        if (mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data)) {
-               SYSERROR("failed to mount '%s' on '%s'", fsname, target);
-               return -1;
+               if (optional) {
+                       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;
+               }
        }
 
        if ((mountflags & MS_REMOUNT) || (mountflags & MS_BIND)) {
@@ -1835,9 +1842,16 @@ static int mount_entry(const char *fsname, const char *target,
 
                if (mount(fsname, target, fstype,
                          mountflags | MS_REMOUNT, data)) {
-                       SYSERROR("failed to mount '%s' on '%s'",
-                                fsname, target);
-                       return -1;
+                       if (optional) {
+                               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;
+                       }
                }
        }
 
@@ -1910,10 +1924,7 @@ static inline int mount_entry_on_systemfs(struct mntent *mntent)
        }
 
        ret = mount_entry(mntent->mnt_fsname, mntent->mnt_dir,
-                         mntent->mnt_type, mntflags, mntdata);
-
-       if (optional)
-               ret = 0;
+                         mntent->mnt_type, mntflags, mntdata, optional);
 
        free(pathdirname);
        free(mntdata);
@@ -2000,13 +2011,10 @@ skipabs:
        }
 
        ret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type,
-                         mntflags, mntdata);
+                         mntflags, mntdata, optional);
 
        free(mntdata);
 
-       if (optional)
-               ret = 0;
-
 out:
        free(pathdirname);
        return ret;
@@ -2059,10 +2067,7 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent,
        }
 
        ret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type,
-                         mntflags, mntdata);
-
-       if (optional)
-               ret = 0;
+                         mntflags, mntdata, optional);
 
        free(pathdirname);
        free(mntdata);