swapon: more robust progname probing
Currently, the 'swapoff' is the default behavior. It means that if you have a libtool wrapper script in your build directory the executed binary name is 'lt-swapon' and then "swapon -a" is interpreted as "swapoff -a". Any random argv[0] should not be interpreted as "swapoff". Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
d08cd85fad
commit
01373d74ef
|
@ -791,6 +791,9 @@ main(int argc, char *argv[]) {
|
|||
|
||||
if (streq(progname, "swapon"))
|
||||
return main_swapon(argc, argv);
|
||||
else
|
||||
else if (streq(progname, "swapoff"))
|
||||
return main_swapoff(argc, argv);
|
||||
|
||||
errx(EXIT_FAILURE, _("'%s' is unsupported program name "
|
||||
"(must be 'swapon' or 'swapoff')."), progname);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue