summaryrefslogtreecommitdiffstats
path: root/sys-utils/pivot_root.c
diff options
context:
space:
mode:
authorKarel Zak2008-11-19 11:07:58 +0100
committerKarel Zak2008-11-19 12:38:43 +0100
commit5947572d5e527b842210e67d07e53eed5d95fbb2 (patch)
tree53b6e80c2280325d069cc3972d64e98345cfb568 /sys-utils/pivot_root.c
parentlosetup: add warning about read-only mode (diff)
downloadkernel-qcow2-util-linux-5947572d5e527b842210e67d07e53eed5d95fbb2.tar.gz
kernel-qcow2-util-linux-5947572d5e527b842210e67d07e53eed5d95fbb2.tar.xz
kernel-qcow2-util-linux-5947572d5e527b842210e67d07e53eed5d95fbb2.zip
build-sys: move pivot_root(8) to sys-utils
This patch moves pivot_root.{8,c) from mount/ to sys-utils/ directory. There is not ant relation between pivot_root source code and the rest of code in the mount. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/pivot_root.c')
-rw-r--r--sys-utils/pivot_root.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sys-utils/pivot_root.c b/sys-utils/pivot_root.c
new file mode 100644
index 000000000..ba2dbbed0
--- /dev/null
+++ b/sys-utils/pivot_root.c
@@ -0,0 +1,32 @@
+/* pivot_root.c - Change the root file system */
+
+/* Written 2000 by Werner Almesberger */
+
+#include <stdio.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#define pivot_root(new_root,put_old) syscall(SYS_pivot_root,new_root,put_old)
+
+#if 0
+/*
+ * With kernelheaders 2.3.41 or later, and ancient libc, try the following.
+ */
+#include <errno.h>
+#include <linux/unistd.h>
+static
+_syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
+#endif
+
+int main(int argc, const char **argv)
+{
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s new_root put_old\n", argv[0]);
+ return 1;
+ }
+ if (pivot_root(argv[1],argv[2]) < 0) {
+ perror("pivot_root");
+ return 1;
+ }
+ return 0;
+}