dirname is the address of the pathname of a directory, terminated by an ASCII NUL.
chroot() causes
dirname to become the root directory, that is, the starting point for path searches of pathnames beginning with ‘/'.
In order for a directory to become the root directory a process must have execute (search) access for that directory.
If the current working directory is not at or under the new root directory, it is silently set to the new root directory. It should be noted that, on most other systems,
chroot() has no effect on the process's current directory.
This call is restricted to the super-user.
The
fchroot() function performs the same operation on an open directory file known by the file descriptor
fd.