aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-02-13 20:04:30 +0000
committerEric Andersen <andersen@codepoet.org>2001-02-13 20:04:30 +0000
commit6fd8c664c1bcb44429b81444be640ff08cac3702 (patch)
treea8faf540fe49e308e52e1694e00f280ac51b9192
parent3af1f88725348b15a0aa467b5734d55210bedf7c (diff)
downloadbusybox-w32-6fd8c664c1bcb44429b81444be640ff08cac3702.tar.gz
busybox-w32-6fd8c664c1bcb44429b81444be640ff08cac3702.tar.bz2
busybox-w32-6fd8c664c1bcb44429b81444be640ff08cac3702.zip
Apply a patch from Evin Robertson -- new pivot_root applet.
-Erik
-rw-r--r--Changelog6
-rw-r--r--Config.h1
-rw-r--r--applets.h3
-rw-r--r--applets/usage.c10
-rw-r--r--include/applets.h3
-rw-r--r--pivot_root.c39
-rw-r--r--usage.c10
-rw-r--r--util-linux/pivot_root.c39
8 files changed, 111 insertions, 0 deletions
diff --git a/Changelog b/Changelog
index c4be93af5..45babb7ea 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,9 @@
10.50
2 * Evin Robertson -- new pivot_root applet
3
4
5 -Erik Andersen, not yet released
6
10.49 70.49
2 8
3 * Matt Kraai -- new sort.c 9 * Matt Kraai -- new sort.c
diff --git a/Config.h b/Config.h
index 65d57d20e..c9e675093 100644
--- a/Config.h
+++ b/Config.h
@@ -74,6 +74,7 @@
74//#define BB_MT 74//#define BB_MT
75//#define BB_NSLOOKUP 75//#define BB_NSLOOKUP
76//#define BB_PING 76//#define BB_PING
77//#define BB_PIVOT_ROOT
77#define BB_POWEROFF 78#define BB_POWEROFF
78//#define BB_PRINTF 79//#define BB_PRINTF
79#define BB_PS 80#define BB_PS
diff --git a/applets.h b/applets.h
index 582b2fa38..4bd8b79e4 100644
--- a/applets.h
+++ b/applets.h
@@ -245,6 +245,9 @@ const struct BB_applet applets[] = {
245#ifdef BB_PING 245#ifdef BB_PING
246 APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage) 246 APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage)
247#endif 247#endif
248#ifdef BB_PIVOT_ROOT
249 APPLET("pivot_root", pivot_root_main, _BB_DIR_SBIN, pivot_root_usage)
250#endif
248#ifdef BB_POWEROFF 251#ifdef BB_POWEROFF
249 APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage) 252 APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage)
250#endif 253#endif
diff --git a/applets/usage.c b/applets/usage.c
index 52c0a6915..13107c6e0 100644
--- a/applets/usage.c
+++ b/applets/usage.c
@@ -1012,6 +1012,16 @@ const char ping_usage[] =
1012#endif 1012#endif
1013#endif 1013#endif
1014 1014
1015#if defined BB_PIVOT_ROOT
1016const char pivot_root_usage[] =
1017 "pivot_root new_root put_old"
1018#ifndef BB_FEATURE_TRIVIAL_HELP
1019 "\n\nMove the current root file system to put_old and make new_root\n"
1020 "the new root file system."
1021#endif
1022 ;
1023#endif
1024
1015#if defined BB_POWEROFF 1025#if defined BB_POWEROFF
1016const char poweroff_usage[] = 1026const char poweroff_usage[] =
1017 "poweroff" 1027 "poweroff"
diff --git a/include/applets.h b/include/applets.h
index 582b2fa38..4bd8b79e4 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -245,6 +245,9 @@ const struct BB_applet applets[] = {
245#ifdef BB_PING 245#ifdef BB_PING
246 APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage) 246 APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage)
247#endif 247#endif
248#ifdef BB_PIVOT_ROOT
249 APPLET("pivot_root", pivot_root_main, _BB_DIR_SBIN, pivot_root_usage)
250#endif
248#ifdef BB_POWEROFF 251#ifdef BB_POWEROFF
249 APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage) 252 APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage)
250#endif 253#endif
diff --git a/pivot_root.c b/pivot_root.c
new file mode 100644
index 000000000..92fe4aeab
--- /dev/null
+++ b/pivot_root.c
@@ -0,0 +1,39 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * pivot_root.c - Change root file system. Based on util-linux 2.10s
4 *
5 * busyboxed by Evin Robertson
6 */
7#include "busybox.h"
8#include <stdlib.h>
9#include <stdio.h>
10#include <sys/syscall.h>
11#include <linux/unistd.h>
12
13#ifndef __NR_pivot_root
14#error Sorry, but this kernel does not support the pivot_root syscall
15#endif
16
17static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
18
19
20int pivot_root_main(int argc, char **argv)
21{
22 if (argc != 3)
23 usage(pivot_root_usage);
24
25 if (pivot_root(argv[1],argv[2]) < 0)
26 perror_msg_and_die("pivot_root");
27
28 return EXIT_SUCCESS;
29
30}
31
32
33/*
34Local Variables:
35c-file-style: "linux"
36c-basic-offset: 4
37tab-width: 4
38End:
39*/
diff --git a/usage.c b/usage.c
index 52c0a6915..13107c6e0 100644
--- a/usage.c
+++ b/usage.c
@@ -1012,6 +1012,16 @@ const char ping_usage[] =
1012#endif 1012#endif
1013#endif 1013#endif
1014 1014
1015#if defined BB_PIVOT_ROOT
1016const char pivot_root_usage[] =
1017 "pivot_root new_root put_old"
1018#ifndef BB_FEATURE_TRIVIAL_HELP
1019 "\n\nMove the current root file system to put_old and make new_root\n"
1020 "the new root file system."
1021#endif
1022 ;
1023#endif
1024
1015#if defined BB_POWEROFF 1025#if defined BB_POWEROFF
1016const char poweroff_usage[] = 1026const char poweroff_usage[] =
1017 "poweroff" 1027 "poweroff"
diff --git a/util-linux/pivot_root.c b/util-linux/pivot_root.c
new file mode 100644
index 000000000..92fe4aeab
--- /dev/null
+++ b/util-linux/pivot_root.c
@@ -0,0 +1,39 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * pivot_root.c - Change root file system. Based on util-linux 2.10s
4 *
5 * busyboxed by Evin Robertson
6 */
7#include "busybox.h"
8#include <stdlib.h>
9#include <stdio.h>
10#include <sys/syscall.h>
11#include <linux/unistd.h>
12
13#ifndef __NR_pivot_root
14#error Sorry, but this kernel does not support the pivot_root syscall
15#endif
16
17static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
18
19
20int pivot_root_main(int argc, char **argv)
21{
22 if (argc != 3)
23 usage(pivot_root_usage);
24
25 if (pivot_root(argv[1],argv[2]) < 0)
26 perror_msg_and_die("pivot_root");
27
28 return EXIT_SUCCESS;
29
30}
31
32
33/*
34Local Variables:
35c-file-style: "linux"
36c-basic-offset: 4
37tab-width: 4
38End:
39*/