adding calls to fstab routines
authorBill Joy <bill@ucbvax.Berkeley.EDU>
Tue, 14 Oct 1980 09:16:32 +0000 (01:16 -0800)
committerBill Joy <bill@ucbvax.Berkeley.EDU>
Tue, 14 Oct 1980 09:16:32 +0000 (01:16 -0800)
SCCS-vsn: sbin/umount/umount.c 4.2
SCCS-vsn: bin/df/df.c 4.2
SCCS-vsn: sbin/swapon/swapon.c 4.2

usr/src/bin/df/df.c
usr/src/sbin/swapon/swapon.c
usr/src/sbin/umount/umount.c

index 075beb1..e0172b3 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)df.c        4.1 (Berkeley) %G%";
+static char *sccsid = "@(#)df.c        4.2 (Berkeley) %G%";
 #include <stdio.h>
 #include <fstab.h>
 #include <sys/param.h>
 #include <stdio.h>
 #include <fstab.h>
 #include <sys/param.h>
@@ -68,6 +68,8 @@ char **argv;
                        perror(FSTAB), exit(1);
                while (!feof(f)){
                        fscanf(f, FSTABFMT, FSTABARG(&fs));
                        perror(FSTAB), exit(1);
                while (!feof(f)){
                        fscanf(f, FSTABFMT, FSTABARG(&fs));
+                       if (strcmp(fs.fs_type, "rw") && strcmp(fs.fs_type, "ro"))
+                               continue;
                        if (root[0] == 0)
                                strcpy(root, fs.fs_spec);
                        dfree(fs.fs_spec);
                        if (root[0] == 0)
                                strcpy(root, fs.fs_spec);
                        dfree(fs.fs_spec);
index 2587d39..ae5e1a4 100644 (file)
@@ -1,5 +1,6 @@
-static char *sccsid = "@(#)swapon.c    4.1 (Berkeley) %G%";
+static char *sccsid = "@(#)swapon.c    4.2 (Berkeley) %G%";
 #include <stdio.h>
 #include <stdio.h>
+#include <fstab.h>
 
 #define        VSWAPON 85
 
 
 #define        VSWAPON 85
 
@@ -14,6 +15,27 @@ 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")) {
+               FILE    *fs_file;
+               struct  fstab   fs;
+               if ((fs_file = fopen(FSTAB, "r")) == NULL){
+                       perror(FSTAB);
+                       exit(1);
+               }
+               while (!feof(fs_file)){
+                       fscanf(fs_file, FSTABFMT, FSTABARG(&fs));
+                       if (strcmp(fs.fs_type, "sw"))
+                               continue;
+                       fprintf(stderr, "Adding %s as swap device\n",
+                           fs.fs_spec);
+                       if (syscall(VSWAPON, fs.fs_spec) == -1) {
+                               perror(fs.fs_spec);
+                               stat = 1;
+                       }
+               }
+               fclose(fs_file);
+               exit(stat);
+       }
        do {
                if (syscall(VSWAPON, *argv++) == -1) {
                        stat = 1;
        do {
                if (syscall(VSWAPON, *argv++) == -1) {
                        stat = 1;
index d6e68b2..1496bda 100644 (file)
@@ -1,12 +1,8 @@
-static char *sccsid = "@(#)umount.c    4.1 (Berkeley) %G%";
+static char *sccsid = "@(#)umount.c    4.2 (Berkeley) %G%";
 #include <stdio.h>
 #include <fstab.h>
 /*
 #include <stdio.h>
 #include <fstab.h>
 /*
- *     umount name
- *
- *     umount -a
- *             This tries to unmount all of the block special file names
- *             as given in /etc/fstab.
+ * umount
  */
 
 #define        NMOUNT  16
  */
 
 #define        NMOUNT  16
@@ -34,7 +30,7 @@ char **argv;
        if (strcmp(argv[1], "-a") == 0){
                FILE    *fs_file;
                struct  fstab   fs;
        if (strcmp(argv[1], "-a") == 0){
                FILE    *fs_file;
                struct  fstab   fs;
-               if ( (fs_file = fopen(FSTAB, "r")) == NULL){
+               if ((fs_file = fopen(FSTAB, "r")) == NULL){
                        perror(FSTAB);
                        exit(1);
                }
                        perror(FSTAB);
                        exit(1);
                }
@@ -42,6 +38,9 @@ char **argv;
                        fscanf(fs_file, FSTABFMT, FSTABARG(&fs));
                        if (strcmp(fs.fs_file, "/") == 0)
                                continue;
                        fscanf(fs_file, FSTABFMT, FSTABARG(&fs));
                        if (strcmp(fs.fs_file, "/") == 0)
                                continue;
+                       if (strcmp(fs.fs_type, "rw") &&
+                           strcmp(fs.fs_type, "ro"))
+                               continue;
                        fprintf(stderr, "Unmounting special file %s\n",
                                fs.fs_spec);
                        fflush(stderr);
                        fprintf(stderr, "Unmounting special file %s\n",
                                fs.fs_spec);
                        fflush(stderr);