ubase

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

commit 0c37fe11e485aa89e2f4b51a72416700c5436f0b
parent 051ed9a79cbe9af13fc38f361126fa1da9038b13
Author: sin <sin@2f30.org>
Date:   Fri,  9 Aug 2013 15:42:49 +0100

Add swapoff(8)

No manpage yet.

Diffstat:
MMakefile | 3++-
Aswapoff.c | 37+++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)

diff --git 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 @@ -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; +}