Penguin
Diff: pivot_root(2)
EditPageHistoryDiffInfoLikePages

Differences between current version and predecessor to the previous major change of pivot_root(2).

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 8 Last edited on Sunday, March 16, 2003 6:32:17 pm by PerryLorier
Older page: version 4 Last edited on Tuesday, June 4, 2002 12:23:44 am by perry Revert
@@ -1,188 +1,63 @@
-PIVOT_ROOT  
-!!!PIVOT_ROOT  
-NAME  
-SYNOPSIS  
-DESCRIPTION  
-NOTES  
-RETURN VALUE  
-ERRORS  
-BUGS  
-CONFORMING TO  
-HISTORY  
-SEE ALSO  
-----  
 !!NAME 
+pivot_root - change the root file system  
  
-  
-pivot_root - change the root file system  
 !!SYNOPSIS 
+ __#include <linux/unistd.h>__  
  
+ ___syscall2(int,pivot_root,const char *,new_root,const char *,put_old)__  
  
-__#include __ 
+ __int pivot_root(const char *__''new_root''__, const char *__''put_old''__); __ 
  
-  
-___syscall2(int,pivot_root,const char *,new_root,const char  
-*,put_old)__  
-  
-  
-__int pivot_root(const char *__''new_root''__, const  
-char *__''put_old''__);__  
 !!DESCRIPTION 
+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.  
  
+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  
+system, and eventually turns the latter into the current root of all relevant processes or threads.  
  
-__pivot_root__ 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
+__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  
+ __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  
+''new_root'' before invoking __pivot_ root__
  
+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  
+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__.  
  
-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  
-system, and eventually turns the latter into the current  
-root of all relevant processes or threads.  
-  
-  
-__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  
-__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  
-''new_root'' before invoking  
-__pivot_root__.  
-  
-  
-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  
-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__.  
-  
-  
- 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(__ 
+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(__ 
 immediately after __pivot_root__. 
  
+The following restrictions apply to ''new_root'' and ''put_old'':  
  
-The following restrictions apply to ''new_root'' and  
-''put_old'':  
+* They must be directories.  
+* ''new_root'' and ''put_old'' must not be on the same file system as the current root.  
+* ''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''.  
+* No other file system may be mounted on ''put_old''.  
  
+See also pivot_root(8) for additional usage examples.  
  
--  
+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''.  
  
-  
-They must be directories.  
-  
-  
--  
-  
-  
-''new_root'' and ''put_old'' must not be on the same  
-file system as the current root.  
-  
-  
--  
-  
-  
-''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''.  
-  
-  
--  
-  
-  
-No other file system may be mounted on  
-''put_old''.  
-  
-  
-See also __pivot_root(8)__ for additional usage  
-examples.  
-  
-  
-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''.  
 !!NOTES 
-  
-  
- ''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  
- (__/__). 
+''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 (__/__). 
 !!RETURN VALUE 
+On success, zero is returned. On error, -1 is returned, and ''errno'' is set appropriately.  
  
-  
-On success, zero is returned. On error, -1 is returned, and  
-''errno'' is set appropriately.  
 !!ERRORS 
+__pivot_root__ may return (in ''errno'') any of the errors returned by stat(2). Additionally, it may return:  
  
+;[EBUSY]: ''new_root'' or ''put_old'' are on the current root file system, or a file system is already mounted on ''put_old''.  
+;[EINVAL]: ''put_old'' is not underneath ''new_root''.  
+;[ENOTDIR]: ''new_root'' or ''put_old'' is not a directory.  
+;[EPERM]: The current process does not have the administrator capability.  
  
-__pivot_root__ may return (in ''errno'') any of the  
-errors returned by __stat(2)__. Additionally, it may  
-return:  
-  
-  
-__EBUSY__  
-  
-  
-''new_root'' or ''put_old'' are on the current root  
-file system, or a file system is already mounted on  
-''put_old''.  
-  
-  
-__EINVAL__  
-  
-  
-''put_old'' is not underneath  
-''new_root''.  
-  
-  
-__ENOTDIR__  
-  
-  
-''new_root'' or ''put_old'' is not a  
-directory.  
-  
-  
-__EPERM__  
-  
-  
-The current process does not have the administrator  
-capability.  
 !!BUGS 
+__pivot_root__ should not have to change root and cwd of all other processes in the system.  
  
+Some of the more obscure uses of __pivot_root__ may quickly lead to insanity.  
  
-__pivot_root__ should not have to change root and cwd of  
-all other processes in the system.  
-  
-  
-Some of the more obscure uses of __pivot_root__ may  
-quickly lead to insanity.  
 !!CONFORMING TO 
+__pivot_root__ is Linux-specific and hence is not portable.  
  
-  
-__pivot_root__ is Linux-specific and hence is not  
-portable.  
 !!HISTORY 
+__pivot_root__ was introduced in Linux 2.3.41.  
  
-  
-__pivot_root__ was introduced in Linux  
-2.3.41.  
 !!SEE ALSO 
-  
-  
- chdir(2), chroot(2), initrd(4),  
- pivot_root(8), stat(2)  
-----  
+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.