chroot(2) CLIX chroot(2)
NAME
chroot - Changes root directory
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
int chroot(
char *path );
PARAMETERS
path Points to the directory which is to become the root directory.
DESCRIPTION
The path parameter points to a pathname naming a directory. The chroot()
function causes the named directory to become the root directory, the
starting point for path searches for pathnames beginning with /. The
user's working directory is unaffected by the chroot() function.
The effective user ID of the process must be superuser to change the root
directory.
The parent (..) 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.
EXAMPLES
To specify a root directory:
if (chroot(my_root_directory) != 0)
perror("chroot failed");
RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value
of -1 is returned and errno is set to indicate the error.
ERRORS
The chroot() function fails and the root directory will remain unchanged
if one or more of the following are true:
[ENOTDIR]
Any component of the pathname is not a directory.
2/94 - Intergraph Corporation 1
chroot(2) CLIX chroot(2)
[ENOENT]
The named directory does not exist.
[EPERM]
The effective user ID is not superuser.
[EFAULT]
The path parameter points outside the allocated address space of
the process.
[EINTR]
A signal was caught during the chroot() function.
[ENOLINK]
The path parameter points to a remote machine and the link to that
machine is no longer active.
[EMULTIHOP]
Components of path require hopping to multiple remote machines.
RELATED INFORMATION
Functions: chdir(2)
2 Intergraph Corporation - 2/94