From mi@xxx.video-collage.com  Wed Jun 24 20:27:40 1998
Received: from www.video-collage.com (www.video-collage.com [206.15.171.132])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id UAA03564
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Jun 1998 20:27:39 -0700 (PDT)
          (envelope-from mi@xxx.video-collage.com)
Received: from xxx.video-collage.com (xxx.video-collage.com [199.232.254.68])
	by www.video-collage.com (8.8.5/8.8.5) with ESMTP id XAA22992
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Jun 1998 23:25:01 -0400 (EDT)
Received: (from root@localhost)
	by xxx.video-collage.com (8.8.8/8.8.7) id XAA09610;
	Wed, 24 Jun 1998 23:27:28 -0400 (EDT)
	(envelope-from mi)
Message-Id: <199806250327.XAA09610@xxx.video-collage.com>
Date: Wed, 24 Jun 1998 23:27:28 -0400 (EDT)
From: Mikhail Teterin <mi@video-collage.com>
Reply-To: mi@aldan.algebra.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: nit-picking on mount
X-Send-Pr-Version: 3.2

>Number:         7063
>Category:       bin
>Synopsis:       mount fails if $PWD does not exist
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 24 20:30:01 PDT 1998
>Closed-Date:    Mon Jun 14 05:30:23 PDT 1999
>Last-Modified:  Tue Mar 28 08:30:00 PST 2000
>Originator:     Mikhail Teterin
>Release:        FreeBSD 2.2.6-BETA i386
>Organization:
Virtual Estates, Inc.
>Environment:


>Description:

	When the current directory is removed, mount will fail

>How-To-Repeat:

	mkdir /tmp/test
	cd /tmp/test
	rmdir /tmp/test
	mount -u -o async,noatime /some-fs
	mount: .: No such file or directory

>Fix:
	
	cd /somewhere
	repeat the mount
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Wed Jul 1 00:42:01 PDT 1998 
State-Changed-Why:  
awaiting fix & committer 
State-Changed-From-To: suspended->closed 
State-Changed-By: sheldonh 
State-Changed-When: Mon Jun 14 05:30:23 PDT 1999 
State-Changed-Why:  
Submitter confirms that the problem has been fixed since the report. 

From: Mikhail Teterin <mi@aldan.algebra.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/7063: mount fails if $PWD does not exist
Date: Tue, 28 Mar 2000 11:21:33 -0500

 This is a multi-part message in MIME format.
 --------------94B7256161EBABF294F5ABEB
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 An almost identical problem still exists :(
 
 If the directory was just plain removed after one cd-ed
 into it, mount will work. But if the entire file-system
 was unmounted, mount will fail:
 
 root@rtfm:src/sys/compile (123) mount /cdrom0
 mount: .: Not a directory
 
 even though none of its parameteres involve current directory
 or the unmounted file-system.
 
 It appears, the problem is with realpath(3), which mount
 invokes. realpath() insists on . being openable.
 
 May be, something like the attached is needed (damn the goto)?
 
 In any case, an entry in the CAVEATS section of realpath(3)
 is in order explaining its behavior in case `.' does not
 exist.
 
 	-mi
 --------------94B7256161EBABF294F5ABEB
 Content-Type: text/plain; charset=us-ascii;
  name="p"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="p"
 
 --- lib/libc/stdlib/realpath.c	Thu Jan 27 18:06:50 2000
 +++ lib/libc/stdlib/realpath.c	Tue Mar 28 11:11:03 2000
 @@ -68,7 +68,4 @@
  
 -	/* Save the starting point. */
 -	if ((fd = _open(".", O_RDONLY)) < 0) {
 -		(void)strcpy(resolved, ".");
 -		return (NULL);
 -	}
 +	/* Save the starting point, if possible */
 +	fd = _open(".", O_RDONLY);
  
 @@ -149,4 +146,4 @@
  
 -	/* Go back to where we came from. */
 -	if (fchdir(fd) < 0) {
 +	/* Go back to where we came from. If we know where, that is */
 +	if (fd >= 0 && fchdir(fd) < 0) {
  		serrno = errno;
 @@ -160,4 +157,4 @@
  err1:	serrno = errno;
 -	(void)fchdir(fd);
 -err2:	(void)_close(fd);
 +	if (fd >=0) (void)fchdir(fd);
 +err2:	if (fd >=0) (void)_close(fd);
  	errno = serrno;
 
 --------------94B7256161EBABF294F5ABEB--
 
 
>Unformatted:
