Subject: kern/28397: fdesc filesystems: directory causes a cycle
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <igor@string1.ciencias.uniovi.es>
List: netbsd-bugs
Date: 11/23/2004 16:40:00
>Number:         28397
>Category:       kern
>Synopsis:       fdesc filesystems: directory causes a cycle
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 23 16:40:00 +0000 2004
>Originator:     Igor Sobrado
>Release:        1.6.2
>Organization:
University of Oviedo
>Environment:
NetBSD localhost 1.6.2 NetBSD 1.6.2 (CPIR400GT) #0: Sun Jun 13 23:09:13 CEST 2004     sobrado@localhost:/usr/src/sys/arch/i386/compile/CPIR400GT i386

>Description:
Mounting a file-descriptor filesystem gives unexpected results.
>How-To-Repeat:
1. mount a file-descriptor filesystem either manually or from a fstab file like the next one:

/dev/wd0a       /               ffs     rw,softdep      1 1
/dev/wd0b       none            swap    sw              0 0
/dev/wd0e       /usr            ffs     rw,softdep      1 2
/dev/wd0f       /usr/contrib    ffs     rw,softdep      1 2
/dev/wd0g       /usr/obj        ffs     rw,softdep      1 2
/dev/wd0h       /usr/pkg        ffs     rw,softdep      1 2
/dev/wd0i       /usr/pkgsrc     ffs     rw,softdep      1 2
/dev/wd0j       /usr/src        ffs     rw,softdep      1 2
/dev/wd0k       /usr/X11R6      ffs     rw,softdep      1 2
/dev/wd0l       /var            ffs     rw,softdep      1 2
/dev/wd0m       /dump           ffs     rw,softdep      1 2
/dev/wd0n       /home           ffs     rw,softdep      1 2
swap            /tmp            mfs     rw,-s=16m       0 0
kernfs          /kern           kernfs  rw              0 0
procfs          /proc           procfs  rw              0 0
fdesc           /dev            fdesc   rw,union        0 0

2. move to the /dev/fd subdirectory:

# cd /dev/fd

3. some entries in this directory are not character devices:

# ls -la
total 0
dr-xr-xr-x  2 root  wheel   512 Nov 23 15:51 .
dr-xr-xr-x  2 root  wheel   512 Nov 23 15:51 ..
crw-rw-rw-  1 root  wheel  5, 1 Nov 22 23:46 0
crw-rw-rw-  1 root  wheel  5, 1 Nov 22 23:46 1
crw-rw-rw-  1 root  wheel  5, 1 Nov 22 23:46 2
dr--r--r--  2 root  wheel   512 Nov 23 15:51 3
dr--r--r--  2 root  wheel   512 Nov 23 15:51 4
dr--r--r--  2 root  wheel   512 Nov 23 15:51 5

why???

4. recursively listing those entries produce the cycle errors:

localhost# ls -lR
total 0
crw-rw-rw-  1 root  wheel  5, 1 Nov 22 23:46 0
crw-rw-rw-  1 root  wheel  5, 1 Nov 22 23:46 1
crw-rw-rw-  1 root  wheel  5, 1 Nov 22 23:46 2
dr--r--r--  2 root  wheel   512 Nov 23 15:51 3
dr--r--r--  2 root  wheel   512 Nov 23 15:51 4
dr--r--r--  2 root  wheel   512 Nov 23 15:51 5
ls: 3: directory causes a cycle
ls: 4: directory causes a cycle
ls: 5: directory causes a cycle

5. when not using the long format output in ls(1) all looks fine
(of course, if we exclude that entries 3-5 are not devices):

# ls -R
0 1 2 3 4 5

>Fix:
Unknown, sorry.  I am not a kernel expert.  :-(