summaryrefslogtreecommitdiffstats
path: root/sys-utils/switch_root.c
diff options
context:
space:
mode:
authorSami Kerola2011-10-30 14:45:14 +0100
committerSami Kerola2011-10-30 14:45:14 +0100
commited8d2938f36c7094ec3ba1dca821b5ded02ba1a5 (patch)
treed382cab8e466bb2ff0eeaa5e6c4796b4476914d5 /sys-utils/switch_root.c
parentunshare: align with howto-usage-function.txt (diff)
downloadkernel-qcow2-util-linux-ed8d2938f36c7094ec3ba1dca821b5ded02ba1a5.tar.gz
kernel-qcow2-util-linux-ed8d2938f36c7094ec3ba1dca821b5ded02ba1a5.tar.xz
kernel-qcow2-util-linux-ed8d2938f36c7094ec3ba1dca821b5ded02ba1a5.zip
switch_root: align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/switch_root.c')
-rw-r--r--sys-utils/switch_root.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index f86b8c697..7c5639682 100644
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -32,7 +32,9 @@
#include <errno.h>
#include <ctype.h>
#include <dirent.h>
+
#include "c.h"
+#include "nls.h"
#ifndef MS_MOVE
#define MS_MOVE 8192
@@ -170,18 +172,17 @@ static int switchroot(const char *newroot)
return 0;
}
-static void usage(FILE *output)
+static void __attribute__((__noreturn__)) usage(FILE *output)
{
- fprintf(output, "usage: %s <newrootdir> <init> <args to init>\n",
- program_invocation_short_name);
- exit(output == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
-}
+ fputs(USAGE_HEADER, output);
+ fprintf(output, " %s [options] <newrootdir> <init> <args to init>\n",
+ program_invocation_short_name);
+ fputs(USAGE_OPTIONS, output);
+ fputs(USAGE_HELP, output);
+ fputs(USAGE_VERSION, output);
+ fprintf(output, USAGE_MAN_TAIL("switch_root(8)"));
-static void version(void)
-{
- fprintf(stdout, "%s from %s\n", program_invocation_short_name,
- PACKAGE_STRING);
- exit(EXIT_SUCCESS);
+ exit(output == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
int main(int argc, char *argv[])
@@ -190,8 +191,10 @@ int main(int argc, char *argv[])
if (argv[1] && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")))
usage(stdout);
- if (argv[1] && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-V")))
- version();
+ if (argv[1] && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-V"))) {
+ printf(UTIL_LINUX_VERSION);
+ return EXIT_SUCCESS;
+ }
if (argc < 3)
usage(stderr);