Subject: re: PR#3615 status...
To: matthew green <mrg@eterna.com.au>
From: Matthew Orgass <darkstar@pgh.net>
List: tech-userlevel
Date: 04/22/1999 00:05:47
On Wed, 21 Apr 1999, matthew green wrote:

> it seems that (a) mount should be resolve the path and (b) umount should
> be able to unmount relative paths if they *are* mounted, perhaps via some
> switch to disable path resolution before calling unmount()... i think.

  Ok, this fixes mount_* and umount -R (minus a thinko in my last umount
-R patch). It resolves the path of both the device or file (when
applicable) and mount point.  While I've only tested umount, mount_msdos
and mount_ffs, I've double checked the patches to the others (which are
very simple), so there should not be any problems.

  Please pull this up to 1.4 also if possible (at least the umount -R
fix).

Matthew Orgass
darkstar@pgh.net

--- sbin/mount_ados/mount_ados.c.bak	Wed Apr 21 12:57:58 1999
+++ sbin/mount_ados/mount_ados.c	Wed Apr 21 16:05:11 1999
@@ -71,7 +71,7 @@
 	struct adosfs_args args;
 	struct stat sb;
 	int c, mntflags, set_gid, set_uid, set_mask;
-	char *dev, *dir, ndir[MAXPATHLEN+1];
+	char dev[MAXPATHLEN], dir[MAXPATHLEN];
 
 	mntflags = set_gid = set_uid = set_mask = 0;
 	(void)memset(&args, '\0', sizeof(args));
@@ -103,17 +103,10 @@
 	if (optind + 2 != argc)
 		usage();
 
-	dev = argv[optind];
-	dir = argv[optind + 1];
-	if (dir[0] != '/') {
-		warnx("\"%s\" is a relative path.", dir);
-		if (getcwd(ndir, sizeof(ndir)) == NULL)
-			err(1, "getcwd");
-		strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
-		strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
-		dir = ndir;
-		warnx("using \"%s\" instead.", dir);
-	}
+	if (realpath(argv[optind], dev) == NULL)
+		err(1, "%s", dev);
+	if (realpath(argv[optind + 1], dir) == NULL)
+		err(1, "%s", dir);
 
 	args.fspec = dev;
 	args.export.ex_root = -2;	/* unchecked anyway on DOS fs */
--- sbin/mount_ados/mount_ados.8.bak	Wed Apr 21 12:58:06 1999
+++ sbin/mount_ados/mount_ados.8	Wed Apr 21 13:02:06 1999
@@ -46,10 +46,9 @@
 The
 .Nm
 command attaches the AmigaDOS filesystem residing on
-the device
+the device at the absolute path of
 .Pa special
-to the global filesystem namespace at the location
-indicated by
+to the global filesystem namespace at the absolute path of
 .Pa node .
 This command is normally executed by
 .Xr mount 8
