swapon, swapoff: show usage with -a device
... and small cleanup.
This commit is contained in:
parent
7e394bd70f
commit
faa6fe28e2
|
@ -11,7 +11,7 @@
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-a] device\n", argv0);
|
eprintf("usage: %s -a | device\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -20,6 +20,8 @@ main(int argc, char *argv[])
|
||||||
int i;
|
int i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int all = 0;
|
int all = 0;
|
||||||
|
struct mntent *me;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -29,13 +31,10 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
if (!all && argc < 1)
|
if ((!all && argc < 1) || (all && argc > 0))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (all) {
|
if (all) {
|
||||||
struct mntent *me = NULL;
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
fp = setmntent("/etc/fstab", "r");
|
fp = setmntent("/etc/fstab", "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
eprintf("setmntent %s:", "/etc/fstab");
|
eprintf("setmntent %s:", "/etc/fstab");
|
||||||
|
|
9
swapon.c
9
swapon.c
|
@ -11,7 +11,7 @@
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-dp] [-a] device\n", argv0);
|
eprintf("usage: %s [-dp] -a | device\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -21,6 +21,8 @@ main(int argc, char *argv[])
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
int all = 0;
|
int all = 0;
|
||||||
|
struct mntent *me;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -36,13 +38,10 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
if (!all && argc < 1)
|
if ((!all && argc < 1) || (all && argc > 0))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (all) {
|
if (all) {
|
||||||
struct mntent *me = NULL;
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
fp = setmntent("/etc/fstab", "r");
|
fp = setmntent("/etc/fstab", "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
eprintf("setmntent %s:", "/etc/fstab");
|
eprintf("setmntent %s:", "/etc/fstab");
|
||||||
|
|
Loading…
Reference in New Issue