Subject: bin/28786: mtree bug (in verify.c)
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <j+nbsd@2004.salmi.ch>
List: netbsd-bugs
Date: 12/26/2004 15:36:00
>Number:         28786
>Category:       bin
>Synopsis:       mtree bug (in verify.c)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 26 15:36:00 +0000 2004
>Originator:     Jukka Salmi
>Release:        NetBSD current and 2.0
>Environment:
System: NetBSD himo.salmi.ch 2.99.11 NetBSD 2.99.11 (GENERIC) #0: Wed Dec 22 16:41:14 CET 2004 build@himo.salmi.ch:/build/nbsd/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
On both NetBSD current and 2.0, mtree seems to have a bug (see
"How-To-Repeat" for details). I didn't have a look at older versions.
>How-To-Repeat:
Given the following mtree specification

	/set type=file
	. type=dir
		file1
		file2

in a file 'spec' and a matching filesystem tree in directory 'dir'

	$ ls -la dir
	total 8
	drwxr-xr-x  2 jukka  jukka  512 Dec 26 16:19 ./
	drwx------  8 jukka  jukka  512 Dec 26 16:20 ../
	-rw-r--r--  1 jukka  jukka    0 Dec 26 16:22 file1
	-rw-r--r--  1 jukka  jukka    0 Dec 26 16:22 file2

running 'mtree -f spec -p dir -U' gives no output (as expected).
Removing 'file1' from the specification and running the command
again prints

	$ mtree -f spec -p dir -U
	extra: file1

as expected. However, removing 'file2' as well, the same command prints
nothing. I would have expected it to print

	$ mtree -f spec -p dir -U                           
	extra: file1
	extra: file2

>Fix:
In src/usr.sbin/mtree/verify.c, commenting out the 'else' statement on
line 134f. (else fts_set(t, p, FTS_SKIP);) seems to fix the problem.
However, I don't really understand the code, so I'm possibly talking
nonsense.