summaryrefslogtreecommitdiffstats
path: root/sys-utils/setarch.c
diff options
context:
space:
mode:
authorSami Kerola2011-08-28 12:04:15 +0200
committerSami Kerola2011-09-10 21:33:47 +0200
commitb446402b79f5058e85e3313f0f9acb9050a9871e (patch)
tree1a04617c4eb5f7802ee01e2541e5764877b184ae /sys-utils/setarch.c
parentsetarch: use program_invocation_short_name (diff)
downloadkernel-qcow2-util-linux-b446402b79f5058e85e3313f0f9acb9050a9871e.tar.gz
kernel-qcow2-util-linux-b446402b79f5058e85e3313f0f9acb9050a9871e.tar.xz
kernel-qcow2-util-linux-b446402b79f5058e85e3313f0f9acb9050a9871e.zip
setarch: add version printing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/setarch.c')
-rw-r--r--sys-utils/setarch.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index 1469f3672..ff364bb2a 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -93,7 +93,6 @@ show_help(void)
program_invocation_short_name, !strcmp(program_invocation_short_name, "setarch") ? " <arch>" : "");
printf(_(
- " -h, --help displays this help text\n"
" -v, --verbose says what options are being switched on\n"
" -R, --addr-no-randomize disables randomization of the virtual address space\n"
" -F, --fdpic-funcptrs makes function pointers point to descriptors\n"
@@ -109,6 +108,8 @@ show_help(void)
printf(_(
" --uname-2.6 turns on UNAME26\n"));
+ printf(USAGE_HELP);
+ printf(USAGE_VERSION);
printf(_("\nFor more information see setarch(8).\n"));
exit(EXIT_SUCCESS);
@@ -120,6 +121,12 @@ show_usage(const char *s)
errx(EXIT_FAILURE, _("%s\nTry `%s --help' for more information."), s, program_invocation_short_name);
}
+static void __attribute__((__noreturn__))
+show_version(void)
+{
+ printf(UTIL_LINUX_VERSION);
+ exit(EXIT_SUCCESS);
+}
int set_arch(const char *pers, unsigned long options)
{
@@ -221,6 +228,7 @@ int main(int argc, char *argv[])
static const struct option longopts[] =
{
{ "help", 0, 0, 'h' },
+ { "version", 0, 0, 'V' },
{ "verbose", 0, 0, 'v' },
{ "addr-no-randomize", 0, 0, 'R' },
{ "fdpic-funcptrs", 0, 0, 'F' },
@@ -254,6 +262,8 @@ int main(int argc, char *argv[])
argv[0] = argv[-1]; /* for getopt_long() to get the program name */
if (!strcmp(p, "-h") || !strcmp(p, "--help"))
show_help();
+ else if (!strcmp(p, "-V") || !strcmp(p, "--version"))
+ show_version();
}
#if defined(__sparc64__) || defined(__sparc__)
if (!strcmp(p, "sparc32bash")) {
@@ -264,11 +274,14 @@ int main(int argc, char *argv[])
}
#endif
- while ((c = getopt_long(argc, argv, "+hv3BFILRSTXZ", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "+hVv3BFILRSTXZ", longopts, NULL)) != -1) {
switch (c) {
case 'h':
show_help();
break;
+ case 'V':
+ show_version();
+ break;
case 'v':
verbose = 1;
break;