From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 09/13] setarch: add option to list settable architectures
Date: Tue, 2 Apr 2013 20:42:53 +0100 [thread overview]
Message-ID: <1364931777-2645-10-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1364931777-2645-1-git-send-email-kerolasa@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/setarch.8 | 3 +++
sys-utils/setarch.c | 18 +++++++++++++++---
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/sys-utils/setarch.8 b/sys-utils/setarch.8
index d206f2c..c5a5368 100644
--- a/sys-utils/setarch.8
+++ b/sys-utils/setarch.8
@@ -35,6 +35,9 @@ Output version information and exit.
.I "\-\-uname\-2.6"
Causes the program to see a kernel version number beginning with 2.6.
.TP
+.I "\-\-list"
+List architectures that can be set.
+.TP
.I "\-3," "\-\-3gb"
Specifies that processes should use a maximum of 3GB of address space on systems where it is supported (ADDR_LIMIT_3GB).
.TP
diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index afa2d1b..f6c0e20 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -110,6 +110,8 @@ show_help(void)
" -3, --3gb limits the used address space to a maximum of 3 GB\n"
" --4gb ignored (for backward compatibility only)\n"
" --uname-2.6 turns on UNAME26\n"));
+ printf(_(
+ " --list list settable architectures, and exit\n"));
printf(USAGE_SEPARATOR);
printf(USAGE_HELP);
@@ -136,7 +138,7 @@ show_version(void)
}
static int
-set_arch(const char *pers, unsigned long options)
+set_arch(const char *pers, unsigned long options, int list)
{
struct utsname un;
int i;
@@ -198,6 +200,12 @@ set_arch(const char *pers, unsigned long options)
{-1, NULL, NULL}
};
+ if (list) {
+ for(i = 0; transitions[i].target_arch != NULL; i++)
+ printf("%s\n", transitions[i].target_arch);
+ return 0;
+ }
+
for(i = 0; transitions[i].perval >= 0; i++)
if(!strcmp(pers, transitions[i].target_arch))
break;
@@ -273,10 +281,14 @@ int main(int argc, char *argv[])
show_help();
else if (!strcmp(p, "-V") || !strcmp(p, "--version"))
show_version();
+ else if (!strcmp(p, "--list")) {
+ set_arch(argv[0], 0L, 1);
+ return EXIT_SUCCESS;
+ }
}
#if defined(__sparc64__) || defined(__sparc__)
if (!strcmp(p, "sparc32bash")) {
- if (set_arch(p, 0L))
+ if (set_arch(p, 0L, 0))
err(EXIT_FAILURE, _("Failed to set personality to %s"), p);
execl("/bin/bash", NULL);
err(EXIT_FAILURE, _("failed to execute %s"), "/bin/bash");
@@ -337,7 +349,7 @@ int main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (set_arch(p, options))
+ if (set_arch(p, options, 0))
err(EXIT_FAILURE, _("Failed to set personality to %s"), p);
if (!argc) {
--
1.8.2
next prev parent reply other threads:[~2013-04-02 19:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-02 19:42 [PATCH 00/13] pull: fixes in preparation to v2.23 release Sami Kerola
2013-04-02 19:42 ` [PATCH 01/13] docs: fix type in mkfs.8 Sami Kerola
2013-04-02 19:42 ` [PATCH 02/13] newgrp: use xstrdup to check allocation succeeded Sami Kerola
2013-04-02 19:42 ` [PATCH 03/13] agetty: the command does not have -h and -V options Sami Kerola
2013-04-02 19:42 ` [PATCH 04/13] dmesg: fix usage() output consistancy Sami Kerola
2013-04-02 19:42 ` [PATCH 05/13] fsfreeze: tell user when mandatory option is not specified Sami Kerola
2013-04-02 19:42 ` [PATCH 06/13] losetup: allow -j option argument to be relative path Sami Kerola
2013-04-02 19:42 ` [PATCH 07/13] lscpu: fix error message Sami Kerola
2013-04-02 19:42 ` [PATCH 08/13] partx: remove deprecated option from usage() Sami Kerola
2013-04-02 19:42 ` Sami Kerola [this message]
2013-04-05 12:04 ` [PATCH 09/13] setarch: add option to list settable architectures Karel Zak
2013-04-02 19:42 ` [PATCH 10/13] setterm: fix various color option argument lists Sami Kerola
2013-04-02 19:42 ` [PATCH 11/13] vipw: add usage() function Sami Kerola
2013-04-02 19:42 ` [PATCH 12/13] chrt: make command syntax easier to understand in usage() Sami Kerola
2013-04-02 19:42 ` [PATCH 13/13] logger: make local sockets to try both stream and datagram Sami Kerola
2013-04-05 12:10 ` [PATCH 00/13] pull: fixes in preparation to v2.23 release Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1364931777-2645-10-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox