]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
contrib: add support for COLLAPSE_RANGE and ZERO_RANGE to falocate program
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 18 Oct 2014 16:15:03 +0000 (12:15 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 18 Oct 2014 16:15:03 +0000 (12:15 -0400)
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
contrib/fallocate.c

index 1f9b59ad547a184627b438c8fa06b27b75d253f9..01d4af7d05c8f02e984909b55cb3472ba3c5da31 100644 (file)
@@ -36,6 +36,8 @@
 // #include <linux/falloc.h>
 #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;