]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/swap: /sbin -> /usr/sbin
authorArian van Putten <arian.vanputten@gmail.com>
Sun, 24 Aug 2025 11:24:26 +0000 (13:24 +0200)
committerArian van Putten <arian.vanputten@gmail.com>
Sun, 24 Aug 2025 11:59:22 +0000 (13:59 +0200)
I noticed in our NixOS packaging that we were working around the fact
that core/swap.c looks for swapon and swapoff in /sbin

Lets make it configurable just like all the other util-linux binaries
through meson and make it default to /usr/sbin/{swapon,swapoff}

This way mounts work on a systemd without the /sbin -> /usr/sbin
compatibility symlink.  (And as a side-effect has NixOS be able
to have it in /nix/store too like the other util-linux tools).

meson.build
meson_options.txt
src/core/swap.c

index f3d0a4b51534e5115f6f30d7bbecf1efce54e009..fc3748c1340242e0c7ce3e6f5c884d447d5b6a1a 100644 (file)
@@ -634,6 +634,8 @@ progs = [['quotaon',    '/usr/sbin/quotaon'    ],
          ['kmod',       '/usr/bin/kmod'        ],
          ['kexec',      '/usr/sbin/kexec'      ],
          ['sulogin',    '/usr/sbin/sulogin'    ],
+         ['swapon',     '/usr/sbin/swapon'     ],
+         ['swapoff',    '/usr/sbin/swapoff'    ],
          ['mount',      '/usr/bin/mount',      'MOUNT_PATH'],
          ['umount',     '/usr/bin/umount',     'UMOUNT_PATH'],
          ['loadkeys',   '/usr/bin/loadkeys',   'KBD_LOADKEYS'],
index d8dec33ec42e7ffc45330b33dec9b3ffb88ff3d6..abcdc279a25dac413370c528e47a1e1ae2468388 100644 (file)
@@ -57,6 +57,8 @@ option('quotacheck-path', type : 'string', description : 'path to quotacheck')
 option('kmod-path', type : 'string', description : 'path to kmod')
 option('kexec-path', type : 'string', description : 'path to kexec')
 option('sulogin-path', type : 'string', description : 'path to sulogin')
+option('swapon-path', type : 'string', description : 'path to swapon')
+option('swapoff-path', type : 'string', description : 'path to swapoff')
 option('mount-path', type : 'string', description : 'path to mount')
 option('umount-path', type : 'string', description : 'path to umount')
 option('loadkeys-path', type : 'string', description : 'path to loadkeys')
index 9146ae91069c194acf06e322e5b472a84f3318e8..26a934013a1eb84b617c72073498d1a07c5d81dc 100644 (file)
@@ -781,7 +781,7 @@ static void swap_enter_activating(Swap *s) {
                 }
         }
 
-        r = exec_command_set(s->control_command, "/sbin/swapon", "--fixpgsz", NULL);
+        r = exec_command_set(s->control_command, SWAPON, "--fixpgsz", NULL);
         if (r < 0) {
                 log_unit_warning_errno(UNIT(s), r, "Failed to initialize swapon command line: %m");
                 goto fail;
@@ -826,7 +826,7 @@ static void swap_enter_deactivating(Swap *s) {
         s->control_command = s->exec_command + SWAP_EXEC_DEACTIVATE;
 
         r = exec_command_set(s->control_command,
-                             "/sbin/swapoff",
+                             SWAPOFF,
                              s->what,
                              NULL);
         if (r < 0) {