ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 7f57d62f440f1b3d342ac571f1fac4e574ca8312
parent 062c7fcbb9719090a520eb33022d672bb4834297
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri Feb  6 15:20:41 +0100

swapon, swapoff: show usage with -a device

... and small cleanup.

Diffstat:
swapoff.c | 9++++-----
swapon.c | 9++++-----
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/swapoff.c b/swapoff.c @@ -11,7 +11,7 @@ static void usage(void) { - eprintf("usage: %s [-a] device\n", argv0); + eprintf("usage: %s -a | device\n", argv0); } int @@ -20,6 +20,8 @@ main(int argc, char *argv[]) int i; int ret = 0; int all = 0; + struct mntent *me; + FILE *fp; ARGBEGIN { case 'a': @@ -29,13 +31,10 @@ main(int argc, char *argv[]) usage(); } ARGEND; - if (!all && argc < 1) + if ((!all && argc < 1) || (all && argc > 0)) usage(); if (all) { - struct mntent *me = NULL; - FILE *fp; - fp = setmntent("/etc/fstab", "r"); if (!fp) eprintf("setmntent %s:", "/etc/fstab"); diff --git a/swapon.c b/swapon.c @@ -11,7 +11,7 @@ static void usage(void) { - eprintf("usage: %s [-dp] [-a] device\n", argv0); + eprintf("usage: %s [-dp] -a | device\n", argv0); } int @@ -21,6 +21,8 @@ main(int argc, char *argv[]) int ret = 0; int flags = 0; int all = 0; + struct mntent *me; + FILE *fp; ARGBEGIN { case 'a': @@ -36,13 +38,10 @@ main(int argc, char *argv[]) usage(); } ARGEND; - if (!all && argc < 1) + if ((!all && argc < 1) || (all && argc > 0)) usage(); if (all) { - struct mntent *me = NULL; - FILE *fp; - fp = setmntent("/etc/fstab", "r"); if (!fp) eprintf("setmntent %s:", "/etc/fstab");