From nobody@FreeBSD.org  Mon Jun 18 20:27:03 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id A8B3516A400
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2007 20:27:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 80CDF13C48C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2007 20:27:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l5IKR3kW046888
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2007 20:27:03 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l5IKR3ta046887;
	Mon, 18 Jun 2007 20:27:03 GMT
	(envelope-from nobody)
Message-Id: <200706182027.l5IKR3ta046887@www.freebsd.org>
Date: Mon, 18 Jun 2007 20:27:03 GMT
From: Ighighi <ighighi@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch]: This patch to mount(8) adds support for relative pathnames
X-Send-Pr-Version: www-3.0

>Number:         113838
>Category:       bin
>Synopsis:       [patch] [request] mount(8): add support for relative pathnames
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-fs
>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:  Sun Mar 09 13:00:46 UTC 2008
>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@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:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Sun Mar 9 13:00:37 UTC 2008 
Responsible-Changed-Why:  
Over to maintainers. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=113838 
>Unformatted:
