From mac@romy.carbonide.com  Sat Jan 13 17:46:37 2001
Return-Path: <mac@romy.carbonide.com>
Received: from romy.carbonide.com (romy.carbonide.com [212.105.74.73])
	by hub.freebsd.org (Postfix) with ESMTP id D048F37B402
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 13 Jan 2001 17:46:36 -0800 (PST)
Received: by romy.carbonide.com (Postfix, from userid 1000)
	id C3B13382A; Sun, 14 Jan 2001 02:46:22 +0100 (CET)
Message-Id: <20010114014622.C3B13382A@romy.carbonide.com>
Date: Sun, 14 Jan 2001 02:46:22 +0100 (CET)
From: markush@acc.umu.se
Reply-To: markush@acc.umu.se
To: FreeBSD-gnats-submit@freebsd.org
Subject: getcwd under Linux emulation fails after rmdir
X-Send-Pr-Version: 3.2

>Number:         24315
>Category:       kern
>Synopsis:       getcwd under Linux emulation fails after a rmdir
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 13 17:50:01 PST 2001
>Closed-Date:    Thu Oct 18 12:47:20 PDT 2001
>Last-Modified:  Thu Oct 18 12:47:56 PDT 2001
>Originator:     Markus Holmberg
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
n/a
>Environment:

	FreeBSD 4.2-STABLE

>Description:

	After doing a rmdir(2) on a directory (in FreeBSD "mode", in a
	shell for example), a program executing under Linux emulation
	will fail the call to getcwd with the error "Not a directory".

>How-To-Repeat:

	$ cd /tmp
	$ ./cwd
	/tmp
	$ mkdir foo
	$ rmdir foo
	$ ./cwd
	getcwd: Not a directory


	# to "fix" the problem, do a "cd ."

	$ cd .
	$ ./cwd
	/tmp

cwd.c:

------------------------------------------------------
#include <unistd.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
        char *buf;

        if ((buf = getcwd(NULL, 0)) == NULL) {
                perror("getcwd");
                return 1;
        }
        printf("%s\n", buf);

        return 0;
}
------------------------------------------------------


>Fix:

	Not known.


>Release-Note:
>Audit-Trail:

From: David Malone <dwmalone@maths.tcd.ie>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/24315: getcwd under Linux emulation fails after a rmdir
Date: Wed, 23 May 2001 14:24:28 +0100

 I'm just bouncing this message into the audit trail for the PR.
 
 	David.
 
 ----- Forwarded message from David Malone <dwmalone@maths.tcd.ie> -----
 
 Delivered-To: freebsd-hackers@freebsd.org
 Date: Wed, 23 May 2001 12:38:21 +0100
 From: David Malone <dwmalone@maths.tcd.ie>
 To: "Koster, K.J." <K.J.Koster@kpn.com>
 Cc: 'Alfred Perlstein' <bright@rush.net>,
     'FreeBSD Hackers mailing list' <freebsd-hackers@freebsd.org>
 Subject: Re: Linux getcwd problems
 In-Reply-To: <59063B5B4D98D311BC0D0001FA7E452205FD9C04@l04.research.kpn.com>; from K.J.Koster@kpn.com on Wed, May 23, 2001 at 01:02:01PM +0100
 List-Archive: <http://docs.freebsd.org/mail/> (Web Archive)
 X-Loop: FreeBSD.ORG
 
 On Wed, May 23, 2001 at 01:02:01PM +0100, Koster, K.J. wrote:
 
 The problem seems to be that FreeBSD's getcwd library call will
 impliment the getcwd userland if the syscall fails or is unimplimented.
 
 There are times when the syscall fails in normal operation and you
 don't see this with the BSD stuff 'cos it is covered up by the
 userland implimentation. You can check this by kdumping a FreeBSD
 version of your cwd program and searching for the return value of
 the __getcwd syscall.
 
 The Linux emulation stuff just calls the FreeBSD syscall, but I
 guess the Linux libraries don't expect getcwd to fail, so they
 can't do the userland magic.
 
 I haven't had a chance to look at how hard it would be to fix the
 FreeBSD getcwd call to always work, or to fake the Linux stuff so
 that it somehow did the equivelent of the userland thing.
 
 	David.
 
 To Unsubscribe: send mail to majordomo@FreeBSD.org
 with "unsubscribe freebsd-hackers" in the body of the message
 
 ----- End forwarded message -----

From: Markus Holmberg <markush@acc.umu.se>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/24315: getcwd under Linux emulation fails after a rmdir
Date: Tue, 25 Sep 2001 09:51:53 +0200

 Fixed in 5.0-CURRENT:
 
 modules/linux/Makefile (Revision 1.52)
 conf/files.i386 (Revision 1.370)
 compat/linux/linux_file.c (Revision 1.54)
 compat/linux/linux_getcwd.c (Revision 1.1)
  
 Andrew Gallatin's commit message:
 "Fix linux_getcwd() so that if the cwd isn't cached (__getcwd() fails),
 the cwd is looked up inside the kernel. The native getcwd() in libc
 handles this in userland if __getcwd() fails."
State-Changed-From-To: open->closed 
State-Changed-By: gallatin 
State-Changed-When: Thu Oct 18 12:47:20 PDT 2001 
State-Changed-Why:  
Fixed in -current and (finally) in -stable 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=24315 
>Unformatted:

Fixed in -current and -stable

