CHDIR(2) BSD Programmer's Manual CHDIR(2)
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>
c
\bch
\bhd
\bdi
\bir
\br(_
\bc_
\bo_
\bn_
\bs_
\bt _
\bc_
\bh_
\ba_
\br _
\b*_
\bp_
\ba_
\bt_
\bh);
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.
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
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
[EACCES] Search permission is denied for any component of the path
[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
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
[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
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