BSD 4_4 development
[unix-history] / usr / share / man / cat2 / chdir.0
CHDIR(2) BSD Programmer's Manual CHDIR(2)
N\bNA\bAM\bME\bE
c\bch\bhd\bdi\bir\br, f\bfc\bch\bhd\bdi\bir\br - change current working directory
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\bun\bni\bis\bst\btd\bd.\b.h\bh>\b>
_\bi_\bn_\bt
c\bch\bhd\bdi\bir\br(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh);
_\bi_\bn_\bt
f\bfc\bch\bhd\bdi\bir\br(_\bi_\bn_\bt _\bf_\bd);
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
The _\bp_\ba_\bt_\bh arument points to the pathname of a directory. The c\bch\bhd\bdi\bir\br()
function causes the named directory to become the current working direc-
tory, that is, the starting point for path searches of pathnames not be-
ginning with a slash, `/'.
The f\bfc\bch\bhd\bdi\bir\br() function causes the directory referenced by _\bf_\bd to become the
current working directory, the starting point for path searches of path-
names 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.
R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
Upon successful completion, a value of 0 is returned. Otherwise, a value
of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
E\bER\bRR\bRO\bOR\bRS\bS
C\bCh\bhd\bdi\bir\br() will fail and the current working directory will be unchanged if
one or more of the following are true:
[ENOTDIR] A component of the path prefix is not a directory.
[EINVAL] The pathname contains a character with the high-order bit
set.
[ENAMETOOLONG]
A component of a pathname exceeded 255 characters, or an
entire path name exceeded 1023 characters.
[ENOENT] The named directory does not exist.
[ELOOP] Too many symbolic links were encountered in translating the
pathname.
[EACCES] Search permission is denied for any component of the path
name.
[EFAULT] _\bP_\ba_\bt_\bh points outside the process's allocated address space.
[EIO] An I/O error occurred while reading from or writing to the
file system.
F\bFc\bch\bhd\bdi\bir\br() 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 argument _\bf_\bd is not a valid file descriptor.
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
chroot(2)
S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
C\bCh\bhd\bdi\bir\br() is expected to conform to IEEE Std 1003.1-1988 (``POSIX'').
H\bHI\bIS\bST\bTO\bOR\bRY\bY
The f\bfc\bch\bhd\bdi\bir\br() function call appeared in 4.2BSD.
4th Berkeley Distribution June 4, 1993 2