1 | /* vi: set sw=4 ts=4: */
|
---|
2 | /*
|
---|
3 | * linux32/linux64 allows for changing uname emulation.
|
---|
4 | *
|
---|
5 | * Copyright 2002 Andi Kleen, SuSE Labs.
|
---|
6 | *
|
---|
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
---|
8 | */
|
---|
9 |
|
---|
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"
|
---|
16 | //usage:
|
---|
17 | //usage:#define linux32_trivial_usage NOUSAGE_STR
|
---|
18 | //usage:#define linux32_full_usage ""
|
---|
19 | //usage:
|
---|
20 | //usage:#define linux64_trivial_usage NOUSAGE_STR
|
---|
21 | //usage:#define linux64_full_usage ""
|
---|
22 |
|
---|
23 | #include <sys/personality.h>
|
---|
24 |
|
---|
25 | #include "libbb.h"
|
---|
26 |
|
---|
27 | int setarch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
28 | int setarch_main(int argc UNUSED_PARAM, char **argv)
|
---|
29 | {
|
---|
30 | int pers;
|
---|
31 |
|
---|
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"
|
---|
36 | */
|
---|
37 | if (ENABLE_SETARCH && applet_name[0] == 's'
|
---|
38 | && argv[1] && strncpy(argv[1], "linux", 5)
|
---|
39 | ) {
|
---|
40 | applet_name = argv[1];
|
---|
41 | argv++;
|
---|
42 | }
|
---|
43 | if (applet_name[5] == '6') /* linux64 */
|
---|
44 | pers = PER_LINUX;
|
---|
45 | else if (applet_name[5] == '3') /* linux32 */
|
---|
46 | pers = PER_LINUX32;
|
---|
47 | else
|
---|
48 | bb_show_usage();
|
---|
49 |
|
---|
50 | argv++;
|
---|
51 | if (argv[0] == NULL)
|
---|
52 | bb_show_usage();
|
---|
53 |
|
---|
54 | /* Try to set personality */
|
---|
55 | if (personality(pers) >= 0) {
|
---|
56 | /* Try to execute the program */
|
---|
57 | BB_EXECVP(argv[0], argv);
|
---|
58 | }
|
---|
59 |
|
---|
60 | bb_simple_perror_msg_and_die(argv[0]);
|
---|
61 | }
|
---|