chiark / gitweb /
mount: don't fail if fstab doesn't exist
authorLennart Poettering <lennart@poettering.net>
Sun, 22 Apr 2012 13:33:43 +0000 (15:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Sun, 22 Apr 2012 13:33:43 +0000 (15:33 +0200)
src/core/mount.c
src/cryptsetup/cryptsetup.c
src/remount-api-vfs/remount-api-vfs.c

index 760ffcd..dbd4893 100644 (file)
@@ -1537,8 +1537,9 @@ static int mount_load_etc_fstab(Manager *m) {
         assert(m);
 
         errno = 0;
-        if (!(f = setmntent("/etc/fstab", "r")))
-                return -errno;
+        f = setmntent("/etc/fstab", "r");
+        if (!f)
+                return errno == ENOENT ? 0 : -errno;
 
         while ((me = getmntent(f))) {
                 char *where, *what;
index f214d60..3ff0ddf 100644 (file)
@@ -190,7 +190,8 @@ static char *disk_mount_point(const char *label) {
         if (asprintf(&device, "/dev/mapper/%s", label) < 0)
                 goto finish;
 
-        if (!(f = setmntent("/etc/fstab", "r")))
+        f = setmntent("/etc/fstab", "r");
+        if (!f)
                 goto finish;
 
         while ((m = getmntent(f)))
index 6cb77c1..373ae25 100644 (file)
@@ -56,6 +56,11 @@ int main(int argc, char *argv[]) {
 
         f = setmntent("/etc/fstab", "r");
         if (!f) {
+                if (errno == ENOENT) {
+                        ret = EXIT_SUCCESS;
+                        goto finish;
+                }
+
                 log_error("Failed to open /etc/fstab: %m");
                 goto finish;
         }