libfs: getdents() should return 0 after reaching EOD
authorChuck Lever <chuck.lever@oracle.com>
Sun, 19 Nov 2023 23:56:17 +0000 (18:56 -0500)
committerChristian Brauner <brauner@kernel.org>
Mon, 20 Nov 2023 14:34:22 +0000 (15:34 +0100)
commit796432efab1e372d404e7a71cc6891a53f105051
tree393f706088d6418bec28ace1db1670d0e8ecbf00
parent9c04138414c00ae61421f36ada002712c4bac94a
libfs: getdents() should return 0 after reaching EOD

The new directory offset helpers don't conform with the convention
of getdents() returning no more entries once a directory file
descriptor has reached the current end-of-directory.

To address this, copy the logic from dcache_readdir() to mark the
open directory file descriptor once EOD has been reached. Seeking
resets the mark.

Reported-by: Tavian Barnes <tavianator@tavianator.com>
Closes: https://lore.kernel.org/linux-fsdevel/20231113180616.2831430-1-tavianator@tavianator.com/
Fixes: 6faddda69f62 ("libfs: Add directory operations for stable offsets")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Link: https://lore.kernel.org/r/170043792492.4628.15646203084646716134.stgit@bazille.1015granger.net
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/libfs.c