Is there an example where you have seen an fs not report . and .. ? On Tue, Sep 3, 2024 at 12:19 AM Hobin Woo <hobin.woo@xxxxxxxxxxx> wrote: > > Some file systems may not provide dot (.) and dot-dot (..) as they are > optional in POSIX. ksmbd can misjudge emptiness of a directory in those > file systems, since it assumes there are always at least two entries: > dot and dot-dot. > Just set the dirent_count to 2, if the first entry is not a dot. > > Signed-off-by: Hobin Woo <hobin.woo@xxxxxxxxxxx> > --- > fs/smb/server/vfs.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c > index 9e859ba010cf..bb836fa0aaa6 100644 > --- a/fs/smb/server/vfs.c > +++ b/fs/smb/server/vfs.c > @@ -1115,6 +1115,8 @@ static bool __dir_empty(struct dir_context *ctx, const char *name, int namlen, > struct ksmbd_readdir_data *buf; > > buf = container_of(ctx, struct ksmbd_readdir_data, ctx); > + if (offset == 0 && !(namlen == 1 && name[0] == '.')) > + buf->dirent_count = 2; > buf->dirent_count++; > > return buf->dirent_count <= 2; > -- > 2.43.0 > > -- Thanks, Steve