From 47a9edbd6d63d279ef2c92c63716d4dbbe40fc66 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 18 Mar 2012 17:32:18 +0100 Subject: fstrim: add --version and align with howto-usage-function.txt Signed-off-by: Sami Kerola --- sys-utils/fstrim.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'sys-utils/fstrim.c') diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c index 92f5ac428..4673e94ab 100644 --- a/sys-utils/fstrim.c +++ b/sys-utils/fstrim.c @@ -52,19 +52,18 @@ struct fstrim_range { 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" - " -o, --offset offset in bytes to discard from\n" + fputs(USAGE_OPTIONS, out); + fputs(_(" -o, --offset offset in bytes to discard from\n" " -l, --length length of bytes to discard from the offset\n" " -m, --minimum minimum extent length to discard\n" " -v, --verbose print number of discarded bytes\n"), out); - - fputs(_("\nFor more information see fstrim(8).\n"), out); - + fputs(USAGE_SEPARATOR, out); + fputs(USAGE_HELP, out); + fputs(USAGE_VERSION, out); + fprintf(out, USAGE_MAN_TAIL("fstrim(8)")); exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -77,6 +76,7 @@ int main(int argc, char **argv) static const struct option longopts[] = { { "help", 0, 0, 'h' }, + { "version", 0, 0, 'V' }, { "offset", 1, 0, 'o' }, { "length", 1, 0, 'l' }, { "minimum", 1, 0, 'm' }, @@ -91,11 +91,14 @@ int main(int argc, char **argv) memset(&range, 0, sizeof(range)); range.len = ULLONG_MAX; - while ((c = getopt_long(argc, argv, "ho:l:m:v", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "hVo:l:m:v", longopts, NULL)) != -1) { switch(c) { case 'h': usage(stdout); break; + case 'V': + printf(UTIL_LINUX_VERSION); + return EXIT_SUCCESS; case 'l': range.len = strtosize_or_err(optarg, _("failed to parse length")); -- cgit v1.2.3-55-g7522