]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
punch-alternating: prevent punching all extents
authorCarlos Maiolino <cem@kernel.org>
Sun, 21 Dec 2025 10:24:50 +0000 (11:24 +0100)
committerZorro Lang <zlang@kernel.org>
Wed, 31 Dec 2025 18:47:37 +0000 (02:47 +0800)
If by any chance the punch size is >= the interval, we end up punching
everything, zeroing out the file.

As this is not a tool to dealloc the whole file, so force the user to
pass a configuration that won't cause it to happen.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/punch-alternating.c

index d2bb4b6a2276c9e6cfb434bf3c43a59cbe84b07f..c555b48d8591fd1a16dddf5ba09c5033b68e5976 100644 (file)
@@ -88,6 +88,11 @@ int main(int argc, char *argv[])
                usage(argv[0]);
        }
 
+       if (size >= interval) {
+               printf("Interval must be > size\n");
+               usage(argv[0]);
+       }
+
        if (optind != argc - 1)
                usage(argv[0]);