From 584aed6b02cb490f271b9eeb6b229ee0409b3302 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 18 Mar 2012 16:46:42 +0100 Subject: fallocate: add --version and align with howto-usage-function.txt Signed-off-by: Sami Kerola --- sys-utils/fallocate.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'sys-utils/fallocate.c') diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 80bb0eabd..5fc13fe62 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -55,19 +55,18 @@ static void __attribute__((__noreturn__)) usage(FILE *out) { - - fputs(_("\nUsage:\n"), out); + fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] \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 offset of the allocation, in bytes\n" " -l, --length 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 */ -- cgit v1.2.3-55-g7522