]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-copy: use non-0 data block in copy_holes
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Tue, 29 Mar 2022 17:43:01 +0000 (19:43 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Mar 2022 19:10:43 +0000 (21:10 +0200)
Some filesystems (e.g. zfs with compression!=off, which is the default
configuration) automatically hole-punch all-zero blocks ‒ write a block
full of ones instead

src/test/test-copy.c

index 71836a307e44a64b9252bb893f7b517577386d0e..a669df644baf7450a6c5303473b73629fab058df 100644 (file)
@@ -343,7 +343,8 @@ TEST_RET(copy_holes) {
 
         assert_se(fstat(fd, &stat) >= 0);
         blksz = stat.st_blksize;
-        buf = alloca0(blksz);
+        buf = alloca_safe(blksz);
+        memset(buf, 1, blksz);
 
         /* We need to make sure to create hole in multiples of the block size, otherwise filesystems (btrfs)
          * might silently truncate/extend the holes. */