From: Darrick J. Wong Date: Sat, 18 Oct 2014 16:15:03 +0000 (-0400) Subject: contrib: add support for COLLAPSE_RANGE and ZERO_RANGE to falocate program X-Git-Tag: v1.43-WIP-2015-05-18~155 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8467b3bec8bb35d5afd0370b2d2a2703e33dd686;p=thirdparty%2Fe2fsprogs.git contrib: add support for COLLAPSE_RANGE and ZERO_RANGE to falocate program Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- diff --git a/contrib/fallocate.c b/contrib/fallocate.c index 1f9b59ad5..01d4af7d0 100644 --- a/contrib/fallocate.c +++ b/contrib/fallocate.c @@ -36,6 +36,8 @@ // #include #define FALLOC_FL_KEEP_SIZE 0x01 #define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ +#define FALLOC_FL_COLLAPSE_RANGE 0x08 +#define FALLOC_FL_ZERO_RANGE 0x10 void usage(void) { @@ -95,7 +97,7 @@ int main(int argc, char **argv) int error; int tflag = 0; - while ((opt = getopt(argc, argv, "npl:o:t")) != -1) { + while ((opt = getopt(argc, argv, "npl:o:tzc")) != -1) { switch(opt) { case 'n': /* do not change filesize */ @@ -106,6 +108,16 @@ int main(int argc, char **argv) falloc_mode = (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE); break; + case 'c': + /* collapse range mode */ + falloc_mode = (FALLOC_FL_COLLAPSE_RANGE | + FALLOC_FL_KEEP_SIZE); + break; + case 'z': + /* zero range mode */ + falloc_mode = (FALLOC_FL_ZERO_RANGE | + FALLOC_FL_KEEP_SIZE); + break; case 'l': length = cvtnum(optarg); break;