Fixed segfault with 'cut -f 1 -d:' and added 'cut -s' suport.
[oweals/busybox.git] / swaponoff.c
index aa961dac935aa820c32924e74ca82a2fdfeb82c1..223436c29a14ad9b36a2b918c73504519d69d6ce 100644 (file)
 #include "internal.h"
 #include <stdio.h>
 #include <sys/mount.h>
-#include <sys/swap.h>
 #include <mntent.h>
 #include <dirent.h>
-#include <fstab.h>
 #include <errno.h>
+#include <linux/unistd.h>
+
+_syscall2(int, swapon, const char *, path, int, flags);
+_syscall1(int, swapoff, const char *, path);
 
 
 static int whichApp;
 static const char *appName;
 
 static const char swapoff_usage[] =
-       "swapoff [OPTION] [device]\n\n"
-       "Stop swapping virtual memory pages on the given device.\n\n"
+       "swapoff [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nStop swapping virtual memory pages on the given device.\n\n"
        "Options:\n"
-       "\t-a\tStop swapping on all swap devices\n";
+       "\t-a\tStop swapping on all swap devices\n"
+#endif
+       ;
 
 static const char swapon_usage[] =
-       "swapon [OPTION] [device]\n\n"
-       "Start swapping virtual memory pages on the given device.\n\n"
+       "swapon [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nStart swapping virtual memory pages on the given device.\n\n"
        "Options:\n"
-       "\t-a\tStart swapping on all swap devices\n";
+       "\t-a\tStart swapping on all swap devices\n"
+#endif
+       ;
 
 
 #define SWAPON_APP   1
@@ -77,7 +85,7 @@ static void do_em_all()
                exit(FALSE);
        }
        while ((m = getmntent(f)) != NULL) {
-               if (!strstr(m->mnt_type, MNTTYPE_SWAP)) {
+               if (strcmp(m->mnt_type, MNTTYPE_SWAP)==0) {
                        swap_enable_disable(m->mnt_fsname);
                }
        }