Skip to contentSkip to conversation

fallocate: --insert-range does not work with --posix

PATCH Johannes Schauer Marin Rodrigues 1 participant 1 message Jan 16, 2025 Util-Linux package

lore
Share & tools
lore
#0 lore raw

Hi,

Steps to reproduce:

    $ fallocate -l 1024 test.img
    $ fallocate --posix --insert-range --offset=0 --length=4096 test.img
    $ ls -l test.img
    -rw-r--r-- 1 root root 4096 Jan 12 16:57 test.img

The size of test.img should be 5120 bytes and not 4096. It works fine without --posix.

This issue can also be expressed as another test:

tests/expected/misc/fallocate +1 -0
@@ -1 +1,2 @@
 384
+4480
tests/ts/misc/fallocate +3 -0
@@ -34,6 +34,9 @@ else
                && ts_skip "'${fs_type}' not supported"
 fi
 
+$TS_CMD_FALLOCATE -x -i -o 0 -l 4096 $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG
+stat -c "%s" $IMAGE >> $TS_OUTPUT 2>> $TS_ERRLOG
+
 rm -f $IMAGE
 
 ts_finalize

I also wonder why the size of --insert-range has to be 4096. If I try smaller sizes, it does not work on my machine even when not using --posix. If this is by design, maybe it should be mentioned in the man page?

I'm running Debian bookworm and reproduced this with util-linux from git.

Thanks!

cheers, josch