.SH SYNOPSIS
.B fallocate
.RB [ \-n ]
+.RB [ \-p ]
.RB [ \-o
.IR offset ]
.B \-l
.IP "\fB\-n, \-\-keep-size\fP"
Do not modify the apparent length of the file. This may effectively allocate
blocks past EOF, which can be removed with a truncate.
+.IP "\fB\-p, \-\-punch-hole\fP"
+Punch holes in the file, the range should not exceed the length of the file.
.IP "\fB\-o, \-\-offset\fP \fIoffset\fP
Specifies the beginning offset of the allocation, in bytes.
.IP "\fB\-l, \-\-length\fP \fIlength\fP
# include <linux/falloc.h> /* for FALLOC_FL_* flags */
#else
# define FALLOC_FL_KEEP_SIZE 1
+# define FALLOC_FL_PUNCH_HOLE 2
#endif
#include "nls.h"
fputs(_("\nOptions:\n"), out);
fputs(_(" -h, --help this help\n"
" -n, --keep-size don't modify the length of the file\n"
+ " -p, --punch-hole punch holes in the file\n"
" -o, --offset <num> offset of the allocation, in bytes\n"
" -l, --length <num> length of the allocation, in bytes\n"), out);
static const struct option longopts[] = {
{ "help", 0, 0, 'h' },
{ "keep-size", 0, 0, 'n' },
+ { "punch-hole", 0, 0, 'p' },
{ "offset", 1, 0, 'o' },
{ "length", 1, 0, 'l' },
{ NULL, 0, 0, 0 }
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((c = getopt_long(argc, argv, "hnl:o:", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hnpl:o:", longopts, NULL)) != -1) {
switch(c) {
case 'h':
usage(stdout);
break;
+ case 'p':
+ mode |= FALLOC_FL_PUNCH_HOLE;
+ /* fall through */
case 'n':
mode |= FALLOC_FL_KEEP_SIZE;
break;