suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB
(the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes
KB=1000, MB=1000*1000, and so on for GB, TB, PB, EB, ZB and YB.
+
+The options \fB\-\-collapse-range\fP, \fB\-\-dig-holes\fP, \fB\-\-punch-hole\fP and
+\fB\-\-zero-range\fP are mutually exclusive.
+
.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.
to be collapsed starts at \fIoffset\fP and continues
for \fIlength\fR bytes. At the completion of the operation, the contents of
the file starting at the location offset+length will be appended at the
-location offset, and the file will be \fIlength\fR bytes smaller.
+location offset, and the file will be \fIlength\fR bytes smaller. The option
+\fB\-\-keep\-size\fR may not be specified for colapse range operation.
Available since Linux 3.15 for ext4 (only for extent-based files) and XFS.
.IP "\fB\-z, \-\-zero-range\fP"
(otherwise) required only to update metadata.
Option \fB\-\-keep\-size\fP can be specified to prevent file length
-modification. This option may not be specified at the same time as the
-\fB\-\-punch-hole\fP or \fB\-\-collapse-range\fP option.
+modification.
Available since Linux 3.14 for ext4 (only for extent-based files) and XFS.
.IP "\fB\-o, \-\-offset\fP \fIoffset\fP
# include <linux/falloc.h> /* non-libc fallback for FALLOC_FL_* flags */
#endif
+
#ifndef FALLOC_FL_KEEP_SIZE
# define FALLOC_FL_KEEP_SIZE 0x1
#endif
#include "c.h"
#include "closestream.h"
#include "xalloc.h"
+#include "optutils.h"
static int verbose;
static char *filename;
{ NULL, 0, 0, 0 }
};
+ static const ul_excl_t excl[] = { /* rows and cols in in ASCII order */
+ { 'c', 'd', 'p', 'z' },
+ { 'c', 'n' },
+ { 0 }
+ };
+ int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
+
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
while ((c = getopt_long(argc, argv, "hvVncpdzl:o:", longopts, NULL))
!= -1) {
+
+ err_exclusive_options(c, longopts, excl, excl_st);
+
switch(c) {
case 'h':
usage(stdout);
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'c':
mode |= FALLOC_FL_COLLAPSE_RANGE;
break;
- case 'p':
- mode |= FALLOC_FL_PUNCH_HOLE;
- /* fall through */
- case 'n':
- mode |= FALLOC_FL_KEEP_SIZE;
- break;
case 'd':
dig = 1;
break;
- case 'z':
- mode |= FALLOC_FL_ZERO_RANGE;
- break;
case 'l':
length = cvtnum(optarg);
break;
+ case 'n':
+ mode |= FALLOC_FL_KEEP_SIZE;
+ break;
case 'o':
offset = cvtnum(optarg);
break;
+ case 'p':
+ mode |= FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
+ break;
+ case 'z':
+ mode |= FALLOC_FL_ZERO_RANGE;
+ break;
case 'v':
verbose++;
break;
+ case 'V':
+ printf(UTIL_LINUX_VERSION);
+ return EXIT_SUCCESS;
default:
usage(stderr);
break;
}
if (dig) {
/* for --dig-holes the default is analyze all file */
- if (mode != 0)
- errx(EXIT_FAILURE,
- _("Can't use other modes with --dig-holes"));
if (length == -2LL)
length = 0;
if (length < 0)
if (optind == argc)
errx(EXIT_FAILURE, _("no filename specified."));
- if ((mode & FALLOC_FL_ZERO_RANGE) &&
- (mode & ~(FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE)))
- errx(EXIT_FAILURE, _("only --keep-size mode can be used with "
- "--zero-range"));
-
filename = argv[optind++];
if (optind != argc) {