From owner-freebsd-bugs@FreeBSD.ORG Mon Jun 18 20:30:04 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D29E416A400 for ; Mon, 18 Jun 2007 20:30:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id B00A413C4AE for ; Mon, 18 Jun 2007 20:30:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l5IKU49Y064541 for ; Mon, 18 Jun 2007 20:30:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l5IKU4dp064540; Mon, 18 Jun 2007 20:30:04 GMT (envelope-from gnats) Resent-Date: Mon, 18 Jun 2007 20:30:04 GMT Resent-Message-Id: <200706182030.l5IKU4dp064540@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ighighi Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A8B3516A400 for ; 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 ; 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 ; 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 To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: bin/113838: [patch]: This patch to mount(8) adds support for relative pathnames X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2007 20:30:04 -0000 >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@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: