]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab-util: make use of PROC_CMDLINE_TRUE_WHEN_MISSING
authorMike Yuan <me@yhndnzj.com>
Thu, 10 Aug 2023 15:25:17 +0000 (23:25 +0800)
committerMike Yuan <me@yhndnzj.com>
Sun, 13 Aug 2023 04:52:15 +0000 (12:52 +0800)
src/shared/fstab-util.c

index fed0e1113fde4313d801d22faacb9779898f477e..55e76b6e16bc6d8f78aa6f1e40405290b2c2d9a2 100644 (file)
@@ -19,7 +19,7 @@
 
 bool fstab_enabled_full(int enabled) {
         static int cached = -1;
-        bool val;
+        bool val = true; /* If nothing specified or the check fails, then defaults to true. */
         int r;
 
         /* If 'enabled' is non-negative, then update the cache with it. */
@@ -29,12 +29,11 @@ bool fstab_enabled_full(int enabled) {
         if (cached >= 0)
                 return cached;
 
-        r = proc_cmdline_get_bool("fstab", PROC_CMDLINE_STRIP_RD_PREFIX, &val);
+        r = proc_cmdline_get_bool("fstab", PROC_CMDLINE_STRIP_RD_PREFIX|PROC_CMDLINE_TRUE_WHEN_MISSING, &val);
         if (r < 0)
-                log_debug_errno(r, "Failed to parse kernel command line, ignoring: %m");
+                log_debug_errno(r, "Failed to parse fstab= kernel command line option, ignoring: %m");
 
-        /* If nothing specified, then defaults to true. */
-        return (cached = r > 0 ? val : true);
+        return (cached = val);
 }
 
 int fstab_has_fstype(const char *fstype) {