print on standard output
[unix-history] / usr / src / sbin / swapon / swapon.c
index 2587d39..74e64ad 100644 (file)
@@ -1,5 +1,6 @@
-static char *sccsid = "@(#)swapon.c    4.1 (Berkeley) %G%";
+static char *sccsid = "@(#)swapon.c    4.4 (Berkeley) %G%";
 #include <stdio.h>
 #include <stdio.h>
+#include <fstab.h>
 
 #define        VSWAPON 85
 
 
 #define        VSWAPON 85
 
@@ -14,6 +15,26 @@ main(argc, argv)
                fprintf(stderr, "usage: swapon name...\n");
                exit(1);
        }
                fprintf(stderr, "usage: swapon name...\n");
                exit(1);
        }
+       if (argc == 1 && !strcmp(*argv, "-a")) {
+               struct  fstab   *fsp;
+               if (setfsent() == 0)
+                       perror(FSTAB), exit(1);
+               while ( (fsp = getfsent()) != 0){
+                       if (strcmp(fsp->fs_type, FSTAB_SW) != 0)
+                               continue;
+                       printf("Adding %s as swap device\n",
+                           fsp->fs_spec);
+                       if (syscall(VSWAPON, fsp->fs_spec) == -1) {
+                               extern errno;
+                               extern char *sys_errlist[];
+                               printf("%s: %s\n",
+                                   sys_errlist[errno]);
+                               stat = 1;
+                       }
+               }
+               endfsent();
+               exit(stat);
+       }
        do {
                if (syscall(VSWAPON, *argv++) == -1) {
                        stat = 1;
        do {
                if (syscall(VSWAPON, *argv++) == -1) {
                        stat = 1;