aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/Config.in9
-rw-r--r--util-linux/Makefile.in1
-rw-r--r--util-linux/setarch.c54
3 files changed, 64 insertions, 0 deletions
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
357config 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
357config CONFIG_SWAPONOFF 366config 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
33UTILLINUX-$(CONFIG_PIVOT_ROOT) +=pivot_root.o 33UTILLINUX-$(CONFIG_PIVOT_ROOT) +=pivot_root.o
34UTILLINUX-$(CONFIG_RDATE) +=rdate.o 34UTILLINUX-$(CONFIG_RDATE) +=rdate.o
35UTILLINUX-$(CONFIG_READPROFILE) +=readprofile.o 35UTILLINUX-$(CONFIG_READPROFILE) +=readprofile.o
36UTILLINUX-$(CONFIG_SETARCH) +=setarch.o
36UTILLINUX-$(CONFIG_SWAPONOFF) +=swaponoff.o 37UTILLINUX-$(CONFIG_SWAPONOFF) +=swaponoff.o
37UTILLINUX-$(CONFIG_SWITCH_ROOT) +=switch_root.o 38UTILLINUX-$(CONFIG_SWITCH_ROOT) +=switch_root.o
38UTILLINUX-$(CONFIG_UMOUNT) +=umount.o 39UTILLINUX-$(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
20int 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 */
29retry:
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
52failure:
53 bb_perror_msg_and_die(argv[0]);
54}