From owner-freebsd-bugs@freebsd.org Thu Feb 11 04:07:50 2021 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 137995398B2 for ; Thu, 11 Feb 2021 04:07:50 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4DbjlT6zL6z4h68 for ; Thu, 11 Feb 2021 04:07:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id ED8E9539924; Thu, 11 Feb 2021 04:07:49 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ED51A539A1C for ; Thu, 11 Feb 2021 04:07:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DbjlT6FjSz4h1w for ; Thu, 11 Feb 2021 04:07:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C9FA22331 for ; Thu, 11 Feb 2021 04:07:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 11B47nYI090817 for ; Thu, 11 Feb 2021 04:07:49 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 11B47nEV090816 for bugs@FreeBSD.org; Thu, 11 Feb 2021 04:07:49 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 253428] getdirentries does not work correctly on NFS mounts Date: Thu, 11 Feb 2021 04:07:50 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: asomers@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.mimetype attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2021 04:07:50 -0000 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.=