chdir system call unix
chdir, fchdir – change current directory
int chdir(const char * path);
int fchdir(int fd);
MSDOSFS, NFS_CLIENT, UFS
path points to the path name of a directory. chdir causes the named directory to become the current working directory of the calling c_actor, the starting point for path searches for pathnames not beginning with a slash ( / ).
The fchdir function causes the directory referenced by fd to become the current working directory, the starting point for path searches for 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.
Upon successful completion both chdir , and fchdir return 0; otherwise they return -1 and set errno to indicate one of the following error conditions:
[ENOTDIR] A component of the path name is not a directory.
[ENOENT] The named directory does not exist.
[EACCES] Search permission is denied for a component of the path name.
[EFAULT] path points outside the allocated address space of the c_actor.
[ENAMETOOLONG] The length of a component of path exceeds NAME_MAX characters or the length of path exceeds PATH_MAX characters.
[ELOOP] Too many symbolic links were encountered during analysis of path .
[EIO] An I/O error occurred while reading from the file system. fchdir will fail and the current working directory will be unchanged if one or more of the following are true:
[EACCES] Search permission is denied for the directory
referenced by the file descriptor.
[ENOTDIR] The file descriptor does not reference a directory.
[EBADF] The fd argument is not a valid file descriptor
See attributes(5) for descriptions of the following attributes:
chdir is expected to conform to IEEE Std 1003.1-1988 POSIX .
The fchdir function call appeared in 4.2 BSD.