bin/113838: [patch]: This patch to mount(8) adds support for relative pathnames

Ighighi ighighi at gmail.com
Mon Jun 18 20:30:04 UTC 2007


>Number:         113838
>Category:       bin
>Synopsis:       [patch]: This patch to mount(8) adds support for relative pathnames
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 18 20:30:04 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Ighighi
>Release:        6.2-STABLE
>Organization:
>Environment:
FreeBSD orion 6.2-STABLE FreeBSD 6.2-STABLE #2: Mon Jun 18 00:28:11 VET 2007     root at orion:/usr/obj/usr/src/sys/CUSTOM  i386
>Description:
The attached patch adds support for relative pathnames to mount(8).
A feature present in the mount_xxx(8) tools as well as umount(8),
it preserves current functionality by retrying with a realpath(3)
version of argv[1] on errors.  A trivial patch anyway.

Tested against the recent 6-STABLE version and verified it patches ok
on -CURRENT.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- src/sbin/mount/mount.c.orig	Wed Feb  7 00:01:41 2007
+++ src/sbin/mount/mount.c	Mon Jun 18 16:08:01 2007
@@ -155,6 +155,7 @@
 	pid_t pid;
 	int all, ch, i, init_flags, late, mntsize, rval, have_fstab, ro;
 	char *cp, *ep, *options;
+	char *arg1, tryargv[PATH_MAX];
 
 	all = init_flags = late = 0;
 	ro = 0;
@@ -267,12 +268,17 @@
 		if (vfslist != NULL)
 			usage();
 
-		rmslashes(*argv, *argv);
+		arg1 = *argv;
+		rmslashes(arg1, arg1);
 		if (init_flags & MNT_UPDATE) {
 			mntfromname = NULL;
 			have_fstab = 0;
-			if ((mntbuf = getmntpt(*argv)) == NULL)
-				errx(1, "not currently mounted %s", *argv);
+			if ((mntbuf = getmntpt(arg1)) == NULL) {
+				if (realpath(arg1, tryargv) == NULL ||
+				    (mntbuf = getmntpt(tryargv)) == NULL)
+					errx(1, "not currently mounted %s", arg1);
+				arg1 = tryargv;
+			}
 			/*
 			 * Only get the mntflags from fstab if both mntpoint
 			 * and mntspec are identical. Also handle the special
@@ -306,13 +312,18 @@
 			    mntbuf->f_mntonname, init_flags, options, 0);
 			break;
 		}
-		if ((fs = getfsfile(*argv)) == NULL &&
-		    (fs = getfsspec(*argv)) == NULL)
-			errx(1, "%s: unknown special file or file system",
-			    *argv);
+tryagain:
+		if ((fs = getfsfile(arg1)) == NULL &&
+		    (fs = getfsspec(arg1)) == NULL) {
+			if (arg1 == tryargv || realpath(arg1, tryargv) == NULL)
+				errx(1, "%s: unknown special file or file system",
+				    arg1);
+			arg1 = tryargv;
+			goto tryagain;
+			
+		}
 		if (BADTYPE(fs->fs_type))
-			errx(1, "%s has unknown file system type",
-			    *argv);
+			errx(1, "%s has unknown file system type", arg1);
 		rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
 		    init_flags, options, fs->fs_mntops);
 		break;


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list