Let's add "Arguments:" section to the --help output and describe
{K,M,G...}iB suffixes there.
Addresses: https://github.com/karelzak/util-linux/pull/917
Co-Author: ed <ed@s5h.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
This broke compilation when HAVE_POSIX_FALLOCATE was undefined. The typo
dates to the original posix_fallocate support added in commit
833f9a7aae.
Signed-off-by: Matti Niemenmaa <matti.niemenmaa+git@iki.fi>
Based on patch from Vaclav Dolezal <vdolezal@redhat.com>, this
implementation is less invasive.
The patch adds a new while() for pread() call (so diff is mostly code
indention). The pread() is called for a real data only (addressed by
'off' and 'end') and we use SEEK_{DATA,HOLE} before the pread() to
skip already existing holes. The variables 'file_off' and 'file_end'
addresses area in the file as specified on fallocate command line.
Test:
$ truncate -s 10G testfile
$ dd if=/dev/zero of=testfile count=10 bs=1M conv=notrunc
old version:
$ time /usr/bin/fallocate --dig-holes --verbose testfile
testfile: 10 GiB (10737418240 bytes) converted to sparse holes.
real 0m3.013s
user 0m0.700s
sys 0m2.304s
new version:
$ time ./fallocate --dig-holes --verbose testfile
testfile: 10 MiB (10485760 bytes) converted to sparse holes.
real 0m0.026s
user 0m0.002s
sys 0m0.004s
The old version scans all file.
The change has minimal overhead for files without holes.
Addresses: https://github.com/karelzak/util-linux/issues/421
Co-Author: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer
Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.
Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Based on patch 83cc932d74
("fallocate: introduce an option -c to support COLLAPSE_RANGE")
This patch includes FALLOC_FL_INSERT_RANGE flag
added to Linux kernel v4.1
Thanks to Pádraig Brady for insert range definition
Signed-off-by: Fabian Frederick <fabf@skynet.be>
FALLOC_FL_KEEP_SIZE flag is generic and used in many situations,
"-n" in the error message does not make sense.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1146152
Signed-off-by: Karel Zak <kzak@redhat.com>
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed. So say so. Also make
two very similar messages equal to this one.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
This adds a concise description of a tool to its usage text.
A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Where POSIX_FADV_SEQUENTIAL and HAVE_POSIX_FADVISE are not available it
is waste of resources to have variables that are meaningful only for
posix_fadvise(). Also initialize the variables immediately to correct
values, and since cachesz is never changed mark it read only.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Recent Linux kernel supports FALLOC_FL_ZERO_RANGE in fallocate(2).
This patch adds FALLOC_FL_ZERO_RANGE support to fallocate utility,
by introducing a new option -z|--zero-range.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Introduce a new option -c (or --collapse-range) to support a new flag
FALLOC_FL_COLLAPSE_RANGE for fallocate(2). It will nullify a particular
range [offset, offset+len] by shifting extents beyond the range to the
beginning of the hole.
Cc: Lukas Czerner <lczerner@redhat.com>
Cc: Namjae Jeon <namjae.jeon@samsung.com>
Cc: Ashish Sangwan <a.sangwan@samsung.com>
Signed-off-by: Dongsu Park <dongsu.park@profitbricks.com>
Based on Pádraig Brady review:
* use is_nul() from coreutils rather then memcmp()
* always call skip_hole() (SEEK_DATA)
* fix possible overflows
Signed-off-by: Karel Zak <kzak@redhat.com>
It's more efficient to skip already known holes by SEEK_DATA (seek to
the next area with data).
Thanks to Pádraig Brady.
Signed-off-by: Karel Zak <kzak@redhat.com>
* don't use --length to specify hole size, always use stat.st_blksize
* use --offset and --length to specify offset within the file (like
another fallocate operations)
Signed-off-by: Karel Zak <kzak@redhat.com>
This option tries to detect chunk of '\0's and punch a hole, making the file
sparse in-place.
[kzak@redhat.com: - fix coding style, use xalloc.h and err.h]
Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
Signed-off-by: Karel Zak <kzak@redhat.com>
Future patches will add more calls to fallocate(), so it will be useful to have
all these tricks inside a function.
The error message when fallocate is not supported is slightly changed: the file
name is not printed as a prefix because is not available in the context of the
function. Also, to only print one of the two possible errors (as happens when
using directly exit()), an else clause was added.
Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
The functionality is already there, with --punch-hole, but the text was for the
preallocation case only.
Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
Recent Linux kernel supports FALLOC_FL_PUNCH_HOLE in fallocate(2).
This patch adds FALLOC_FL_PUNCH_HOLE support to fallocate utility,
by introducing a new option -p|--punch-hole.
[kzak@redhat.com: - fix merge conflict in fallocate.1]
Cc: Karel Zak <kzak@redhat.com>
Cc: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Solaris lacks err, errx, warn and warnx. This also means the err.h header
doesn't exist. Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>