NAME
chroot — change
root directory (LEGACY)
SYNOPSIS
#include <unistd.h> int chroot(const char *path);
DESCRIPTION
The path argument points to a pathname naming a directory. The chroot() function causes the named directory to become the root directory; that is, the starting point for path searches for pathnames beginning with /. The process' working directory is unaffected by chroot() .
The process must have appropriate privileges to change the root directory.
The dot-dot entry in the root directory is interpreted to mean the root directory itself. Thus, dot-dot cannot be used to access files outside the subtree rooted at the root directory.
This interface need not be reentrant.
RETURN VALUE
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. If -1 is returned, no change is made in the root directory.
ERRORS
The chroot() function will fail if:
- [EACCES]
- Search permission is denied for a component of path .
- [ELOOP]
- Too many symbolic links were encountered in resolving path .
- [ENAMETOOLONG]
- The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
- [ENOENT]
- A component of path does not name an existing directory or path is an empty string.
- [ENOTDIR]
- A component of the path name is not a directory.
- [EPERM]
- The effective user ID does not have appropriate privileges.
The chroot() function may fail if:
- [ENAMETOOLONG]
- Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.
EXAMPLES
None.
APPLICATION USAGE
There is no portable use that an application could make of this interface.
FUTURE DIRECTIONS
None.
SEE ALSO
chdir(3) , <unistd.h> .
DERIVATION
Derived from Issue 1 of the SVID.