annotate toys/other/pivot_root.c @ 944:b4faf2ae39e8

This inlines CRC64, and nothing more. The functions involved were called only once.
author Isaac Dunham <idunham@lavabit.com>
date Sat, 06 Jul 2013 11:26:15 -0500
parents 9e00446064fa
children da72fa267b7b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
929
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 /* pivot_root.c - edit system mount tree
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 *
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 * Copyright 2012 Rob Landley <rob@landley.net>
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 USE_PIVOT_ROOT(NEWTOY(pivot_root, "<2>2", TOYFLAG_USR|TOYFLAG_BIN))
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 config PIVOT_ROOT
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 bool "pivot_root"
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 default y
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 help
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 usage: pivot_root OLD NEW
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
12
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 Swap OLD and NEW filesystems (as if by simultaneous mount --move), and
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 move all processes with chdir or chroot under OLD into NEW (including
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 kernel threads) so OLD may be unmounted.
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
16
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 The directory NEW must exist under OLD. This doesn't work on initramfs,
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 which can't be moved (about the same way PID 1 can't be killed; see
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 switch_root instead).
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 */
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
21
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 #define FOR_pivot_root
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 #include "toys.h"
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
24
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 #include <linux/unistd.h>
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
26
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 void pivot_root_main(void)
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 {
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 if (syscall(__NR_pivot_root, toys.optargs[0], toys.optargs[1]))
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 perror_exit("'%s' -> '%s'", toys.optargs[0], toys.optargs[1]);
9e00446064fa Add pivot_root.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 }