--- sbin/mount_cd9660/mount_cd9660.c.bak	Wed Apr 21 13:04:48 1999
+++ sbin/mount_cd9660/mount_cd9660.c	Wed Apr 21 16:13:10 1999
@@ -83,7 +83,7 @@
 {
 	struct iso_args args;
 	int ch, mntflags, opts;
-	char *dev, *dir;
+	char dev[MAXPATHLEN], dir[MAXPATHLEN];
 
 	mntflags = opts = 0;
 	while ((ch = getopt(argc, argv, "ego:r")) != -1)
@@ -110,8 +110,10 @@
 	if (argc != 2)
 		usage();
 
-	dev = argv[0];
-	dir = argv[1];
+	if (realpath(argv[0], dev) == NULL)
+		err(1, "%s", dev);
+	if (realpath(argv[1], dir) == NULL)
+		err(1, "%s", dir);
 
 #define DEFAULT_ROOTUID	-2
 	/*
--- sbin/mount_cd9660/mount_cd9660.8.bak	Wed Apr 21 13:04:53 1999
+++ sbin/mount_cd9660/mount_cd9660.8	Wed Apr 21 13:07:13 1999
@@ -51,8 +51,9 @@
 The
 .Nm
 command attaches the ISO-9660 filesystem residing on the device
+at the absolute path of
 .Pa special
-to the global filesystem namespace at the location indicated by
+to the global filesystem namespace at the absolute path of
 .Pa node .
 This command is normally executed by
 .Xr mount 8
--- sbin/mount_ext2fs/mount_ext2fs.c.bak	Wed Apr 21 14:29:36 1999
+++ sbin/mount_ext2fs/mount_ext2fs.c	Wed Apr 21 16:33:04 1999
@@ -83,7 +83,7 @@
 	extern int optreset;
 	struct ufs_args args;		/* XXX ffs_args */
 	int ch, mntflags;
-	char *fs_name;
+	char fs_name[MAXPATHLEN], dev_name[MAXPATHLEN];
 	const char *errcause;
 
 	mntflags = 0;
@@ -103,8 +103,11 @@
 	if (argc != 2)
 		ext2fs_usage();
 
-        args.fspec = argv[0];		/* The name of the device file. */
-	fs_name = argv[1];		/* The mount point. */
+	if (realpath(argv[0], dev_name) == NULL)
+		err(1, "%s", dev_name);
+	args.fspec = dev_name;
+	if (realpath(argv[1], fs_name) == NULL)
+		err(1, "%s", fs_name);
 
 #define DEFAULT_ROOTUID	-2
 	args.export.ex_root = DEFAULT_ROOTUID;
--- sbin/mount_ext2fs/mount_ext2fs.8.bak	Wed Apr 21 14:29:43 1999
+++ sbin/mount_ext2fs/mount_ext2fs.8	Wed Apr 21 14:39:46 1999
@@ -47,8 +47,9 @@
 The
 .Nm
 command attaches an EXT2FS file system
+on the device at the absolute path of
 .Ar special
-device on to the file system tree at the point
+to the file system tree at the absolute path of
 .Ar node .
 .Pp
 This command is normally executed by
--- sbin/mount_fdesc/mount_fdesc.c.bak	Wed Apr 21 14:45:44 1999
+++ sbin/mount_fdesc/mount_fdesc.c	Wed Apr 21 16:23:07 1999
@@ -76,6 +76,7 @@
 	char *argv[];
 {
 	int ch, mntflags;
+	char dir[MAXPATHLEN];
 
 	mntflags = 0;
 	while ((ch = getopt(argc, argv, "o:")) != -1)
@@ -93,7 +94,10 @@
 	if (argc != 2)
 		usage();
 
-	if (mount(MOUNT_FDESC, argv[1], mntflags, NULL))
+	if (realpath(argv[1], dir) == NULL)
+		err(1, "%s", dir);
+
+	if (mount(MOUNT_FDESC, dir, mntflags, NULL))
 		err(1, "%s", "");
 	exit(0);
 }
--- sbin/mount_fdesc/mount_fdesc.8.bak	Wed Apr 21 14:45:51 1999
+++ sbin/mount_fdesc/mount_fdesc.8	Wed Apr 21 15:00:41 1999
@@ -45,13 +45,14 @@
 .Sh SYNOPSIS
 .Nm ""
 .Op Fl o Ar options
-.Ar fdesc
+fdesc
 .Ar mount_point
 .Sh DESCRIPTION
 The
 .Nm
 command attaches an instance of the per-process file descriptor
-namespace to the global filesystem namespace.
+namespace to the global filesystem namespace at the absolute path of 
+.Ar mount_point .
 The conventional mount point is
 .Pa /dev
 and the filesystem should be union mounted in order to augment,
--- sbin/mount_ffs/mount_ffs.c.bak	Wed Apr 21 11:42:51 1999
+++ sbin/mount_ffs/mount_ffs.c	Wed Apr 21 16:34:57 1999
@@ -84,7 +84,7 @@
 	extern int optreset;
 	struct ufs_args args;
 	int ch, mntflags;
-	char *fs_name;
+	char fs_name[MAXPATHLEN], dev_name[MAXPATHLEN];
 	const char *errcause;
 
 	mntflags = 0;
@@ -104,8 +104,11 @@
 	if (argc != 2)
 		ffs_usage();
 
-        args.fspec = argv[0];		/* The name of the device file. */
-	fs_name = argv[1];		/* The mount point. */
+	if (realpath(argv[0], dev_name) == NULL)
+		err(1, "%s", dev_name);
+	args.fspec = dev_name;
+	if (realpath(argv[1], fs_name) == NULL)
+		err(1, "%s", fs_name);
 
 #define DEFAULT_ROOTUID	-2
 	args.export.ex_root = DEFAULT_ROOTUID;
--- sbin/mount_ffs/mount_ffs.8.bak	Wed Apr 21 12:10:20 1999
+++ sbin/mount_ffs/mount_ffs.8	Wed Apr 21 12:52:33 1999
@@ -48,8 +48,9 @@
 The
 .Nm
 command attaches the Berkeley Fast File System on the
+device at the absolute path of
 .Ar special
-device on to the file system tree at point
+to the file system tree at the absolute path of
 .Ar node .
 .Pp
 The
--- sbin/mount_filecore/mount_filecore.c.bak	Wed Apr 21 15:07:55 1999
+++ sbin/mount_filecore/mount_filecore.c	Wed Apr 21 16:36:52 1999
@@ -81,7 +81,7 @@
 {
 	struct filecore_args args;
 	int ch, mntflags, opts, useuid;
-	char *dev, *dir;
+	char dev[MAXPATHLEN], dir[MAXPATHLEN];
 
 	mntflags = opts = 0;
 	useuid = 1;
@@ -123,8 +123,10 @@
 	if (argc != 2)
 		usage();
 
-	dev = argv[0];
-	dir = argv[1];
+	if (realpath(argv[0], dev) == NULL)
+		err(1, "%s", dev);
+	if (realpath(argv[1], dir) == NULL)
+		err(1, "%s", dir);
 
 #define DEFAULT_ROOTUID	-2
 	/*
--- sbin/mount_filecore/mount_filecore.8.bak	Wed Apr 21 15:08:03 1999
+++ sbin/mount_filecore/mount_filecore.8	Wed Apr 21 15:13:43 1999
@@ -60,10 +60,9 @@
 The
 .Nm
 command attaches the FILECORE filesystem residing on
-the device
+the device at the absolute path of
 .Pa special
-to the global filesystem namespace at the location
-indicated by
+to the global filesystem namespace at the absolute path of
 .Pa node .
 This command is normally executed by
 .Xr mount 8
--- sbin/mount_kernfs/mount_kernfs.c.bak	Wed Apr 21 15:23:40 1999
+++ sbin/mount_kernfs/mount_kernfs.c	Wed Apr 21 16:39:19 1999
@@ -76,6 +76,7 @@
 	char *argv[];
 {
 	int ch, mntflags;
+	char dir[MAXPATHLEN];
 
 	mntflags = 0;
 	while ((ch = getopt(argc, argv, "o:")) != -1)
@@ -93,7 +94,10 @@
 	if (argc != 2)
 		usage();
 
-	if (mount(MOUNT_KERNFS, argv[1], mntflags, NULL))
+	if (realpath(argv[1], dir) == NULL)
+		err(1, "%s", dir);
+
+	if (mount(MOUNT_KERNFS, dir, mntflags, NULL))
 		err(1, "%s", "");
 	exit(0);
 }
--- sbin/mount_kernfs/mount_kernfs.8.bak	Wed Apr 21 15:23:47 1999
+++ sbin/mount_kernfs/mount_kernfs.8	Wed Apr 21 15:31:03 1999
@@ -46,13 +46,14 @@
 .Sh SYNOPSIS
 .Nm ""
 .Op Fl o Ar options
-.Ar /kern
+/kern
 .Ar mount_point
 .Sh DESCRIPTION
 The
 .Nm
 command attaches an instance of the kernel parameter
-namespace to the global filesystem namespace.
+namespace to the global filesystem namespace at the absolute path of
+.Ar mount_point .
 The conventional mount point is
 .Pa /kern .
 This command is normally executed by
--- sbin/mount_lfs/mount_lfs.c.bak	Wed Apr 21 15:35:17 1999
+++ sbin/mount_lfs/mount_lfs.c	Wed Apr 21 16:41:13 1999
@@ -80,7 +80,7 @@
 {
 	struct ufs_args args;
 	int ch, mntflags, noclean;
-	char *fs_name, *options;
+	char fs_name[MAXPATHLEN], dev_name[MAXPATHLEN], *options;
 
 	options = NULL;
 	mntflags = noclean = 0;
@@ -108,8 +108,11 @@
 	if (argc != 2)
 		usage();
 
-        args.fspec = argv[0];	/* the name of the device file */
-	fs_name = argv[1];	/* the mount point */
+	if (realpath(argv[0], dev_name) == NULL)
+		err(1, "%s", dev_name);
+	args.fspec = dev_name;
+	if (realpath(argv[1], fs_name) == NULL)
+		err(1, "%s", fs_name);
 
 #define DEFAULT_ROOTUID	-2
 	args.export.ex_root = DEFAULT_ROOTUID;
--- sbin/mount_lfs/mount_lfs.8.bak	Wed Apr 21 15:35:22 1999
+++ sbin/mount_lfs/mount_lfs.8	Wed Apr 21 15:40:15 1999
@@ -49,8 +49,9 @@
 The
 .Nm
 command attaches a log-structured file system
+on the device at the absolute path of
 .Ar special
-device on to the file system tree at the point
+to the file system tree at the absolute path of
 .Ar node .
 In addition, the
 .Xr lfs_cleanerd 8
--- sbin/mount_msdos/mount_msdos.c.bak	Sun Mar  1 07:18:03 1998
+++ sbin/mount_msdos/mount_msdos.c	Wed Apr 21 16:43:46 1999
@@ -71,7 +71,7 @@
 	struct msdosfs_args args;
 	struct stat sb;
 	int c, mntflags, set_gid, set_uid, set_mask;
-	char *dev, *dir, ndir[MAXPATHLEN+1];
+	char dev[MAXPATHLEN], dir[MAXPATHLEN];
 
 	mntflags = set_gid = set_uid = set_mask = 0;
 	(void)memset(&args, '\0', sizeof(args));
@@ -115,17 +115,10 @@
 	if (optind + 2 != argc)
 		usage();
 
-	dev = argv[optind];
-	dir = argv[optind + 1];
-	if (dir[0] != '/') {
-		warnx("\"%s\" is a relative path.", dir);
-		if (getcwd(ndir, sizeof(ndir)) == NULL)
-			err(1, "getcwd");
-		strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
-		strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
-		dir = ndir;
-		warnx("using \"%s\" instead.", dir);
-	}
+	if (realpath(argv[optind], dev) == NULL)
+		err(1, "%s", dev);
+	if (realpath(argv[optind + 1], dir) == NULL)
+		err(1, "%s", dir);
 
 	args.fspec = dev;
 	args.export.ex_root = -2;	/* unchecked anyway on DOS fs */
--- sbin/mount_msdos/mount_msdos.8.bak	Wed Apr 21 12:39:20 1999
+++ sbin/mount_msdos/mount_msdos.8	Wed Apr 21 12:47:55 1999
@@ -49,11 +49,10 @@
 .Sh DESCRIPTION
 The
 .Nm
-command attaches the MS-DOS filesystem residing on
-the device
+command attaches the MS-DOS filesystem residing on the device
+at the absolute path of
 .Pa special
-to the global filesystem namespace at the location
-indicated by
+to the global filesystem namespace at the absolute path of
 .Pa node .
 This command is normally executed by
 .Xr mount 8
--- sbin/mount_nfs/mount_nfs.c.bak	Thu May 14 07:10:15 1998
+++ sbin/mount_nfs/mount_nfs.c	Wed Apr 21 16:47:18 1999
@@ -430,7 +430,9 @@
 		usage();
 
 	spec = *argv++;
-	name = *argv;
+
+	if (realpath(*argv, name) == NULL)
+		err(1, "%s", name);
 
 	if (!getnfsargs(spec, nfsargsp))
 		exit(1);
--- sbin/mount_nfs/mount_nfs.8.bak	Wed Apr 21 15:45:27 1999
+++ sbin/mount_nfs/mount_nfs.8	Wed Apr 21 15:51:56 1999
@@ -88,8 +88,8 @@
 calls the
 .Xr mount 2
 system call to prepare and graft a remote nfs file system (rhost:path)
-on to the file system tree at the point
-.Ar node.
+on to the file system tree at the absolute path of
+.Ar node .
 This command is normally executed by
 .Xr mount 8 .
 It implements the mount protocol as described in RFC 1094, Appendix A and
--- sbin/mount_null/mount_null.c.bak	Wed Apr 21 15:55:26 1999
+++ sbin/mount_null/mount_null.c	Wed Apr 21 16:52:36 1999
@@ -78,7 +78,7 @@
 {
 	struct null_args args;
 	int ch, mntflags;
-	char target[MAXPATHLEN];
+	char target[MAXPATHLEN], mntpt[MAXPATHLEN];
 
 	mntflags = 0;
 	while ((ch = getopt(argc, argv, "o:")) != -1)
@@ -98,14 +98,16 @@
 
 	if (realpath(argv[0], target) == 0)
 		err(1, "%s", target);
+	if (realpath(argv[1], mntpt) == 0)
+		err(1, "%s", mntpt);
 
-	if (subdir(target, argv[1]) || subdir(argv[1], target))
-		errx(1, "%s (%s) and %s are not distinct paths",
-		    argv[0], target, argv[1]);
+	if (subdir(target, mntpt) || subdir(mntpt, target))
+		errx(1, "%s and %s are not distinct paths",
+		    target, mntpt);
 
 	args.target = target;
 
-	if (mount(MOUNT_NULL, argv[1], mntflags, &args))
+	if (mount(MOUNT_NULL, mntpt, mntflags, &args))
 		err(1, "%s", "");
 	exit(0);
 }
--- sbin/mount_null/mount_null.8.bak	Wed Apr 21 15:55:33 1999
+++ sbin/mount_null/mount_null.8	Wed Apr 21 16:57:19 1999
@@ -58,6 +58,12 @@
 This allows existing files and directories to be accessed
 using a different pathname.
 .Pp
+Both
+.Ar target 
+and
+.Ar mount-point 
+are converted to absolute paths.
+.Pp
 The primary differences between a virtual copy of the filesystem
 and a symbolic link are that
 .Xr getcwd 3
--- sbin/mount_portal/mount_portal.c.bak	Wed Apr 21 17:00:33 1999
+++ sbin/mount_portal/mount_portal.c	Wed Apr 21 17:06:49 1999
@@ -75,7 +75,7 @@
 	{ NULL }
 };
 
-static char *mountpt;		/* made available to signal handler */
+static char mountpt[MAXPATHLEN];	/* for signal handler */
 
 	int	main __P((int, char *[]));
 static	void	sigchld __P((int));
@@ -122,7 +122,7 @@
 {
 	struct portal_args args;
 	struct sockaddr_un un;
-	char *conf;
+	char conf[MAXPATHLEN];
 	int mntflags = 0;
 	char tag[32];
 
@@ -156,8 +156,10 @@
 	/*
 	 * Get config file and mount point
 	 */
-	conf = argv[optind];
-	mountpt = argv[optind+1];
+	if (realpath(argv[optind], conf) == NULL)
+		err(1, "%s", conf);
+	if (realpath(argv[optind+1], mountpt) == NULL)
+		err(1, "%s", mountpt);
 
 	/*
 	 * Construct the listening socket
--- sbin/mount_portal/mount_portal.8.bak	Wed Apr 21 17:00:39 1999
+++ sbin/mount_portal/mount_portal.8	Wed Apr 21 17:10:21 1999
@@ -45,13 +45,17 @@
 .Sh SYNOPSIS
 .Nm ""
 .Op Fl o Ar options
-.Ar /etc/portal.conf
+.Ar portal.conf
 .Ar mount_point
 .Sh DESCRIPTION
 The
 .Nm
 command attaches an instance of the portal daemon
-to the global filesystem namespace.
+to the global filesystem namespace at the absolute path of
+.Ar mount_point 
+according to the configuration file
+.Ar portal.conf
+(usually /etc/portal.conf).
 The conventional mount point is
 .Pa /p .
 This command is normally executed by
--- sbin/mount_procfs/mount_procfs.c.bak	Wed Apr 21 17:15:02 1999
+++ sbin/mount_procfs/mount_procfs.c	Wed Apr 21 17:17:03 1999
@@ -76,6 +76,7 @@
 	char *argv[];
 {
 	int ch, mntflags;
+	char dir[MAXPATHLEN];
 
 	mntflags = 0;
 	while ((ch = getopt(argc, argv, "o:")) != -1)
@@ -93,7 +94,10 @@
 	if (argc != 2)
 		usage();
 
-	if (mount(MOUNT_PROCFS, argv[1], mntflags, NULL))
+	if (realpath(argv[1], dir) == NULL)
+		err(1, "%s", dir);
+
+	if (mount(MOUNT_PROCFS, dir, mntflags, NULL))
 		err(1, "%s", "");
 	exit(0);
 }
--- sbin/mount_procfs/mount_procfs.8.bak	Wed Apr 21 17:15:07 1999
+++ sbin/mount_procfs/mount_procfs.8	Wed Apr 21 17:18:39 1999
@@ -47,13 +47,15 @@
 .Sh SYNOPSIS
 .Nm ""
 .Op Fl o Ar options
-.Pa /proc
+/proc
 .Pa mount_point
 .Sh DESCRIPTION
 The
 .Nm
 command attaches an instance of the process
-namespace to the global filesystem namespace.
+namespace to the global filesystem namespace 
+at the absolute path of
+.Pa mount_point .
 The conventional mount point is
 .Pa /proc .
 This command is normally executed by
--- sbin/mount_umap/mount_umap.c.bak	Wed Apr 21 17:22:03 1999
+++ sbin/mount_umap/mount_umap.c	Wed Apr 21 17:35:38 1999
@@ -103,7 +103,8 @@
 	u_long mapdata[MAPFILEENTRIES][2];
 	u_long gmapdata[GMAPFILEENTRIES][2];
 	int ch, count, gnentries, mntflags, nentries;
-	char *gmapfile, *mapfile, *source, *target, buf[20];
+	char *gmapfile, *mapfile, source[MAXPATHLEN], target[MAXPATHLEN],
+		buf[20];
 
 	mntflags = 0;
 	mapfile = gmapfile = NULL;
@@ -128,8 +129,10 @@
 	if (argc != 2 || mapfile == NULL || gmapfile == NULL)
 		usage();
 
-	source = argv[0];
-	target = argv[1];
+	if (realpath(argv[0], source) == NULL)
+		err(1, "%s", source);
+	if (realpath(argv[1], target) == NULL)
+		err(1, "%s", target);
 
 	/* Read in uid mapping data. */
 	if ((fp = fopen(mapfile, "r")) == NULL)
--- sbin/mount_umap/mount_umap.8.bak	Wed Apr 21 17:22:08 1999
+++ sbin/mount_umap/mount_umap.8	Wed Apr 21 17:36:51 1999
@@ -61,6 +61,12 @@
 it could be a file system on removable media brought from some
 foreign location that uses a different password file.
 .Pp
+Both
+.Ar target
+and
+.Ar mount-point
+are converted to absolute paths.
+.Pp
 The options are as follows:
 .Bl -tag -width indent
 .It Fl o
--- sbin/mount_union/mount_union.c.bak	Wed Apr 21 17:39:24 1999
+++ sbin/mount_union/mount_union.c	Wed Apr 21 17:42:20 1999
@@ -79,7 +79,7 @@
 {
 	struct union_args args;
 	int ch, mntflags;
-	char target[MAXPATHLEN];
+	char target[MAXPATHLEN], uniondir[MAXPATHLEN];
 
 	mntflags = 0;
 	args.mntflags = UNMNT_ABOVE;
@@ -109,10 +109,12 @@
 
 	if (realpath(argv[0], target) == 0)
 		err(1, "%s", target);
+	if (realpath(argv[1], uniondir) == 0)
+		err(1, "%s", uniondir);
 
-	if (subdir(target, argv[1]) || subdir(argv[1], target))
-		errx(1, "%s (%s) and %s are not distinct paths",
-		    argv[0], target, argv[1]);
+	if (subdir(target, uniondir) || subdir(uniondir, target))
+		errx(1, "%s and %s are not distinct paths",
+		    target, uniondir);
 
 	args.target = target;
 
--- sbin/mount_union/mount_union.8.bak	Wed Apr 21 17:39:29 1999
+++ sbin/mount_union/mount_union.8	Wed Apr 21 17:43:17 1999
@@ -67,6 +67,12 @@
 .Em lower
 layer.
 .Pp
+Both
+.Ar directory
+and
+.Ar uniondir
+are converted to absolute paths.
+.Pp
 The options are as follows:
 .Bl -tag -width indent
 .It Fl b
--- sbin/umount/umount.c.bak	Tue Apr 20 21:49:50 1999
+++ sbin/umount/umount.c	Wed Apr 21 17:46:39 1999
@@ -213,70 +213,68 @@
 	hp = NULL;
 	delimp = NULL;
 
-	if (raw) {
-		mntpt = name;
-	} else {
-
+	if (raw)
+		strncpy(rname, name, MAXPATHLEN)[MAXPATHLEN-1] = '\0';
+	else
 		if (realpath(name, rname) == NULL) {
 			warn("%s", rname);
 			return (1);
 		}
 
-		what = MNTANY;
-		mntpt = name = rname;
+	mntpt = name = rname;
+	what = MNTANY;
 
-		if (stat(name, &sb) == 0) {
-			if (S_ISBLK(sb.st_mode))
-				what = MNTON;
-			else if (S_ISDIR(sb.st_mode))
-				what = MNTFROM;
-		}
+	if (stat(name, &sb) == 0) {
+		if (S_ISBLK(sb.st_mode))
+			what = MNTON;
+		else if (S_ISDIR(sb.st_mode))
+			what = MNTFROM;
+	}
 
-		switch (what) {
-		case MNTON:
+	switch (what) {
+	case MNTON:
+		if ((mntpt = getmntname(name, MNTON, &type)) == NULL) {
+			warnx("%s: not currently mounted", name);
+			return (1);
+		}
+		break;
+	case MNTFROM:
+		if ((name = getmntname(mntpt, MNTFROM, &type)) == NULL) {
+			warnx("%s: not currently mounted", mntpt);
+			return (1);
+		}
+		break;
+	default:
+		if ((name = getmntname(mntpt, MNTFROM, &type)) == NULL) {
+			name = rname;
 			if ((mntpt = getmntname(name, MNTON, &type)) == NULL) {
 				warnx("%s: not currently mounted", name);
 				return (1);
 			}
-			break;
-		case MNTFROM:
-			if ((name = getmntname(mntpt, MNTFROM, &type)) == NULL) {
-				warnx("%s: not currently mounted", mntpt);
-				return (1);
-			}
-			break;
-		default:
-			if ((name = getmntname(mntpt, MNTFROM, &type)) == NULL) {
-				name = rname;
-				if ((mntpt = getmntname(name, MNTON, &type)) == NULL) {
-					warnx("%s: not currently mounted", name);
-					return (1);
-				}
-			}
 		}
+	}
 
-		if (checkvfsname(type, typelist))
-			return (1);
+	if (checkvfsname(type, typelist))
+		return (1);
 
-		hp = NULL;
-		if (!strncmp(type, MOUNT_NFS, MFSNAMELEN)) {
-			if ((delimp = strchr(name, '@')) != NULL) {
-				hostp = delimp + 1;
-				*delimp = '\0';
-				hp = gethostbyname(hostp);
-				*delimp = '@';
-			} else if ((delimp = strchr(name, ':')) != NULL) {
-				*delimp = '\0';
-				hostp = name;
-				hp = gethostbyname(hostp);
-				name = delimp + 1;
-				*delimp = ':';
-			}
+	hp = NULL;
+	if (!strncmp(type, MOUNT_NFS, MFSNAMELEN)) {
+		if ((delimp = strchr(name, '@')) != NULL) {
+			hostp = delimp + 1;
+			*delimp = '\0';
+			hp = gethostbyname(hostp);
+			*delimp = '@';
+		} else if ((delimp = strchr(name, ':')) != NULL) {
+			*delimp = '\0';
+			hostp = name;
+			hp = gethostbyname(hostp);
+			name = delimp + 1;
+			*delimp = ':';
 		}
-
-		if (!namematch(hp))
-			return (1);
 	}
+
+	if (!namematch(hp))
+		return (1);
 
 	if (verbose)
 		(void)printf("%s: unmount from %s\n", name, mntpt);