Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Feb 2021 04:07:50 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 253428] getdirentries does not work correctly on NFS mounts
Message-ID:  <bug-253428-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D253428

            Bug ID: 253428
           Summary: getdirentries does not work correctly on NFS mounts
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: asomers@FreeBSD.org
 Attachment #222358 text/plain
         mime type:

Created attachment 222358
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D222358&action=
=3Dedit
test program demonstrating getdirentries's output.

r318736, the 64-bit inode project, added a d_off field to struct dirent.=20
According to the man page, each entry's d_off field can be used with lseek(=
2)
to position the directory descriptor to the next entry.  That works for UFS,
devfs, ZFS, and tmpfs.  But the NFS client always returns 0 for d_off.

Secondly, getdirentries is supposed to return the length of valid data in t=
he
buffer.  For UFS, devfs, ZFS, and tmpfs it does it correctly.  But for NFS,=
 it
always returns the size of the buffer.

Steps to Reproduce:
1) Compile the attached program with cc -o getdirentries -Wall getdirentrie=
s.c
2) sudo mount -t tmpfs tmpfs /mnt
3) cd /mnt
4) sudo touch foo bar baz
5) /path/to/getdirentries 0
  len=3D160
  name=3D. d_reclen=3D32 d_off=3D1
  name=3D.. d_reclen=3D32 d_off=3D15397777
  name=3Dbar d_reclen=3D32 d_off=3D15397785
  name=3Dbaz d_reclen=3D32 d_off=3D250872870
  name=3Dfoo d_reclen=3D32 d_off=3D2
6) /path/to/getdirentries 1
  name=3D.. d_reclen=3D32 d_off=3D15397777
  name=3Dbar d_reclen=3D32 d_off=3D15397785
  name=3Dbaz d_reclen=3D32 d_off=3D250872870
  name=3Dfoo d_reclen=3D32 d_off=3D2
Notice that we supplied the first entry's d_off value, and getdirentries
returned a buffer starting with the second entry.
7) cd /path/to/some/NFS/mount
8) touch foo bar baz
9) /path/to/getdirentries 0
  len=3D8192
  name=3D. d_reclen=3D40 d_off=3D0
  name=3D.. d_reclen=3D40 d_off=3D0
  name=3Dbar d_reclen=3D40 d_off=3D0
  name=3Dfoo d_reclen=3D40 d_off=3D0
  name=3Dbaz d_reclen=3D352 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
  name=3D d_reclen=3D512 d_off=3D0
Notice the long tail of "" entries.  That's because the returned length is
equal to the size of the buffer.  Also, notice that d_off is always 0.=20
Obviously, it can't be supplied to lseek.

Observed with NFS v4.2 on a FreeBSD 14.0-CURRENT amd64 client with a
13.0-ALPHA1 server.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-253428-227>