- if (strcmp(argv[1], "-a") == 0){
- 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_file, "/") == 0)
- continue;
- fprintf(stderr, "Unmounting special file %s\n",
- fs.fs_spec);
- fflush(stderr);
- if (umountfs(fs.fs_spec))
- continue;
- }
- fclose(fs_file);
- } else {
- if (umountfs(argv[1]))
- exit(1);
+ exit(errs);
+}
+
+umountall()
+{
+ struct fstab fs, *fsp;
+
+ if ((fsp = getfsent()) == 0)
+ return;
+ fs = *fsp; /* save info locally; it is static from getfsent() */
+ umountall();
+ if (strcmp(fs.fs_file, "/") == 0)
+ return;
+ if (strcmp(fs.fs_type, FSTAB_RW) && strcmp(fs.fs_type, FSTAB_RO))
+ return;
+ if (umountfs(fs.fs_spec) < 0) {
+ perror(fs.fs_spec);
+ return;