summaryrefslogtreecommitdiffstats
path: root/sys-utils/swapon.c
diff options
context:
space:
mode:
authorMike Frysinger2015-04-12 11:06:52 +0200
committerKarel Zak2015-04-27 10:28:44 +0200
commitf1bc59963fb2cf755fa1373c4f86fe8a6bdc2bf8 (patch)
tree866ed6195e448d3167ff17fad440399b4dc359e8 /sys-utils/swapon.c
parentmkfs: drop hardcoded search path (diff)
downloadkernel-qcow2-util-linux-f1bc59963fb2cf755fa1373c4f86fe8a6bdc2bf8.tar.gz
kernel-qcow2-util-linux-f1bc59963fb2cf755fa1373c4f86fe8a6bdc2bf8.tar.xz
kernel-qcow2-util-linux-f1bc59963fb2cf755fa1373c4f86fe8a6bdc2bf8.zip
swapon: search for mkswap via PATH
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>
Diffstat (limited to 'sys-utils/swapon.c')
-rw-r--r--sys-utils/swapon.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 645a01d42..561b1a967 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -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 */