]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapon: search for mkswap via PATH
authorMike Frysinger <vapier@gentoo.org>
Sun, 12 Apr 2015 09:06:52 +0000 (05:06 -0400)
committerKarel Zak <kzak@redhat.com>
Mon, 27 Apr 2015 08:28:44 +0000 (10:28 +0200)
Rather than hardcode /sbin/mkswap all the time, use a normal PATH search.
This matches the normal behavior of other tools, and makes local testing
easier.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
sys-utils/swapon.8
sys-utils/swapon.c

index e571a5fb0b24bfddb7889fc5ca44cf9657b66968..299da2282def6ee23cf5521481f7068d517b2c57 100644 (file)
@@ -108,7 +108,7 @@ may also be used to skip non-existing device.
 
 .TP
 .BR \-f , " \-\-fixpgsz"
-Reinitialize (exec /sbin/mkswap) the swap space if its page size does not
+Reinitialize (exec mkswap) the swap space if its page size does not
 match that of the current running kernel.
 .BR mkswap (2)
 initializes the whole device and does not check for bad blocks.
index 645a01d423ab0f957145dcab85c8839cf4c05ca7..561b1a9671eeb0bcfb37f99078cb677dbc45150a 100644 (file)
@@ -28,8 +28,6 @@
 #include "swapprober.h"
 #include "swapon-common.h"
 
-#define PATH_MKSWAP    "/sbin/mkswap"
-
 #ifdef HAVE_SYS_SWAP_H
 # include <sys/swap.h>
 #endif
@@ -303,7 +301,7 @@ static int swap_reinitialize(const char *device,
                return -1;
 
        case 0: /* child */
-               cmd[idx++] = PATH_MKSWAP;
+               cmd[idx++] = "mkswap";
                if (label && *label) {
                        cmd[idx++] = "-L";
                        cmd[idx++] = (char *) label;
@@ -314,7 +312,7 @@ static int swap_reinitialize(const char *device,
                }
                cmd[idx++] = (char *) device;
                cmd[idx++] = NULL;
-               execv(cmd[0], cmd);
+               execvp(cmd[0], cmd);
                err(EXIT_FAILURE, _("failed to execute %s"), cmd[0]);
 
        default: /* parent */