Fixes so "make allnoconfig" works again.
[oweals/busybox.git] / util-linux / swaponoff.c
index 918a5bc0e6ce32682c765e021290ee0521edbc12..7c7031bcee79424fbac0edf0be42d9f8cc21ef9e 100644 (file)
@@ -2,8 +2,7 @@
 /*
  * Mini swapon/swapoff implementation for busybox
  *
- * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
- * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include <string.h>
 #include <stdlib.h>
 #include <sys/mount.h>
-
-#if __GNU_LIBRARY__ < 5
-/* libc5 doesn't have sys/swap.h, define these here. */ 
-extern int swapon (__const char *__path, int __flags);
-extern int swapoff (__const char *__path);
-#else
 #include <sys/swap.h>
-#endif
 
 #include "busybox.h"
 
@@ -51,13 +43,13 @@ static int swap_enable_disable(const char *device)
        struct stat st;
 
        if (stat(device, &st) < 0) {
-               perror_msg_and_die("cannot stat %s");
+               bb_perror_msg_and_die("cannot stat %s", device);
        }
 
        /* test for holes */
        if (S_ISREG(st.st_mode)) {
                if (st.st_blocks * 512 < st.st_size) {
-                       error_msg_and_die("swap file has holes");
+                       bb_error_msg_and_die("swap file has holes");
                }
        }
 
@@ -67,7 +59,7 @@ static int swap_enable_disable(const char *device)
                status = swapoff(device);
 
        if (status != 0) {
-               perror_msg("%s", device);
+               bb_perror_msg("%s", device);
                return EXIT_FAILURE;
        }
        return EXIT_SUCCESS;
@@ -80,7 +72,7 @@ static int do_em_all(void)
        int err = 0;
 
        if (f == NULL)
-               perror_msg_and_die("/etc/fstab");
+               bb_perror_msg_and_die("/etc/fstab");
        while ((m = getmntent(f)) != NULL) {
                if (strcmp(m->mnt_type, MNTTYPE_SWAP)==0) {
                        if(swap_enable_disable(m->mnt_fsname) == EXIT_FAILURE)
@@ -94,7 +86,7 @@ static int do_em_all(void)
 
 extern int swap_on_off_main(int argc, char **argv)
 {
-       if (applet_name[5] == 'f') { /* "swapoff" */
+       if (bb_applet_name[5] == 'f') { /* "swapoff" */
                whichApp = SWAPOFF_APP;
        }
 
@@ -113,7 +105,7 @@ extern int swap_on_off_main(int argc, char **argv)
                                        struct stat statBuf;
 
                                        if (stat("/etc/fstab", &statBuf) < 0)
-                                               error_msg_and_die("/etc/fstab file missing");
+                                               bb_error_msg_and_die("/etc/fstab file missing");
                                }
                                return do_em_all();
                                break;
@@ -124,5 +116,5 @@ extern int swap_on_off_main(int argc, char **argv)
        return swap_enable_disable(*argv);
 
   usage_and_exit:
-       show_usage();
+       bb_show_usage();
 }