From 38b8a4f2232ca3e8dc4596c080df770f07fa49a8 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 28 Nov 2024 15:52:03 +0100 Subject: [PATCH] s4:torture: Fix samba3.smb2.name-mangling on btrfs If a file is removed from or added to the directory after the most recent call to opendir() or rewinddir(), whether a subsequent call to readdir() returns an entry for that file is unspecified." https://pubs.opengroup.org/onlinepubs/009604599/functions/readdir.html As it is unspecified, the different filesystems on Linux implement this differently: ext4: ./a.out opendir(foo) creat(foo/bar) readdir() loop readdir entry: bar readdir entry: .. readdir entry: . readdir() detected the newly created file `foo` btrfs: ./a.out opendir(foo) creat(foo/bar) readdir() loop readdir entry: . readdir entry: .. readdir() did not detect the newly created file `foo` Signed-off-by: Andreas Schneider Reviewed-by: Alexander Bokovoy Reviewed-by: Ralph Boehme --- source4/torture/smb2/mangle.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source4/torture/smb2/mangle.c b/source4/torture/smb2/mangle.c index 09097ee6d78..09eddd26556 100644 --- a/source4/torture/smb2/mangle.c +++ b/source4/torture/smb2/mangle.c @@ -264,6 +264,7 @@ static bool test_mangled_mask(struct torture_context *tctx, smb2_deltree(tree, dname); + /* Create dname and fname */ status = torture_smb2_testdir(tree, dname, &dh); torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "torture_smb2_testdir failed"); @@ -271,6 +272,13 @@ static bool test_mangled_mask(struct torture_context *tctx, status = torture_smb2_testfile(tree, fname, &fh); smb2_util_close(tree, fh); + smb2_util_close(tree, dh); + + /* Update the directory handle, that readdir() can see the testfile */ + status = torture_smb2_testdir(tree, dname, &dh); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "torture_smb2_testdir failed"); + ZERO_STRUCT(f); f.in.file.handle = dh; f.in.pattern = "*"; -- 2.47.3