From q@uni.de  Tue Aug 26 06:57:59 2003
Return-Path: <q@uni.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 25CE116A4C0
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 2003 06:57:59 -0700 (PDT)
Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 80DE143FE0
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 2003 06:57:54 -0700 (PDT)
	(envelope-from q@uni.de)
Received: from wrzx34.rz.uni-wuerzburg.de (wrzx34.rz.uni-wuerzburg.de [132.187.3.34])
	by wrzx28.rz.uni-wuerzburg.de (Postfix) with ESMTP id 16A1A1D8A
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 2003 15:57:53 +0200 (CEST)
Received: from virusscan (localhost [127.0.0.1])
	by wrzx34.rz.uni-wuerzburg.de (Postfix) with ESMTP id E0130D62D
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 2003 15:58:40 +0200 (CEST)
Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28])
	by wrzx34.rz.uni-wuerzburg.de (Postfix) with ESMTP id A4713D669
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 2003 15:58:40 +0200 (CEST)
Received: from frodo.galgenberg.net (wwsx14.win-screen.uni-wuerzburg.de [132.187.253.14])
	by mailmaster.uni-wuerzburg.de (Postfix) with SMTP id 968961D8A
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 2003 15:57:52 +0200 (CEST)
Received: (qmail 85328 invoked from network); 26 Aug 2003 13:57:52 -0000
Received: from gb-21-237.galgenberg.net (HELO coyote.local) (172.16.21.237)
  by frodo.galgenberg.net with SMTP; 26 Aug 2003 13:57:52 -0000
Received: from roadrunner.local (roadrunner [192.168.0.147])
	by coyote.local (8.12.9/8.12.8) with ESMTP id h7QDvqlt020247
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 2003 15:57:52 +0200 (CEST)
	(envelope-from q@roadrunner.local)
Received: from roadrunner.local (localhost [127.0.0.1])
	by roadrunner.local (8.12.9/8.12.9) with ESMTP id h7QDvm5H004824
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 2003 15:57:48 +0200 (CEST)
	(envelope-from q@roadrunner.local)
Received: (from q@localhost)
	by roadrunner.local (8.12.9/8.12.9/Submit) id h7QDvlG5004823;
	Tue, 26 Aug 2003 15:57:47 +0200 (CEST)
Message-Id: <200308261357.h7QDvlG5004823@roadrunner.local>
Date: Tue, 26 Aug 2003 15:57:47 +0200 (CEST)
From: Ulrich Spoerlein <q@uni.de>
Reply-To: Ulrich Spoerlein <q@uni.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: getcwd() breaks on unionfs mounted directories
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         55993
>Category:       kern
>Synopsis:       [unionfs] getcwd() breaks on unionfs mounted directories
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 26 07:00:26 PDT 2003
>Closed-Date:    Sat Oct 02 18:56:13 GMT 2004
>Last-Modified:  Sat Oct 02 18:56:13 GMT 2004
>Originator:     Ulrich Spoerlein
>Release:        FreeBSD 5.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD roadrunner 5.1-RELEASE FreeBSD 5.1-RELEASE #1: Mon Aug 11 15:27:16 CEST 2003 q@roadrunner:/usr/obj/usr/src/sys/ROADRUNNER i386
>Description:
Inside a chroot, a simple 'pwd' will fail, if it is run on a unionfs mounted
directory. truss shows the following:
readlink("/etc/malloc.conf","aj",63)             = 2 (0x2)
issetugid()                                      = 0 (0x0)
getuid()                                         = 0 (0x0)
mmap(0x0,4096,0x3,0x1002,-1,0x0)                 = 671449088 (0x28058000)
break(0x805c000)                                 = 0 (0x0)
break(0x805d000)                                 = 0 (0x0)
__getcwd(0x805c000,0x3fc)                        ERR#20 'Not a directory'
stat("/",0xbfbff4e0)                             = 0 (0x0)
lstat(".",0xbfbff4e0)                            = 0 (0x0)
stat("..",0xbfbff400)                            = 0 (0x0)
open("..",0x4,00)                                = 3 (0x3)
fstat(3,0xbfbff400)                              = 0 (0x0)
fcntl(0x3,0x2,0x1)                               = 0 (0x0)
break(0x805e000)                                 = 0 (0x0)
__sysctl(0xbfbff2b0,0x2,0x8059084,0xbfbff2ac,0x0,0x0) = 0 (0x0)
fstatfs(0x3,0xbfbff300)                          = 0 (0x0)
break(0x805f000)                                 = 0 (0x0)
getdirentries(0x3,0x805e000,0x1000,0x805d014)    = 512 (0x200)
getdirentries(0x3,0x805e200,0xe00,0x805d014)     = 512 (0x200)
getdirentries(0x3,0x805e400,0xc00,0x805d014)     = 0 (0x0)
fstat(3,0xbfbff4e0)                              = 0 (0x0)
lseek(3,0x200,0)                                 = 512 (0x200)
close(3)                                         = 0 (0x0)
lstat("../",0xbfbff4e0)                          = 0 (0x0)
stat("../..",0xbfbff400)                         = 0 (0x0)
open("../..",0x4,04)                             = 3 (0x3)
fstat(3,0xbfbff400)                              = 0 (0x0)
fcntl(0x3,0x2,0x1)                               = 0 (0x0)
fstatfs(0x3,0xbfbff300)                          = 0 (0x0)
fstat(3,0xbfbff4e0)                              = 0 (0x0)
getdirentries(0x3,0x805e000,0x1000,0x805d014)    = 512 (0x200)
getdirentries(0x3,0x805e000,0x1000,0x805d014)    = 0 (0x0)
lseek(3,0x0,0)                                   = 0 (0x0)
close(3)                                         = 0 (0x0)
pwd: write(2,0xbfbfedd0,5)                               = 5 (0x5)
.write(2,0xbfbfedf0,1)                           = 1 (0x1)
: write(2,0x80568cc,2)                           = 2 (0x2)
No such file or directory
write(2,0xbfbfedd0,26)                           = 26 (0x1a)
exit(0x1)
process exit, rval = 256

