From ok@etrust.ru  Fri Oct 24 03:59:46 2003
Return-Path: <ok@etrust.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 709CE16A4B3
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 Oct 2003 03:59:46 -0700 (PDT)
Received: from zippo.etrust.ru (zippo.etrust.ru [194.84.67.3])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9294543F3F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 Oct 2003 03:59:44 -0700 (PDT)
	(envelope-from ok@etrust.ru)
Received: from blizzard.etrust.ru (blizzard.etrust.ru [192.168.25.5])
	by zippo.etrust.ru (8.12.9/8.12.9) with ESMTP id h9OAcmVU040339
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 Oct 2003 14:38:48 +0400 (MSD)
	(envelope-from ok@etrust.ru)
Received: from dik.etrust.ru (dik.etrust.ru [192.168.30.88])
	by blizzard.etrust.ru (8.12.9/8.12.9) with ESMTP id h9OAclcj092642
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 Oct 2003 14:38:47 +0400 (MSD)
	(envelope-from ok@etrust.ru)
Received: from dik.etrust.ru (localhost.etrust.ru [127.0.0.1])
	by dik.etrust.ru (8.12.9/8.12.9) with ESMTP id h9O9wCcv037724
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 Oct 2003 13:58:12 +0400 (MSD)
	(envelope-from ok@etrust.ru)
Received: (from ok@localhost)
	by dik.etrust.ru (8.12.9/8.12.9/Submit) id h9O9wC8p037723;
	Fri, 24 Oct 2003 13:58:12 +0400 (MSD)
Message-Id: <200310240958.h9O9wC8p037723@dik.etrust.ru>
Date: Fri, 24 Oct 2003 13:58:12 +0400 (MSD)
From: Oleg Karachevtsev <ok@etrust.ru>
Reply-To: Oleg Karachevtsev <ok@etrust.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] allows type special or node relative names
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         58483
>Category:       bin
>Synopsis:       [patch] mount(8): allow type special or node relative names
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 24 04:00:34 PDT 2003
>Closed-Date:    
>Last-Modified:  Sun Oct 23 22:12:28 GMT 2005
>Originator:     Oleg Karachevtsev
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD 5.1-CURRENT i386

>Description:
	Allows type special or node relative names.
>How-To-Repeat:
	>cd /dev; mount acd0
	mount: acd0: unknown special file or file system
	>cd /mnt; mount cdrom
	mount: cdrom: unknown special file or file system

>Fix:
Index: mount.c
===================================================================
RCS file: /home/ncvs/src/sbin/mount/mount.c,v
retrieving revision 1.54
diff -u -r1.54 mount.c
--- mount.c	7 Aug 2003 04:51:41 -0000	1.54
+++ mount.c	24 Oct 2003 09:43:17 -0000
@@ -136,6 +136,7 @@
 	pid_t pid;
 	int all, ch, i, init_flags, mntsize, rval, have_fstab;
 	char *cp, *ep, *options;
+	char mntnamereal[MAXPATHLEN + 1];
 
 	all = init_flags = 0;
 	options = NULL;
@@ -272,8 +273,9 @@
 			break;
 		}
 		rmslashes(*argv, *argv);
-		if ((fs = getfsfile(*argv)) == NULL &&
-		    (fs = getfsspec(*argv)) == NULL)
+		if (realpath(*argv,mntnamereal) == NULL ||
+		    ((fs = getfsfile(mntnamereal)) == NULL &&
+		     (fs = getfsspec(mntnamereal)) == NULL))
 			errx(1, "%s: unknown special file or file system",
 			    *argv);
 		if (BADTYPE(fs->fs_type))
>Release-Note:
>Audit-Trail:

From: Oleg Karachevtsev <ok@etrust.ru>
To: freebsd-gnats-submit@FreeBSD.org, ok@etrust.ru
Cc:  
Subject: Re: bin/58483: [PATCH] allows type special or node relative names
Date: Fri, 24 Oct 2003 16:53:00 +0400

 While realpath() used rmslashes() is not need at all.
 
 Index: getmntopts.c
 ===================================================================
 RCS file: /home/ncvs/src/sbin/mount/getmntopts.c,v
 retrieving revision 1.10
 diff -u -r1.10 getmntopts.c
 --- getmntopts.c	3 May 2003 18:41:58 -0000	1.10
 +++ getmntopts.c	24 Oct 2003 12:40:57 -0000
 @@ -110,28 +110,6 @@
  }
  
  void
 -rmslashes(rrpin, rrpout)
 -	char *rrpin;
 -	char *rrpout;
 -{
 -	char *rrpoutstart;
 -
 -	*rrpout = *rrpin;
 -	for (rrpoutstart = rrpout; *rrpin != '\0'; *rrpout++ = *rrpin++) {
 -
 -		/* skip all double slashes */
 -		while (*rrpin == '/' && *(rrpin + 1) == '/')
 -			 rrpin++;
 -	}
 -
 -	/* remove trailing slash if necessary */
 -	if (rrpout - rrpoutstart > 1 && *(rrpout - 1) == '/')
 -		*(rrpout - 1) = '\0';
 -	else
 -		*rrpout = '\0';
 -}
 -
 -void
  checkpath(path, resolved)
  	const char *path;
  	char *resolved;
 Index: mntopts.h
 ===================================================================
 RCS file: /home/ncvs/src/sbin/mount/mntopts.h,v
 retrieving revision 1.20
 diff -u -r1.20 mntopts.h
 --- mntopts.h	14 Oct 2002 19:40:00 -0000	1.20
 +++ mntopts.h	24 Oct 2003 12:40:57 -0000
 @@ -93,6 +93,5 @@
  	MOPT_ACLS
  
  void getmntopts(const char *, const struct mntopt *, int *, int *);
 -void rmslashes(char *, char *);
  void checkpath(const char *, char resolved_path[]);
  extern int getmnt_silent;
 Index: mount.c
 ===================================================================
 RCS file: /home/ncvs/src/sbin/mount/mount.c,v
 retrieving revision 1.54
 diff -u -r1.54 mount.c
 --- mount.c	7 Aug 2003 04:51:41 -0000	1.54
 +++ mount.c	24 Oct 2003 12:40:58 -0000
 @@ -136,6 +136,7 @@
  	pid_t pid;
  	int all, ch, i, init_flags, mntsize, rval, have_fstab;
  	char *cp, *ep, *options;
 +	char mntnamereal[MAXPATHLEN];
  
  	all = init_flags = 0;
  	options = NULL;
 @@ -271,9 +272,9 @@
  			    mntbuf->f_mntonname, init_flags, options, 0);
  			break;
  		}
 -		rmslashes(*argv, *argv);
 -		if ((fs = getfsfile(*argv)) == NULL &&
 -		    (fs = getfsspec(*argv)) == NULL)
 +		if (realpath(*argv,mntnamereal) == NULL ||
 +		    ((fs = getfsfile(mntnamereal)) == NULL &&
 +		     (fs = getfsspec(mntnamereal)) == NULL))
  			errx(1, "%s: unknown special file or file system",
  			    *argv);
  		if (BADTYPE(fs->fs_type))
 
 
 -- 
 WBR, Oleg Karachevtsev
 http://dik.pp.ru
>Unformatted:
