Subject: kern/14521: kernel panic 'bad dir' while listing ext2fs-dir
To: None <>
From: None <>
List: netbsd-bugs
Date: 11/10/2001 11:41:56
>Number:         14521
>Category:       kern
>Synopsis:       kernel panics with 'bad dir' while trying to `ls` a directory on an ext2fs
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 10 03:43:00 PST 2001
>Originator:     Michael Rauch
>Release:        1.5Y (2001/11/09)
	i386, NetBSD-current (1.5Y) from cvs: 2001/11/09 about 1 pm GMT
	1.5.2 userland, GENERIC kernel with "options I686_CPU" commented out

Trying to list a directory on an ext2fs filesystem with a recent kernel 
causes the kernel to panic. 
The ddb backtrace is (copied from screen to paper so it may contain 
subtle errors):
panic: bad dir
Stopped in pid 231 (ls) at cpu_Debugger+0x4: leave
db> t
cpu_Debugger(c0bbd000,0,0,d3d42d70,c02fefda) at cpu_Debugger+0x4
panic(c0481d65,d0a28000,d3d42df4,c02dbc2d,d3d39000) at panic+0xa0
ufs_dirbad(d3d39000,0,c047d720,d3d34c20,0) at ufs_dirbad+0x3a
ext2fs_lookup(d3d42e04,d3d42eb0,c046a4a0,d3d34c20,d3d42ec0) at ext2fs_lookup+0x291
VOP_LOOKUP(d3d34c20,d3d42ec0,d3d42ed4,0,d3d42ed4) at VOP_LOOKUP+0x32
lookup(d3d42eb0,d3d42f78,d3d03c80,d3d42f80,1002) at lookup+0x238
namei(d3d42eb0,d3d42f78,d3d03c80,c05a5368,808e0c0) at namei+0x276
sys___stat13(d3d03c80,d3d42f80,d3d42f78) at sys___stat13+0x4c
syscall_plain(1f,1f,1f,1f,808e080) at syscall_plain+0x98

As I happened to have a two days older kernel which worked, I've played a 
bit with different revisions and the problem goes away if I do a 
`cvs update -d -p -D "2001/11/08 03:00 GMT" .` in src/sys/ufs/ufs. 

Update config, compile a kernel from 1.5.2 with details as found in 
"Environment" and reboot. Mount an ext2fs filesystem (created with linux 
and works perfectly fine under NetBSD 1.5.2) at /usr/src , type 
`ls /usr/src/src<Enter>` (it doesn't matter whether the directory entry 
exists or not).