1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

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 <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Andreas Schneider 2024-11-28 15:52:03 +01:00 committed by Andreas Schneider
parent bb92c70f0e
commit 38b8a4f223

View File

@ -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 = "*";