CHDIR(2)
NAME
chdir − change current working directory
USAGE
chdir(path) char *path;
DESCRIPTION
Chdir sets path, which must be the name of a directory, as the current working directory. This becomes the starting point for resolving pathnames not beginning with a slash (/).
In order for a directory to become the current directory, a process must have execute (search) access to the directory.
RETURN VALUE
A successful chdir returns zero. Otherwise, it returns -1 and sets errno as indicated below.
ERRORS
Chdir will fail and the current working directory will not change if one or more of the following are true:
[ENOTDIR] A component of the pathname is not a directory.
[ENOENT] The directory named does not exist.
[ENOENT] The argument pathname is too long.
[EPERM] The argument contains a byte with the high-order bit set.
[EACCES] Search permission is denied for any component of the pathname.
[EFAULT] Path points outside the process’s allocated address space.
[ELOOP] The call encountered too many symbolic links in translating the pathname.