Rev | Line | |
---|
[821] | 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 GPL v2 or later, see file License for details.
|
---|
| 8 | */
|
---|
| 9 |
|
---|
| 10 | #include <sys/personality.h>
|
---|
| 11 |
|
---|
[1765] | 12 | #include "libbb.h"
|
---|
[821] | 13 |
|
---|
[1765] | 14 | int setarch_main(int ATTRIBUTE_UNUSED argc, char **argv);
|
---|
[821] | 15 | int setarch_main(int ATTRIBUTE_UNUSED argc, char **argv)
|
---|
| 16 | {
|
---|
| 17 | int pers = -1;
|
---|
| 18 |
|
---|
| 19 | /* Figure out what personality we are supposed to switch to ...
|
---|
| 20 | * we can be invoked as either:
|
---|
| 21 | * argv[0],argv[1] -> "setarch","personality"
|
---|
| 22 | * argv[0] -> "personality"
|
---|
| 23 | */
|
---|
| 24 | retry:
|
---|
| 25 | if (argv[0][5] == '6') /* linux64 */
|
---|
| 26 | pers = PER_LINUX;
|
---|
| 27 | else if (argv[0][5] == '3') /* linux32 */
|
---|
| 28 | pers = PER_LINUX32;
|
---|
| 29 | else if (pers == -1 && argv[1] != NULL) {
|
---|
| 30 | pers = PER_LINUX32;
|
---|
| 31 | ++argv;
|
---|
| 32 | goto retry;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | /* make user actually gave us something to do */
|
---|
| 36 | ++argv;
|
---|
| 37 | if (argv[0] == NULL)
|
---|
| 38 | bb_show_usage();
|
---|
| 39 |
|
---|
| 40 | /* Try to set personality */
|
---|
| 41 | if (personality(pers) >= 0) {
|
---|
| 42 |
|
---|
| 43 | /* Try to execute the program */
|
---|
[1765] | 44 | BB_EXECVP(argv[0], argv);
|
---|
[821] | 45 | }
|
---|
| 46 |
|
---|
| 47 | bb_perror_msg_and_die("%s", argv[0]);
|
---|
| 48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.