]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture: Fix samba3.smb2.name-mangling on btrfs
authorAndreas Schneider <asn@samba.org>
Thu, 28 Nov 2024 14:52:03 +0000 (15:52 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 29 Nov 2024 14:09:35 +0000 (14:09 +0000)
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>
source4/torture/smb2/mangle.c

index 09097ee6d78fea6c40c836134c765261a664c46d..09eddd265565205be31e6cce8327b6449b69b14b 100644 (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            = "*";