chroot(2) chroot(2)
NAME
chroot - change root directory
SYNOPSIS
#include <unistd.h>
int chroot(const char *path);
DESCRIPTION
path points to a pathname naming a directory. chroot() causes the
named directory to become the root directory, the starting point for
path searches for pathnames beginning with /. The working directory of
the process is unaffected by the chroot() system call.
The effective user ID of the process must be superuser 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.
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
chroot() will fail and the root directory will remain unchanged if one
or more of the following apply:
ELOOP Too many symbolic links were encountered in translating
path.
ENAMETOOLONG The length of the path argument exceeds PATHMAX or the
length of a path component exceeds NAMEMAX.
ENAMETOOLONG Pathname resolution of a symbolic link produced an
intermediate result whose length exceeds PATHMAX.
EFAULT path points outside the allocated address space of the
process.
EINTR A signal was caught during the chroot() system call.
EMULTIHOP Components of path require hopping to multiple remote
machines.
ENOLINK path points to a remote machine and the link to that
machine is no longer active.
ENOTDIR Any component of the pathname is not a directory.
ENOENT The named directory does not exist or is a null path-
name.
Page 1 Reliant UNIX 5.44 Printed 11/98
chroot(2) chroot(2)
EPERM The effective user ID is not superuser.
RESULT
Upon successful completion, a value of 0 is returned. Otherwise, a
value of -1 is returned and errno is set to indicate the error.
SEE ALSO
chdir(2), unistd(4).
Page 2 Reliant UNIX 5.44 Printed 11/98