+ if (strcmp(argv[1], "-a") == 0){
+ if (setfsent() == 0)
+ perror(FSTAB), exit(1);
+ umountall();
+ endfsent();
+ } else {
+ int back;
+ if (back = umountfs(argv[1])){
+ if (back < 0)
+ perror("umount");
+ exit(1);
+ }
+ }
+ exit(0);
+}
+/*
+ * It is important to unmount the files in
+ * reverse! order from the order they were mounted,
+ * so that file systems mounted as children to other
+ * file systems get removed in the right order.
+ */
+umountall()
+{
+ struct fstab fs;
+ struct fstab *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)
+ fprintf(stdout, "Unmount of special file %s FAILED\n", fs.fs_spec);
+ else
+ fprintf(stdout, "Unmounted special file %s\n", fs.fs_spec);
+ fflush(stdout);
+}
+
+int umountfs(name)
+ char *name;
+{
+ register char *p1, *p2;
+ register struct mtab *mp;
+ int mf;
+
+ if (umount(name) < 0) {
+ return(-1);