929
|
1 /* pivot_root.c - edit system mount tree
|
|
2 *
|
|
3 * Copyright 2012 Rob Landley <rob@landley.net>
|
|
4
|
|
5 USE_PIVOT_ROOT(NEWTOY(pivot_root, "<2>2", TOYFLAG_USR|TOYFLAG_BIN))
|
|
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
|
|
25 #include <linux/unistd.h>
|
|
26
|
|
27 void pivot_root_main(void)
|
|
28 {
|
|
29 if (syscall(__NR_pivot_root, toys.optargs[0], toys.optargs[1]))
|
|
30 perror_exit("'%s' -> '%s'", toys.optargs[0], toys.optargs[1]);
|
|
31 }
|