Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Hobin Woo <hobin.woo@samsung.com>
To: linux-cifs@vger.kernel.org
Cc: linkinjeon@kernel.org, sfrench@samba.org,
	senozhatsky@chromium.org, tom@talpey.com, sj1557.seo@samsung.com,
	kiras.lee@samsung.com, Hobin Woo <hobin.woo@samsung.com>
Subject: [PATCH] ksmbd: make __dir_empty() compatible with POSIX
Date: Tue,  3 Sep 2024 14:19:18 +0900	[thread overview]
Message-ID: <20240903051918.728540-1-hobin.woo@samsung.com> (raw)
In-Reply-To: CGME20240903051932epcas1p31c823baa892d8dc3f3e2ed8e1c073250@epcas1p3.samsung.com

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@samsung.com>
---
 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


       reply	other threads:[~2024-09-03  5:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240903051932epcas1p31c823baa892d8dc3f3e2ed8e1c073250@epcas1p3.samsung.com>
2024-09-03  5:19 ` Hobin Woo [this message]
2024-09-03  5:45   ` [PATCH] ksmbd: make __dir_empty() compatible with POSIX Steve French
2024-09-03  5:53     ` Hobin Woo
     [not found]   ` <CAKYAXd_zBESXWJ+CubrDBd0u_i9h=CimJ=6E_DxtfNLTXxRPgA@mail.gmail.com>
     [not found]     ` <005401dafdc9$18aaee00$4a00ca00$@samsung.com>
2024-09-03  6:33       ` Hobin Woo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240903051918.728540-1-hobin.woo@samsung.com \
    --to=hobin.woo@samsung.com \
    --cc=kiras.lee@samsung.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=sj1557.seo@samsung.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox