From 0c37fe11e485aa89e2f4b51a72416700c5436f0b Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 9 Aug 2013 15:42:49 +0100 Subject: [PATCH] Add swapoff(8) No manpage yet. --- Makefile | 3 ++- swapoff.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 swapoff.c diff --git a/Makefile b/Makefile index 46d28d3..cf60823 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,8 @@ SRC += \ lsmod.c \ mkswap.c \ reboot.c \ - rmmod.c + rmmod.c \ + swapoff.c endif OBJ = $(SRC:.c=.o) $(LIB) diff --git a/swapoff.c b/swapoff.c new file mode 100644 index 0000000..96864c9 --- /dev/null +++ b/swapoff.c @@ -0,0 +1,37 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include +#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; +}