Penguin
Blame: pivot_root(2)
EditPageHistoryDiffInfoLikePages
Annotated edit history of pivot_root(2) version 8, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
5 PerryLorier 2 pivot_root - change the root file system
1 perry 3
4 !!SYNOPSIS
5 PerryLorier 5 __#include <linux/unistd.h>__
1 perry 6
5 PerryLorier 7 ___syscall2(int,pivot_root,const char *,new_root,const char *,put_old)__
1 perry 8
5 PerryLorier 9 __int pivot_root(const char *__''new_root''__, const char *__''put_old''__);__
1 perry 10
11 !!DESCRIPTION
5 PerryLorier 12 pivot_root(2) moves the root file system of the current process to the directory ''put_old'' and makes ''new_root'' the new root file system of the current process.
1 perry 13
5 PerryLorier 14 The typical use of __pivot_root__ is during system startup, when the system mounts a temporary root file system (e.g. an __initrd__), then mounts the real root file
15 system, and eventually turns the latter into the current root of all relevant processes or threads.
1 perry 16
5 PerryLorier 17 __pivot_root__ may or may not change the current root and the current working directory (cwd) of any processes or threads which use the old root directory. The caller of
18 __pivot_root__ must ensure that processes with root or cwd at the old root operate correctly in either case. An easy way to ensure this is to change their root and cwd to
19 ''new_root'' before invoking __pivot_root__.
1 perry 20
5 PerryLorier 21 The paragraph above is intentionally vague because the implementation of __pivot_root__ may change in the future. At the time of writing, __pivot_root__ changes
22 root and cwd of each process or thread to ''new_root'' if they point to the old root directory. This is necessary in order to prevent kernel threads from keeping the old root directory busy with their root and cwd, even if they never access the file system in any way. In the future, there may be a mechanism for kernel threads to explicitly relinquish any access to the file system, such that this fairly intrusive mechanism can be removed from __pivot_root__.
1 perry 23
5 PerryLorier 24 Note that this also applies to the current process: __pivot_root__ may or may not affect its cwd. It is therefore recommended to call __chdir(__
1 perry 25 immediately after __pivot_root__.
26
5 PerryLorier 27 The following restrictions apply to ''new_root'' and ''put_old'':
1 perry 28
5 PerryLorier 29 * They must be directories.
30 * ''new_root'' and ''put_old'' must not be on the same file system as the current root.
31 * ''put_old'' must be underneath ''new_root'', i.e. adding a non-zero number of __/..__ to the string pointed to by ''put_old'' must yield the same directory as ''new_root''.
32 * No other file system may be mounted on ''put_old''.
1 perry 33
8 PerryLorier 34 See also pivot_root(8) for additional usage examples.
1 perry 35
5 PerryLorier 36 If the current root is not a mount point (e.g. after chroot(2) or __pivot_root__, see also below), not the old root directory, but the mount point of that file system is mounted on ''put_old''.
1 perry 37
38 !!NOTES
5 PerryLorier 39 ''new_root'' does not have to be a mount point. In this case, __/proc/mounts__ will show the mount point of the file system containing ''new_root'' as root (__/__).
1 perry 40 !!RETURN VALUE
5 PerryLorier 41 On success, zero is returned. On error, -1 is returned, and ''errno'' is set appropriately.
1 perry 42
43 !!ERRORS
6 PerryLorier 44 __pivot_root__ may return (in ''errno'') any of the errors returned by stat(2). Additionally, it may return:
1 perry 45
5 PerryLorier 46 ;[EBUSY]: ''new_root'' or ''put_old'' are on the current root file system, or a file system is already mounted on ''put_old''.
47 ;[EINVAL]: ''put_old'' is not underneath ''new_root''.
48 ;[ENOTDIR]: ''new_root'' or ''put_old'' is not a directory.
7 PerryLorier 49 ;[EPERM]: The current process does not have the administrator capability.
1 perry 50
51 !!BUGS
5 PerryLorier 52 __pivot_root__ should not have to change root and cwd of all other processes in the system.
1 perry 53
5 PerryLorier 54 Some of the more obscure uses of __pivot_root__ may quickly lead to insanity.
1 perry 55
56 !!CONFORMING TO
5 PerryLorier 57 __pivot_root__ is Linux-specific and hence is not portable.
1 perry 58
59 !!HISTORY
5 PerryLorier 60 __pivot_root__ was introduced in Linux 2.3.41.
1 perry 61
62 !!SEE ALSO
5 PerryLorier 63 chdir(2), chroot(2), initrd(4), pivot_root(8), stat(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 9 times)