RE: [PATCH] ksmbd: make __dir_empty() compatible with POSIX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Android's FUSE file system, /storage/emulated/<USER>, is an example of this.
https://cs.android.com/android/platform/superproject/main/+/main:packages/providers/MediaProvider/jni/ReaddirHelper.cpp;l=52;drc=01c2d29eeefc2d344794429af3df08c38adfd57f

> -----Original Message-----
> From: Steve French <smfrench@xxxxxxxxx>
> Sent: Tuesday, September 3, 2024 2:45 PM
> To: Hobin Woo <hobin.woo@xxxxxxxxxxx>
> Cc: linux-cifs@xxxxxxxxxxxxxxx; linkinjeon@xxxxxxxxxx; sfrench@xxxxxxxxx;
> senozhatsky@xxxxxxxxxxxx; tom@xxxxxxxxxx; sj1557.seo@xxxxxxxxxxx;
> kiras.lee@xxxxxxxxxxx
> Subject: Re: [PATCH] ksmbd: make __dir_empty() compatible with POSIX
> 
> 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







[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux