CHDIR(2)
NAME
chdir, chroot − change default directory
SYNOPSIS
chdir(dirname)
char *dirname;
chroot(dirname)
char *dirname;
DESCRIPTION
Dirname is the address of the pathname of a directory, terminated by a null byte. Chdir causes this directory to become the current working directory, the starting point for path names not beginning with ’/’.
Chroot sets the root directory, the starting point for path names beginning with ’/’. The call is restricted to the superuser.
RETURN VALUE
Zero is returned if the directory is changed; −1 is returned if the given name is not that of a directory or is not searchable.
DIAGNOSTICS
Chdir will fail and the current working directory will be unchanged if one or more of the following is true:
[EACCES] Search permission is denied for a component of the path name.
[EFAULT] Dirname points outside the process’s allocated address space.
[ENFILE] Insufficient system space to contain i-node.
[ENOENT] The named directory, or an element within the named path, does not exist.
[ENOTDIR] A component of the path name is not a directory.
Chroot will also fail if:
[EPERM] The user is not the superuser.
SEE ALSO
ASSEMBLER
(chdir = 12.)
sys chdir; dirname
(chroot = 61.)
sys chroot; dirname