This also renders 'make' in any port of choice unuseable.
>How-To-Repeat:
cd /usr/src && make world DESTDIR=/livefs
mkdir -p /livefs/usr/ports && mount -t unionfs /usr/ports /livefs/usr/ports

Doing a pwd in /livefs/usr/ports/editors/vim works just fine, however doing a
'make' fails. Running truss on both processes shows that both processes should
fail to get getcwd(). I don't know why a simple pwd prints the correct directory,
a 'truss pwd' does not.

Now chroot to /livefs

# chroot /livefs /bin/tcsh
# cd /usr/ports/editors/vim && pwd
pwd: .: No such file or directory

So here pwd "correctly fails" to call getcwd() (It always returns ERR#20), make is
broken too.

>Fix:

Please don't tell me that unionfs is buggy, I know that and I read the manpages.
However I think that (when working) unionfs is a real cool tool and can obviously
do more than an union-mount. I will try to get into debugging this, but my skills
are severly limited with respect to that area :(

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: kris 
State-Changed-When: Sat Nov 15 13:43:57 PST 2003 
State-Changed-Why:  
Suspended awaiting patch 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55993 

From: Ryan Beasley <ryanb@goddamnbastard.org>
To: freebsd-gnats-submit@FreeBSD.org, q@uni.de
Cc:  
Subject: Re: kern/55993: getcwd() breaks on unionfs mounted directories
Date: Tue, 27 Jan 2004 16:12:34 -0600

 --EeQfGwPcQSOJBaQU
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 I found a patch that required only slight modification to work under 5.2-RC.
 
 http://docs.freebsd.org/cgi/getmsg.cgi?fetch=3D633632+0+archive/2002/freebs=
 d-hackers/20020310.freebsd-hackers
 
 I'm not sure if it's safe and "does the right thing", but it seemed to work
 with only slight modification.  (Change saveflags to cnp->cn_flags.)
 
 --=20
 ryan beasley                            <ryanb@goddamnbastard.org>
 GPG ID: 0x16EFBD48
 
 --EeQfGwPcQSOJBaQU
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.4 (FreeBSD)
 
 iD8DBQFAFuJRskfdOxbvvUgRArS/AKCUPv84vvNnAkn6K1fd9uxM4dXOEwCdGpWG
 +OslR70oA4OP0yzB2NH71Mk=
 =vud4
 -----END PGP SIGNATURE-----
 
 --EeQfGwPcQSOJBaQU--

From: Ryan Beasley <ryanb@goddamnbastard.org>
To: freebsd-gnats-submit@FreeBSD.org, q@uni.de
Cc:  
Subject: Re: kern/55993: getcwd() breaks on unionfs mounted directories
Date: Tue, 27 Jan 2004 19:19:04 -0600

 --ZfOjI3PrQbgiZnxM
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 My mistake.
 
 Use this link instead:
 	http://docs.freebsd.org/cgi/mid.cgi?1015415443.3157.2.camel
 
 --=20
 ryan beasley                            <ryanb@goddamnbastard.org>
 GPG ID: 0x16EFBD48
 
 --ZfOjI3PrQbgiZnxM
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.4 (FreeBSD)
 
 iD8DBQFAFw4IskfdOxbvvUgRAjvsAJ90+JIOk6v9Je98oLE6HT3njMgnIQCfVrD1
 0WNr1hX9y1Vxvpf4ARvsLfs=
 =RerA
 -----END PGP SIGNATURE-----
 
 --ZfOjI3PrQbgiZnxM--
State-Changed-From-To: suspended->closed 
State-Changed-By: takawata 
State-Changed-When: Sat Oct 2 18:53:04 GMT 2004 
State-Changed-Why:  
I committed the fix I submitted two years ago . 



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