diff options
author | Mike Frysinger <vapier@gentoo.org> | 2006-02-21 04:26:52 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2006-02-21 04:26:52 +0000 |
commit | 0a6b0bfa7a821b594d237611e3f1effb1b3692fc (patch) | |
tree | 5313b93950024acfa71e58b53375957199ab9586 | |
parent | ea6360e3938d016b2dfa6d0cbc9c9577070dca75 (diff) | |
download | busybox-w32-0a6b0bfa7a821b594d237611e3f1effb1b3692fc.tar.gz busybox-w32-0a6b0bfa7a821b594d237611e3f1effb1b3692fc.tar.bz2 busybox-w32-0a6b0bfa7a821b594d237611e3f1effb1b3692fc.zip |
add setarch/linux32/linux64 applet
-rw-r--r-- | include/applets.h | 7 | ||||
-rw-r--r-- | include/usage.h | 7 | ||||
-rw-r--r-- | util-linux/Config.in | 9 | ||||
-rw-r--r-- | util-linux/Makefile.in | 1 | ||||
-rw-r--r-- | util-linux/setarch.c | 54 |
5 files changed, 78 insertions, 0 deletions
diff --git a/include/applets.h b/include/applets.h index 6eb5cfd5f..e952ac44f 100644 --- a/include/applets.h +++ b/include/applets.h | |||
@@ -378,6 +378,10 @@ | |||
378 | #ifdef CONFIG_FEATURE_INITRD | 378 | #ifdef CONFIG_FEATURE_INITRD |
379 | APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT, _BB_SUID_NEVER) | 379 | APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT, _BB_SUID_NEVER) |
380 | #endif | 380 | #endif |
381 | #ifdef CONFIG_SETARCH | ||
382 | APPLET_NOUSAGE("linux32", setarch_main, _BB_DIR_BIN, _BB_SUID_NEVER) | ||
383 | APPLET_NOUSAGE("linux64", setarch_main, _BB_DIR_BIN, _BB_SUID_NEVER) | ||
384 | #endif | ||
381 | #ifdef CONFIG_LN | 385 | #ifdef CONFIG_LN |
382 | APPLET(ln, ln_main, _BB_DIR_BIN, _BB_SUID_NEVER) | 386 | APPLET(ln, ln_main, _BB_DIR_BIN, _BB_SUID_NEVER) |
383 | #endif | 387 | #endif |
@@ -586,6 +590,9 @@ | |||
586 | #ifdef CONFIG_SEQ | 590 | #ifdef CONFIG_SEQ |
587 | APPLET(seq, seq_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) | 591 | APPLET(seq, seq_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) |
588 | #endif | 592 | #endif |
593 | #ifdef CONFIG_SETARCH | ||
594 | APPLET(setarch, setarch_main, _BB_DIR_BIN, _BB_SUID_NEVER) | ||
595 | #endif | ||
589 | #ifdef CONFIG_SETCONSOLE | 596 | #ifdef CONFIG_SETCONSOLE |
590 | APPLET(setconsole, setconsole_main, _BB_DIR_SBIN, _BB_SUID_NEVER) | 597 | APPLET(setconsole, setconsole_main, _BB_DIR_SBIN, _BB_SUID_NEVER) |
591 | #endif | 598 | #endif |
diff --git a/include/usage.h b/include/usage.h index 22beeadf3..63cd79f0e 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -1626,6 +1626,13 @@ | |||
1626 | "\t\treached.\n" \ | 1626 | "\t\treached.\n" \ |
1627 | "\t-h, -?\tDisplay this help message\n" | 1627 | "\t-h, -?\tDisplay this help message\n" |
1628 | 1628 | ||
1629 | #define setarch_trivial_usage \ | ||
1630 | "<personality> <program> [args ...]" | ||
1631 | #define setarch_full_usage \ | ||
1632 | "Personality may be:\n" \ | ||
1633 | "\tlinux32\tSet 32bit uname emulation\n" \ | ||
1634 | "\tlinux64\tSet 64bit uname emulation" | ||
1635 | |||
1629 | #define ln_trivial_usage \ | 1636 | #define ln_trivial_usage \ |
1630 | "[OPTION] TARGET... LINK_NAME|DIRECTORY" | 1637 | "[OPTION] TARGET... LINK_NAME|DIRECTORY" |
1631 | #define ln_full_usage \ | 1638 | #define ln_full_usage \ |
diff --git a/util-linux/Config.in b/util-linux/Config.in index fbcf62476..28292bd40 100644 --- a/util-linux/Config.in +++ b/util-linux/Config.in | |||
@@ -354,6 +354,15 @@ config CONFIG_READPROFILE | |||
354 | help | 354 | help |
355 | This allows you to parse /proc/profile for basic profiling. | 355 | This allows you to parse /proc/profile for basic profiling. |
356 | 356 | ||
357 | config CONFIG_SETARCH | ||
358 | bool "setarch" | ||
359 | default n | ||
360 | help | ||
361 | The linux32 utility is used to create a 32bit environment for the | ||
362 | specified program (usually a shell). It only makes sense to have | ||
363 | this util on a system that supports both 64bit and 32bit userland | ||
364 | (like amd64/x86, ppc64/ppc, sparc64/sparc, etc...). | ||
365 | |||
357 | config CONFIG_SWAPONOFF | 366 | config CONFIG_SWAPONOFF |
358 | bool "swaponoff" | 367 | bool "swaponoff" |
359 | default n | 368 | default n |
diff --git a/util-linux/Makefile.in b/util-linux/Makefile.in index 90100aceb..423d4b6c0 100644 --- a/util-linux/Makefile.in +++ b/util-linux/Makefile.in | |||
@@ -33,6 +33,7 @@ UTILLINUX-$(CONFIG_FEATURE_MOUNT_NFS) +=nfsmount.o | |||
33 | UTILLINUX-$(CONFIG_PIVOT_ROOT) +=pivot_root.o | 33 | UTILLINUX-$(CONFIG_PIVOT_ROOT) +=pivot_root.o |
34 | UTILLINUX-$(CONFIG_RDATE) +=rdate.o | 34 | UTILLINUX-$(CONFIG_RDATE) +=rdate.o |
35 | UTILLINUX-$(CONFIG_READPROFILE) +=readprofile.o | 35 | UTILLINUX-$(CONFIG_READPROFILE) +=readprofile.o |
36 | UTILLINUX-$(CONFIG_SETARCH) +=setarch.o | ||
36 | UTILLINUX-$(CONFIG_SWAPONOFF) +=swaponoff.o | 37 | UTILLINUX-$(CONFIG_SWAPONOFF) +=swaponoff.o |
37 | UTILLINUX-$(CONFIG_SWITCH_ROOT) +=switch_root.o | 38 | UTILLINUX-$(CONFIG_SWITCH_ROOT) +=switch_root.o |
38 | UTILLINUX-$(CONFIG_UMOUNT) +=umount.o | 39 | UTILLINUX-$(CONFIG_UMOUNT) +=umount.o |
diff --git a/util-linux/setarch.c b/util-linux/setarch.c new file mode 100644 index 000000000..3543eb6a2 --- /dev/null +++ b/util-linux/setarch.c | |||
@@ -0,0 +1,54 @@ | |||
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 | * This file is subject to the GNU General Public License v2 | ||
7 | * | ||
8 | * Licensed under GPL v2 or later, see file License for details. | ||
9 | */ | ||
10 | |||
11 | #include <stdlib.h> | ||
12 | #include <unistd.h> | ||
13 | #include <string.h> | ||
14 | #include <errno.h> | ||
15 | #include <stdio.h> | ||
16 | #include <sys/personality.h> | ||
17 | |||
18 | #include "busybox.h" | ||
19 | |||
20 | int setarch_main(int argc, char **argv) | ||
21 | { | ||
22 | int pers = -1; | ||
23 | |||
24 | /* Figure out what personality we are supposed to switch to ... | ||
25 | * we can be invoked as either: | ||
26 | * argv[0],argv[1] -> "setarch","personality" | ||
27 | * argv[0] -> "personality" | ||
28 | */ | ||
29 | retry: | ||
30 | if (!strcmp(argv[0], "linux64")) | ||
31 | pers = PER_LINUX; | ||
32 | else if (!strcmp(argv[0], "linux32")) | ||
33 | pers = PER_LINUX32; | ||
34 | else if (pers == -1 && argv[1] != NULL) { | ||
35 | pers = PER_LINUX32; | ||
36 | ++argv; | ||
37 | goto retry; | ||
38 | } | ||
39 | |||
40 | /* make user actually gave us something to do */ | ||
41 | ++argv; | ||
42 | if (argv[0] == NULL) | ||
43 | bb_show_usage(); | ||
44 | |||
45 | /* Try to set personality */ | ||
46 | if (personality(pers) < 0) | ||
47 | goto failure; | ||
48 | |||
49 | /* Try to execute the program */ | ||
50 | execvp(argv[0], argv); | ||
51 | |||
52 | failure: | ||
53 | bb_perror_msg_and_die(argv[0]); | ||
54 | } | ||