Subject: kern/31507: getcwd returns ERANGE after directory move across null mount
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Simon Burge <simonb@wasabisystems.com>
List: netbsd-bugs
Date: 10/08/2005 12:51:00
>Number:         31507
>Category:       kern
>Synopsis:       getcwd returns ERANGE after directory move across null mount
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 08 12:51:00 +0000 2005
>Originator:     Simon Burge <simonb@wasabisystems.com>
>Release:        NetBSD 3.0_BETA, September 6 2005 sources
>Organization:
Wasabi Systems
>Environment:
System: NetBSD thoreau 3.0_BETA NetBSD 3.0_BETA (THOREAU) #1:
	Tue Sep 6 01:13:10 EST 2005
	simonb@thoreau:/usr/obj/sys/arch/i386/compile/THOREAU i386
Architecture: i386
Machine: i386
>Description:
	Moving a directory from the "top" part of a null mount to the
	"bottom" part of a null mount and then calling getcwd(2) gets an
	ERANGE error.  This problem exists on the netbsd-3 branch but
	doesn't exist in -current (as of around Sep 29 2005).

>How-To-Repeat:
	In one window:

		thoreau 1> mount | grep home
		/data/00/home on /home type null (hidden, NFS exported, local)
		thoreau 2> df .
		Filesystem    1K-blocks      Used     Avail Capacity  Mounted on
		/data/00/home 102985734  87545602  10290846    89%    /home
		thoreau 3> mkdir foo
		thoreau 4> cd foo
		thoreau 5> pwd
		/home/simonb/foo

	In another window:

		thoreau 1# mv /home/simonb/foo /data/00/foofoo

	Back in the first window:

		thoreau 6> pwd
		pwd: Result too large or too small
		 (this is getcwd(2) returning ERANGE)

	Using a small program that uses a 1MB buffer passed to getcwd(2)
	still fails with ERANGE.  A ktrace of mv shows that rename(2) is
	used instead of copying:

		10169 mv       CALL  rename(0xbfbfe9ef,0xbfbfea00)
		10169 mv       NAMI  "/home/simonb/foo"
		10169 mv       NAMI  "/data/00/foofoo"
		10169 mv       RET   rename 0

>Fix:
	None given.