Thu Apr 23 04:21:13 2020 UTC ()
make umount NAME= work


(christos)
diff -r1.19 -r1.20 src/sbin/umount/Makefile
diff -r1.52 -r1.53 src/sbin/umount/umount.c

cvs diff -r1.19 -r1.20 src/sbin/umount/Makefile (expand / switch to context diff)
--- src/sbin/umount/Makefile 2019/10/13 07:28:13 1.19
+++ src/sbin/umount/Makefile 2020/04/23 04:21:13 1.20
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.19 2019/10/13 07:28:13 mrg Exp $
+#	$NetBSD: Makefile,v 1.20 2020/04/23 04:21:13 christos Exp $
 #	@(#)Makefile	8.4 (Berkeley) 6/22/95
 
 .include <bsd.own.mk>
@@ -15,6 +15,8 @@
 .PATH:	${MOUNT}
 SRCS+=	vfslist.c
 .endif
+LDADD+=-lutil
+DPADD+=${LIBUTIL}
 
 COPTS.umount.c+=	${GCC_NO_CAST_FUNCTION_TYPE}
 

cvs diff -r1.52 -r1.53 src/sbin/umount/umount.c (expand / switch to context diff)
--- src/sbin/umount/umount.c 2016/06/26 04:01:30 1.52
+++ src/sbin/umount/umount.c 2020/04/23 04:21:13 1.53
@@ -1,4 +1,4 @@
-/*	$NetBSD: umount.c,v 1.52 2016/06/26 04:01:30 dholland Exp $	*/
+/*	$NetBSD: umount.c,v 1.53 2020/04/23 04:21:13 christos Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1989, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)umount.c	8.8 (Berkeley) 5/8/95";
 #else
-__RCSID("$NetBSD: umount.c,v 1.52 2016/06/26 04:01:30 dholland Exp $");
+__RCSID("$NetBSD: umount.c,v 1.53 2020/04/23 04:21:13 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -65,6 +65,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <util.h>
 
 typedef enum { MNTANY, MNTON, MNTFROM } mntwhat;
 
@@ -90,6 +91,7 @@
 main(int argc, char *argv[])
 {
 	int ch, errs, all = 0, raw = 0;
+	char mntfromname[MAXPATHLEN];
 #ifndef SMALL
 	int mnts;
 	struct statvfs *mntbuf;
@@ -168,9 +170,13 @@
 		}
 	} else 
 #endif /* !SMALL */
-		for (errs = 0; *argv != NULL; ++argv)
-			if (umountfs(*argv, typelist, raw) != 0)
+		for (errs = 0; *argv != NULL; ++argv) {
+			if (getfsspecname(mntfromname, sizeof(mntfromname),
+			    *argv) == NULL)
+				err(EXIT_FAILURE, "%s", mntfromname);
+			if (umountfs(mntfromname, typelist, raw) != 0)
 				errs = 1;
+		}
 	return errs;
 }
 
@@ -339,6 +345,7 @@
 {
 	static struct statvfs *mntbuf;
 	static int mntsize;
+	static char mntfromname[MAXPATHLEN];
 	int i;
 
 	if (mntbuf == NULL &&
@@ -355,7 +362,10 @@
 		if ((what == MNTFROM) && !strcmp(mntbuf[i].f_mntonname, name)) {
 			if (type)
 				*type = mntbuf[i].f_fstypename;
-			return (mntbuf[i].f_mntfromname);
+			if (getfsspecname(mntfromname, sizeof(mntfromname),
+			    mntbuf[i].f_mntfromname) == NULL)
+				err(EXIT_FAILURE, "%s", mntfromname);
+			return mntfromname;
 		}
 	}
 	return (NULL);