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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Dec 2023 06:33:03 +0000 (07:33 +0100)
commit53da7fe847d58e771ee9b01ea14e3a94ff60cd7d
tree08dab924553b8494cef1b314a84bdfb3e087516a
parent468a549d2ab57c89085f5e8f9a308908c6d689e5
libfs: getdents() should return 0 after reaching EOD

[ Upstream commit 796432efab1e372d404e7a71cc6891a53f105051 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/libfs.c