+ exit(errs);
+}
+
+usage()
+{
+ fprintf(stderr,
+ "%s\n%s\n",
+ "Usage: umount [-fv] special | node",
+#ifndef NFS
+ " or umount -a[fv] [-t fstypelist]"
+#else
+ " or umount -a[fv] [-h host] [-t fstypelist]"
+#endif
+ );
+ exit(1);
+}
+
+umountall(typelist)
+ char **typelist;
+{
+ register struct fstab *fs;
+ struct fstab *allocfsent();
+
+ if ((fs = getfsent()) == (struct fstab *)0)
+ return;
+ fs = allocfsent(fs);
+ umountall(typelist);
+ if (strcmp(fs->fs_file, "/") == 0) {
+ freefsent(fs);
+ return;
+ }
+ if (strcmp(fs->fs_type, FSTAB_RW) &&
+ strcmp(fs->fs_type, FSTAB_RO) &&
+ strcmp(fs->fs_type, FSTAB_RQ)) {
+ freefsent(fs);
+ return;
+ }
+ (void) umountfs(fs->fs_file, typelist);
+ freefsent(fs);
+}
+
+struct fstab *
+allocfsent(fs)
+ register struct fstab *fs;
+{
+ register struct fstab *new;
+ register char *cp;
+
+ new = (struct fstab *)malloc((unsigned)sizeof (*fs));
+ cp = (char *)malloc((unsigned)strlen(fs->fs_file) + 1);
+ strcpy(cp, fs->fs_file);
+ new->fs_file = cp;
+ cp = (char *)malloc((unsigned)strlen(fs->fs_type) + 1);
+ strcpy(cp, fs->fs_type);
+ new->fs_type = cp;
+ cp = (char *)malloc((unsigned)strlen(fs->fs_spec) + 1);
+ strcpy(cp, fs->fs_spec);
+ new->fs_spec = cp;
+ new->fs_passno = fs->fs_passno;
+ new->fs_freq = fs->fs_freq;
+ return (new);
+}
+
+freefsent(fs)
+ register struct fstab *fs;
+{
+
+ if (fs->fs_file)
+ free(fs->fs_file);
+ if (fs->fs_spec)
+ free(fs->fs_spec);
+ if (fs->fs_type)
+ free(fs->fs_type);
+ free((char *)fs);
+}
+
+umountfs(name, typelist)
+ char *name;
+ int *typelist;
+{
+ char *mntpt;
+ struct stat stbuf;
+ int type;
+#ifdef NFS
+ register CLIENT *clp;
+ struct hostent *hp = 0;
+ struct sockaddr_in saddr;
+ struct timeval pertry, try;
+ enum clnt_stat clnt_stat;
+ int so = RPC_ANYSOCK;
+ char *hostp, *delimp;
+#endif /* NFS */
+
+ if (stat(name, &stbuf) < 0) {
+ if (getmntname(name, MNTFROM, &type) != 0)
+ mntpt = name;
+ else if ((mntpt = getmntname(name, MNTON, &type)) == 0) {
+ fprintf(stderr, "%s: not currently mounted\n", name);
+ return (0);