Thanks for following this up Matej.
Some very quick comments below. Will review more thoroughly when I've time.
Matej Cepl wrote:
> doc/coreutils.texi | 9 ++++
> man/mkfile.8.xml | 94
> +++++++++++++++++++++++++++++++++++++++++
> src/mkfile | 81 +++++++++++++++++++++++++++++++++++
> src/truncate.c | 48 +++++++++++++++------
> tests/Makefile.am | 1 +
> tests/misc/truncate-fallocate | 57 +++++++++++++++++++++++++
> tests/misc/truncate-mkfile | 72 +++++++++++++++++++++++++++++++
> +++ b/doc/coreutils.texi
>
> +...@item -a
> +...@itemx --fallocate
> +...@opindex -a
> +...@opindex --fallocate
> +When extending file use system call @command{fallocate}, which
> +ensures that disk space is allocated for @var{FILE}. After a successful
> +call subsequent writes in the specified files are guaranteed
> +not to fail because of lack of disk space.
I would mention that the main reason for this call is
to ensure blocks are contiguous. I.E. that as well as efficiently creating
the file, subsequent use may be more efficient.
I'd probably add "extents" to the index.
> +++ b/man/mkfile.8.xml
probably better to stick with the current coreutils man format
(auto generated from --help).
> --- a/src/truncate.c
> +++ b/src/truncate.c
> + {"fallocate", no_argument, NULL, 'a'},
How about just --allocate ?
That is the functionality exported.
Whether it's implemented using fallocate(), posix_fallocate()
or read(/dev/zero); write, is then an implementation detail.
> + /* posix_fallocate() is available since glibc 2.1.94.
> + * fallocate is in Linux since kernel 2.6.23.
> + */
> + if (fallocate_mode)
> + {
> + int ret = 0;
> + if ((ret = posix_fallocate (fd, 0, nsize)) != 0)
what if this function is not available?
> +++ b/tests/misc/truncate-fallocate
> +truncate -a -s $TESTSIZE $TESTFILE || fail=1
> +
> +if [ ! $fail -eq 1 ] ; then
> + size=$(stat --format="%s" $TESTFILE)
> + if [ "$(($size - 204800))" -gt 1024 ] ; then
so fallocate() rounds up to next multiple of block size?
That could be determined exactly.
Should we warn if user specifies a size that's not a multiple?
cheers,
Pádraig.
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils