1 /* vi: set sw=4 ts=4: */
3 * linux32/linux64 allows for changing uname emulation.
5 * Copyright 2002 Andi Kleen, SuSE Labs.
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 //usage:#define setarch_trivial_usage
11 //usage: "personality PROG ARGS"
12 //usage:#define setarch_full_usage "\n\n"
13 //usage: "Personality may be:\n"
14 //usage: " linux32 Set 32bit uname emulation\n"
15 //usage: " linux64 Set 64bit uname emulation"
17 //usage:#define linux32_trivial_usage NOUSAGE_STR
18 //usage:#define linux32_full_usage ""
20 //usage:#define linux64_trivial_usage NOUSAGE_STR
21 //usage:#define linux64_full_usage ""
23 #include <sys/personality.h>
27 int setarch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
28 int setarch_main(int argc UNUSED_PARAM, char **argv)
32 /* Figure out what personality we are supposed to switch to ...
33 * we can be invoked as either:
34 * argv[0],argv[1] == "setarch","personality"
35 * argv[0] == "personality"
37 if (ENABLE_SETARCH && applet_name[0] == 's'
38 && argv[1] && strncpy(argv[1], "linux", 5)
40 applet_name = argv[1];
43 if (applet_name[5] == '6') /* linux64 */
45 else if (applet_name[5] == '3') /* linux32 */
54 /* Try to set personality */
55 if (personality(pers) >= 0) {
56 /* Try to execute the program */
57 BB_EXECVP(argv[0], argv);
60 bb_simple_perror_msg_and_die(argv[0]);