* configure.ac, src/mkfile -> src/mkfile.in: @bindir@ should be used; doesn't work correctly currently, so commented out. * doc/coreutils.texi: fix the description of what is the fallocate actually good for. * man/mkfile.x: manpages should be generated (man/mkfile.8.xml deleted) * src/truncate.c: rename the option from --fallocate to --allocate nobody is interested in the implementation of the option.
Signed-off-by: Matej Cepl <mc...@redhat.com> --- configure.ac | 1 + doc/coreutils.texi | 8 +++-- man/mkfile.8.xml | 94 ---------------------------------------------------- man/mkfile.x | 9 +++++ src/mkfile | 81 -------------------------------------------- src/mkfile.in | 77 ++++++++++++++++++++++++++++++++++++++++++ src/truncate.c | 6 ++-- 7 files changed, 95 insertions(+), 181 deletions(-) delete mode 100644 man/mkfile.8.xml create mode 100644 man/mkfile.x delete mode 100755 src/mkfile create mode 100755 src/mkfile.in diff --git a/configure.ac b/configure.ac index 99452c8..485eb1a 100644 --- a/configure.ac +++ b/configure.ac @@ -380,6 +380,7 @@ AC_CONFIG_FILES( man/Makefile po/Makefile.in src/Makefile + src/mkfile tests/Makefile gnulib-tests/Makefile ) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index d318e8d..1a4c1a5 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -10492,11 +10492,13 @@ The program accepts the following options. Also see @ref{Common options}. @table @samp @item -a -...@itemx --fallocate +...@itemx --allocate @opindex -a -...@opindex --fallocate +...@opindex --allocate +...@opindex extents When extending file use system call @command{fallocate}, which -ensures that disk space is allocated for @var{FILE}. After a successful +ensures that disk space is allocated for @var{FILE} and ensure +that allocated blocks are contiguous. After a successful call subsequent writes in the specified files are guaranteed not to fail because of lack of disk space. diff --git a/man/mkfile.8.xml b/man/mkfile.8.xml deleted file mode 100644 index ba3d0b4..0000000 --- a/man/mkfile.8.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" - "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> -<!-- lifted from troff+man by doclifter --> -<refentry id='mkfile8'> -<!-- Copyright (c) 2007 --> -<!-- MATEJ Cepl. All rights reserved. --> -<!-- Copyright (c) 2001, 2003, 2004 --> -<!-- HATANOU Tomomi. All rights reserved. --> - -<!-- Redistribution and use in source and binary forms, with or without --> -<!-- modification, are permitted provided that the following conditions --> -<!-- are met: --> -<!-- 1. Redistributions of source code must retain the above copyright --> -<!-- notice, this list of conditions and the following disclaimer. --> -<!-- 2. Redistributions in binary form must reproduce the above copyright --> -<!-- notice, this list of conditions and the following disclaimer in the --> -<!-- documentation and/or other materials provided with the distribution. --> -<!-- @(#)mkfile.8 1.3 (HATANOU Tomomi) 2004/01/21 --> - -<info> - <date>2007-09-03</date> - <author>MatÄj Cepl <mc...@redhat.com></author> -</info> -<refmeta> -<refentrytitle>MKFILE</refentrytitle> -<manvolnum>8</manvolnum> -<refmiscinfo class='date'>2007-09-03</refmiscinfo> -<refmiscinfo class='source'>GNU</refmiscinfo> -<refmiscinfo class='manual'>GNU</refmiscinfo> -</refmeta> -<refnamediv id='name'> -<refname>mkfile</refname> -<refpurpose>create a file</refpurpose> -</refnamediv> -<!-- body begins here --> -<refsynopsisdiv id='synopsis'> -<cmdsynopsis> - <command>mkfile</command> <arg choice='opt'>-n </arg> - <arg choice='opt'>-v </arg> - <arg choice='plain'><replaceable>size</replaceable></arg> - <group choice='plain'><arg choice='plain'><replaceable>e</replaceable></arg><arg choice='plain'><replaceable>p</replaceable></arg><arg choice='plain'><replaceable>t</replaceable></arg><arg choice='plain'><replaceable>g</replaceable></arg><arg choice='plain'><replaceable>m</replaceable></arg><arg choice='plain'><replaceable>k</replaceable></arg><arg choice='plain'><replaceable>b</replaceable></arg><arg choice='plain'><replaceable>filename</replaceable></arg></group> -</cmdsynopsis> -</refsynopsisdiv> - - -<refsect1 id='description'><title>DESCRIPTION</title> -<para>creates a file named -<emphasis remap='I'>filename</emphasis> -that are suitable for use as NFS-mounted swap areas, -or as local swap areas. -The file is padded with zeros by default. -The default -<emphasis remap='I'>size</emphasis> -is in bytes, but it can be flagged as exabytes, petabytes, terabytes, gigabytes, megabytes, kilobytes, or blocks, with the e, p, t, g, m, k, or b suffixes, respectively.</para> -</refsect1> - -<refsect1 id='options'><title>OPTIONS</title> -<para>The following options are available:</para> -<variablelist remap='TP'> - <varlistentry> - <term><option>-n</option></term> - <listitem> -<para>Create an empty file. -The size is noted, but disk blocks are not allocated -until data is written to them.</para> - </listitem> - </varlistentry> - <varlistentry> - <term><option>-v</option></term> - <listitem> -<para>Verbose. -Report the names and sizes of created files.</para> - - </listitem> - </varlistentry> -</variablelist> -</refsect1> - -<refsect1 id='see_also'><title>SEE ALSO</title> -<para><citerefentry><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry>, -<citerefentry><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry>,</para> -</refsect1> - -<refsect1 id='bugs'><title>BUGS</title> -<para>Option -<option>-n</option> -is not tested well.</para> -</refsect1> - -<refsect1 id='history'><title>HISTORY</title> -<para>A command first appeared in SunOS.</para> -</refsect1> -</refentry> diff --git a/man/mkfile.x b/man/mkfile.x new file mode 100644 index 0000000..bf1655b --- /dev/null +++ b/man/mkfile.x @@ -0,0 +1,9 @@ +[NAME] +mkfile \- create a new file +[DESCRIPTION] +.\" Add any additional description here +[SEE ALSO] +swapon(8), dd(1), truncate(2), ftruncate(2) + +[HISTORY] +A command first appeared in SunOS. diff --git a/src/mkfile b/src/mkfile deleted file mode 100755 index 0c020ad..0000000 --- a/src/mkfile +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# the original manpage is on -# http://developer.apple.com/documentation/Darwin/Reference\ -# /ManPages/man8/mkfile.8.html -# and -# http://docs.sun.com/app/docs/doc/819-2240/6n4htdnbv?a=view -SPARSE=0 -VERBOSE=0 -OPTFLAGS="" -VERSION="1.0" -COMMANDNAME="$0" - -function usage() { - cat - <<\EOF -Usage: mkfile OPTION... SIZE FILE -Create a new FILE of the specified size (possibly with sparse file) that is -suitable for use as NFS-mounted swap areas, or as local swap areas. - -A FILE argument that does exist is overwritten. - -Mandatory arguments to long options are mandatory for short options too. - -n create a sparse file (the size is noted, but disk blocks are not - allocated until data is written to them) - -v be verbose (report the size of the file created) - -h display this help and exit - -SIZE is a number which may be followed by one of the following suffixes: -KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. - -SIZE may also be prefixed by one of the following modifying characters: -`+' extend by, `-' reduce by, `<' at most, `>' at least, -`/' round down to multiple of, `%' round up to multiple of. - -SEE ALSO -swapon(8) - -HISTORY -A command first appeared in SunOS. - -Report truncate bugs to bug-coreutils@gnu.org -GNU coreutils home page: <http://www.gnu.org/software/coreutils/> -General help using GNU software: <http://www.gnu.org/gethelp/> -Report mkfile translation bugs to <http://translationproject.org/team/> -EOF -} - -while getopts ":vnh" OPTION ; do - case $OPTION in - v) - VERBOSE=1 - ;; - n) - SPARSE=1 - ;; - h) - usage - exit 0 - ;; - *) - usage - exit 1 - ;; - esac -done - -if [ $SPARSE -eq 0 ] ; then - OPTFLAGS=$OPTFLAGS"-a " -fi - -shift $(($OPTIND - 1)) -SIZE="$1" - -shift 1 -FILE="$1" - -truncate $OPTFLAGS $SIZE $FILE -RET=$? - -if [ $RET -eq 0 ] &&Â [ $VERBOSE -eq 1 ] ; then - echo >&2 "Created file $FILE of the size "$(stat --format="%s" $FILE)"." -fi diff --git a/src/mkfile.in b/src/mkfile.in new file mode 100755 index 0000000..6f4ad48 --- /dev/null +++ b/src/mkfile.in @@ -0,0 +1,77 @@ +#!/bin/bash +# the original manpage is on +# http://developer.apple.com/documentation/Darwin/Reference\ +# /ManPages/man8/mkfile.8.html +# and +# http://docs.sun.com/app/docs/doc/819-2240/6n4htdnbv?a=view +SPARSE=0 +VERBOSE=0 +OPTFLAGS="" +VERSION="1.0" +COMMANDNAME="$0" + +function usage() { + cat - <<\EOF +Usage: mkfile OPTION... SIZE FILE +Create a new FILE of the specified size (possibly with sparse file) that is +suitable for use as NFS-mounted swap areas, or as local swap areas. + +A FILE argument that does exist is overwritten. + +Mandatory arguments to long options are mandatory for short options too. + -n create a sparse file (the size is noted, but disk blocks are not + allocated until data is written to them) + -v be verbose (report the size of the file created) + -h display this help and exit + +SIZE is a number which may be followed by one of the following suffixes: +KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. + +SIZE may also be prefixed by one of the following modifying characters: +`+' extend by, `-' reduce by, `<' at most, `>' at least, +`/' round down to multiple of, `%' round up to multiple of. + +Report truncate bugs to bug-coreutils@gnu.org +GNU coreutils home page: <http://www.gnu.org/software/coreutils/> +General help using GNU software: <http://www.gnu.org/gethelp/> +Report mkfile translation bugs to <http://translationproject.org/team/> +EOF +} + +while getopts ":vnh" OPTION ; do + case $OPTION in + v) + VERBOSE=1 + ;; + n) + SPARSE=1 + ;; + h) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac +done + +if [ $SPARSE -eq 0 ] ; then + OPTFLAGS=$OPTFLAGS"-a " +fi + +shift $(($OPTIND - 1)) +SIZE="$1" + +shift 1 +FILE="$1" + +...@bindir@/truncate $OPTFLAGS $SIZE $FILE +# should I use http://tinyurl.com/amkydq ??? +/usr/bin/truncate $OPTFLAGS $SIZE $FILE +RET=$? + +if [ $RET -eq 0 ] &&Â [ $VERBOSE -eq 1 ] ; then + echo >&2 "Created file $FILE of the size "$(stat --format="%s" $FILE)"." +fi diff --git a/src/truncate.c b/src/truncate.c index 6eaeac0..b7dcf9c 100644 --- a/src/truncate.c +++ b/src/truncate.c @@ -57,7 +57,7 @@ static bool fallocate_mode; static struct option const longopts[] = { {"no-create", no_argument, NULL, 'c'}, {"io-blocks", no_argument, NULL, 'o'}, - {"fallocate", no_argument, NULL, 'a'}, + {"allocate", no_argument, NULL, 'a'}, {"reference", required_argument, NULL, 'r'}, {"size", required_argument, NULL, 's'}, {GETOPT_HELP_OPTION_DECL}, @@ -117,7 +117,7 @@ reads as zero bytes.\n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ - -a, --fallocate when extending a file use fallocate.\n\ + -a, --allocate when extending a file use fallocate.\n\ "), stdout); fputs (_("\ -c, --no-create do not create any files\n\ @@ -237,7 +237,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) int ret = 0; if ((ret = posix_fallocate (fd, 0, nsize)) != 0) { - error (0, ret, _("cannot fallocate size %d for file %s"), nsize, + error (0, ret, _("cannot allocate size %d for file %s"), nsize, quote (fname)); return 1; } -- 1.6.0.6 _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils