CHROOT(2) — SYSTEM CALLS
NAME
chroot − change root directory
SYNOPSIS
chroot(dirname)
char ∗dirname;
DESCRIPTION
dirname points to a path name naming a directory. chroot causes this directory to become the root directory, the starting point for path names beginning with /. The current working directory is unaffected by this call. This root directory setting is inherited across execve(2) and by all children of this process created with fork(2) calls.
The effective user ID of the process must be super-user to change the root directory.
The .. entry in the root directory is interpreted to mean the root directory itself. Thus, .. cannot be used to access files outside the subtree rooted at the root directory.
In order for a directory to become the root directory a process must have execute (search) access to the directory.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate an error.
ERRORS
chroot will fail and the root directory will be unchanged if one or more of the following are true:
ENOTDIR A component of the path prefix of dirname is not a directory.
ENOTDIR The file referred to by dirname is not a directory.
EINVAL dirname contains a byte with the high-order bit set.
ENAMETOOLONG
The length of a component of dirname exceeds 255 characters, or the length of dirname exceeds 1023 characters.
ENOENT The directory referred to by dirname does not exist.
EACCES Search permission is denied for a component of the path prefix of dirname.
EACCES Search permission is denied for the directory referred to by dirname.
ELOOP Too many symbolic links were encountered in translating dirname.
EPERM The effective user ID is not super-user.
EFAULT dirname points outside the process’s allocated address space.
EIO An I/O error occurred while reading from or writing to the file system.
SEE ALSO
Sun Release 3.2 — Last change: 16 July 1986