From: cem@kernel.org
To: zlang@kernel.org
Cc: linux-xfs@vger.kernel.org, djwong@kernel.org, fstests@vger.kernel.org
Subject: [PATCH] punch-alternating: prevent punching all extents
Date: Sun, 21 Dec 2025 11:24:50 +0100 [thread overview]
Message-ID: <20251221102500.37388-1-cem@kernel.org> (raw)
From: Carlos Maiolino <cem@kernel.org>
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>
---
src/punch-alternating.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/punch-alternating.c b/src/punch-alternating.c
index d2bb4b6a2276..c555b48d8591 100644
--- a/src/punch-alternating.c
+++ b/src/punch-alternating.c
@@ -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]);
--
2.52.0
next reply other threads:[~2025-12-21 10:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-21 10:24 cem [this message]
2025-12-31 18:46 ` [PATCH] punch-alternating: prevent punching all extents Zorro Lang
2026-01-02 13:36 ` Carlos Maiolino
2026-01-02 15:43 ` Zorro Lang
2026-01-05 9:51 ` Carlos Maiolino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251221102500.37388-1-cem@kernel.org \
--to=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zlang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox