]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab-generator: refuse to add swap earlier if disabled
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 May 2023 22:24:52 +0000 (07:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 May 2023 23:23:22 +0000 (08:23 +0900)
No functional change, preparation for later commits.

src/fstab-generator/fstab-generator.c

index 042cce1ffafec0e1590368329d9b21c00295d837..5776eb421a8ed1fe8fcb25850c9849fe27bb4294 100644 (file)
@@ -111,11 +111,6 @@ static int add_swap(
 
         assert(what);
 
-        if (!arg_swap_enabled) {
-                log_info("Swap unit generation disabled on kernel command line, ignoring fstab swap entry for %s.", what);
-                return 0;
-        }
-
         if (access("/proc/swaps", F_OK) < 0) {
                 log_info("Swap not supported, ignoring fstab swap entry for %s.", what);
                 return 0;
@@ -718,6 +713,10 @@ static int parse_fstab_one(
                 return 0;
 
         is_swap = streq_ptr(fstype, "swap");
+        if (is_swap && !arg_swap_enabled) {
+                log_info("Swap unit generation disabled on kernel command line, ignoring swap entry for %s.", what);
+                return 0;
+        }
 
         what = fstab_node_to_udev_node(what_original);
         if (!what)