]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fallocate: add --version and align with howto-usage-function.txt
authorSami Kerola <kerolasa@iki.fi>
Sun, 18 Mar 2012 15:46:42 +0000 (16:46 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 30 Mar 2012 14:48:12 +0000 (16:48 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/fallocate.c

index 80bb0eabd7feebb2c46b52c632b36d83e96d7544..5fc13fe62f42bc85508a320b4f56d0ab3db1ba47 100644 (file)
 
 static void __attribute__((__noreturn__)) usage(FILE *out)
 {
-
-       fputs(_("\nUsage:\n"), out);
+       fputs(USAGE_HEADER, out);
        fprintf(out,
              _(" %s [options] <filename>\n"), program_invocation_short_name);
-
-       fputs(_("\nOptions:\n"), out);
-       fputs(_(" -h, --help          this help\n"
-               " -n, --keep-size     don't modify the length of the file\n"
+       fputs(USAGE_OPTIONS, out);
+       fputs(_(" -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);
-
-       fprintf(out, _("\nFor more information see fallocate(1).\n"));
+       fputs(USAGE_SEPARATOR, out);
+       fputs(USAGE_HELP, out);
+       fputs(USAGE_VERSION, out);
+       fprintf(out, USAGE_MAN_TAIL("fallocate(1)"));
 
        exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
@@ -94,6 +93,7 @@ int main(int argc, char **argv)
 
        static const struct option longopts[] = {
            { "help",      0, 0, 'h' },
+           { "version",   0, 0, 'V' },
            { "keep-size", 0, 0, 'n' },
            { "punch-hole", 0, 0, 'p' },
            { "offset",    1, 0, 'o' },
@@ -105,11 +105,14 @@ int main(int argc, char **argv)
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
 
-       while ((c = getopt_long(argc, argv, "hnpl:o:", longopts, NULL)) != -1) {
+       while ((c = getopt_long(argc, argv, "hVnpl:o:", longopts, NULL)) != -1) {
                switch(c) {
                case 'h':
                        usage(stdout);
                        break;
+               case 'V':
+                       printf(UTIL_LINUX_VERSION);
+                       return EXIT_SUCCESS;
                case 'p':
                        mode |= FALLOC_FL_PUNCH_HOLE;
                        /* fall through */