Add swapoff(8)
No manpage yet.
This commit is contained in:
parent
051ed9a79c
commit
0c37fe11e4
3
Makefile
3
Makefile
@ -23,7 +23,8 @@ SRC += \
|
||||
lsmod.c \
|
||||
mkswap.c \
|
||||
reboot.c \
|
||||
rmmod.c
|
||||
rmmod.c \
|
||||
swapoff.c
|
||||
endif
|
||||
|
||||
OBJ = $(SRC:.c=.o) $(LIB)
|
||||
|
37
swapoff.c
Normal file
37
swapoff.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <sys/swap.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "util.h"
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
eprintf("usage: %s swapfile\n", argv0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
ARGBEGIN {
|
||||
default:
|
||||
usage();
|
||||
} ARGEND;
|
||||
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
ret = swapoff(argv[i]);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "swapoff %s: %s\n",
|
||||
argv[i], strerror(errno));
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue
Block a user