Subject: kern/8183: unionfs: delay creation of shadow directories
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wes@epilogue.com>
List: netbsd-bugs
Date: 08/09/1999 21:35:48
>Number:         8183
>Category:       kern
>Synopsis:       unionfs: delay creation of shadow directories
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Aug  9 21:35:01 1999
>Last-Modified:
>Originator:     Bill Sommerfeld
>Organization:
	
>Release:        19990802
>Environment:
	
System: NetBSD heap.epilogue.com 1.4 NetBSD 1.4 (HEAPII) #72: Sun Jul 4 00:38:40 EDT 1999 wes@:/usr/sommerfeld/NetBSD-sys/arch/i386/compile/HEAPII i386


>Description:
	unionfs creates shadow directories in the upper
	layer of the union whenever a lookup happens into a directory
	which doesn't exist in the upper layer.

	this occurs even if the union is mounted read-only; a find(1)
	in a union mount with a mostly-empty upper layer still creates
	lots of empty directories.

>How-To-Repeat:

	mkdir /tmp/xxx		
	mount -o ro -t union /tmp/xxx /usr/src
	find /usr/src -type d -print >/dev/null
	umount /usr/src
	ls -R /tmp/xxx

>Fix:
	defer creation of shadow directories; just leave the upper
	layer NULL in the union vnode until something gets put in
	them.

	when something gets created in a directory with a null upper
	layer, scan upward in the union vnode directories until you
	reach a union vnode which does have an upper-layer directory, 
	then use the framework for getcwd(2) between those two nodes 
	to figure out the correct pathnames of directories to create
	in the upper layer.

	this is likely to be vnode locking minefield.

	getting it right in the presence of directory renames in the
	lower layer is likely to be a PITA.

>Audit-Trail:
>Unformatted: