create a document for mdev so people dont have to rtfs
[oweals/busybox.git] / util-linux / swaponoff.c
index ce55a132a5954ecb830b1df99118884deb071631..e1de4eb0ce9cbd8689ed0df3cfdc7d6b685bfd26 100644 (file)
@@ -4,34 +4,27 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  *
- * Licensed under the GPL v2, see the file LICENSE in this tarball.
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 
-#include <stdio.h>
+#include "busybox.h"
 #include <mntent.h>
-#include <dirent.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/mount.h>
 #include <sys/swap.h>
 
-#include "busybox.h"
 
-static int swap_enable_disable(const char *device)
+static int swap_enable_disable(char *device)
 {
        int status;
        struct stat st;
 
-       if (stat(device, &st) < 0)
-               bb_perror_msg_and_die("cannot stat %s", device);
+       xstat(device, &st);
 
        /* test for holes */
        if (S_ISREG(st.st_mode))
                if (st.st_blocks * 512 < st.st_size)
                        bb_error_msg_and_die("swap file has holes");
 
-       if (bb_applet_name[5] == 'n')
+       if (applet_name[5] == 'n')
                status = swapon(device, 0);
        else
                status = swapoff(device);
@@ -66,6 +59,7 @@ static int do_em_all(void)
 
 #define DO_ALL    0x01
 
+int swap_on_off_main(int argc, char **argv);
 int swap_on_off_main(int argc, char **argv)
 {
        int ret;
@@ -73,7 +67,7 @@ int swap_on_off_main(int argc, char **argv)
        if (argc == 1)
                bb_show_usage();
 
-       ret = bb_getopt_ulflags(argc, argv, "a");
+       ret = getopt32(argc, argv, "a");
        if (ret & DO_ALL)
                return do_em_all();