Mercurial > hg > toybox
annotate toys/other/pivot_root.c @ 1776:7bf68329eb3b draft default tip
Repository switched to git at https://github.com/landley/toybox
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 09 Apr 2015 02:28:32 -0500 |
parents | 57f2a26fa92c |
children |
rev | line source |
---|---|
929 | 1 /* pivot_root.c - edit system mount tree |
2 * | |
3 * Copyright 2012 Rob Landley <rob@landley.net> | |
4 | |
1775
57f2a26fa92c
To ensure that toybox can be installed alongside busybox without
Paul Barker <paul@paulbarker.me.uk>
parents:
1569
diff
changeset
|
5 USE_PIVOT_ROOT(NEWTOY(pivot_root, "<2>2", TOYFLAG_SBIN)) |
929 | 6 |
7 config PIVOT_ROOT | |
8 bool "pivot_root" | |
9 default y | |
10 help | |
11 usage: pivot_root OLD NEW | |
12 | |
13 Swap OLD and NEW filesystems (as if by simultaneous mount --move), and | |
14 move all processes with chdir or chroot under OLD into NEW (including | |
15 kernel threads) so OLD may be unmounted. | |
16 | |
17 The directory NEW must exist under OLD. This doesn't work on initramfs, | |
18 which can't be moved (about the same way PID 1 can't be killed; see | |
19 switch_root instead). | |
20 */ | |
21 | |
22 #define FOR_pivot_root | |
23 #include "toys.h" | |
24 | |
1569
da72fa267b7b
A patch against your current ToT that builds in AOSP master.
Elliott Hughes <enh@google.com>
parents:
929
diff
changeset
|
25 #include <sys/syscall.h> |
da72fa267b7b
A patch against your current ToT that builds in AOSP master.
Elliott Hughes <enh@google.com>
parents:
929
diff
changeset
|
26 #include <unistd.h> |
929 | 27 |
28 void pivot_root_main(void) | |
29 { | |
30 if (syscall(__NR_pivot_root, toys.optargs[0], toys.optargs[1])) | |
31 perror_exit("'%s' -> '%s'", toys.optargs[0], toys.optargs[1]); | |
32 } |