Subject: Re: fts_read: No such file or directory
To: Jukka Salmi <j+nbsd@2005.salmi.ch>
From: Jeff <jeffi@rcn.com>
List: current-users
Date: 08/10/2005 09:14:11
On Wed, Aug 10, 2005 at 12:18:32PM +0200, Jukka Salmi wrote:
> Hi,
> 
> Peter Seebach --> current-users (2005-08-09 21:31:50 -0500):
> > $ du -s .
> > du: fts_read: No such file or directory
> 
> Do you use the fdesc file system on the system in question? After
> unmounting fdesc (mounted on /dev) on one of the systems where I saw
> the same problem du(1) suddenly worked fine...

I notice this as well, only when fdesc is mounted.
$ sudo mount -o union -t fdesc fdesc /dev

/tmp $ sudo du -s /
du: fts_read: No such file or directory

/ $ sudo du -s /
1546165 /

/ $ sudo du -s /dev
du: fts_read: No such file or directory

/dev $ sudo du -s /dev
59      /dev

/dev $ sudo du -s /dev/fd
[...snip...]
du: /dev/fd/3/tap2: No such file or directory
du: /dev/fd/3/tap3: No such file or directory
du: /dev/fd/3: No such file or directory
0       /dev/fd

/dev/fd $ sudo du -s /dev/fd [*]

uvm_fault(0xca3888c0, 0, 0, 1) -> 0xe
kernel: page fault trap, code=0
Stopped in pid 498.1 (sudo) at  netbsd:fdesc_readdir+0x63:      movl
0xc(%eax),%eax

Which is the following code:

sys/miscfs/fdesc/fdesc_vnops.c line 709:

int
fdesc_readdir(v)
        void *v;
{
[...]

        switch (VTOFDESC(ap->a_vp)->fd_type) {
        case Fctty:
                return (0);

        case Fdesc:
                return (ENOTDIR);

        default:
                break;
        }

        fdp = uio->uio_procp->p_fd;
	^^^^^^^^^^^^^^^^^^^^^^^^^^^

as a test I enclosed fdp=... in
	if(uio->uio_procp)
		fdp = ...
	else 
		return (ENOTDIR)

and was able to avoid the crash, however i'm sure this is not the
correct solution.

[*] Running commands such as 'mount -a' and 'umount /kern' from
    /dev/fd also produces this crash.