CHROOT(3) Library Functions Manual CHROOT(3)

chrootchange root directory (LEGACY)

#include <unistd.h>

int chroot(const char *path);

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.

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.

The chroot() function will fail if:

Search permission is denied for a component of path .
Too many symbolic links were encountered in resolving path .
The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
A component of path does not name an existing directory or path is an empty string.
A component of the path name is not a directory.
The effective user ID does not have appropriate privileges.

The function may fail if:

Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.

None.

There is no portable use that an application could make of this interface.

None.

chdir(3) , <unistd.h> .

Derived from Issue 1 of the SVID.

February 1997 posix.fail