add EACCES for fchdir (directory not searchable)
[unix-history] / usr / src / lib / libc / sys / chdir.2
CommitLineData
be16c266
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
1267c1ec 5.\" @(#)chdir.2 6.6 (Berkeley) %G%
be16c266 6.\"
f313899c 7.TH CHDIR 2 ""
be16c266
KM
8.UC 4
9.SH NAME
9db609f1 10chdir, fchdir \- change current working directory
be16c266
KM
11.SH SYNOPSIS
12.nf
9726efd6
KM
13.ft B
14chdir(path)
15char *path;
16.ft R
be16c266 17.fi
e28eab18
KM
18.LP
19.nf
20.ft B
21fchdir(fd)
22int fd;
23.fi
24.ft R
be16c266 25.SH DESCRIPTION
9726efd6
KM
26.I Path
27is the pathname of a directory.
be16c266
KM
28.I Chdir
29causes this directory
30to become the current working directory,
9726efd6
KM
31the starting point for path names not beginning with ``/''.
32.PP
e28eab18
KM
33.I Fchdir
34causes the directory referenced by
35.I fd
36to become the current working directory,
37the starting point for path names not beginning with ``/''.
38.PP
9726efd6
KM
39In order for a directory to become the current directory,
40a process must have execute (search) access to the directory.
41.SH "RETURN VALUE
42Upon successful completion, a value of 0 is returned.
43Otherwise, a value of \-1 is returned and \fIerrno\fP is set to indicate
44the error.
45.SH ERRORS
46.I Chdir
47will fail and the current working directory will be unchanged if
48one or more of the following are true:
49.TP 15
50[ENOTDIR]
b5984ffe 51A component of the path prefix is not a directory.
9726efd6 52.TP 15
b5984ffe
KM
53[EINVAL]
54The pathname contains a character with the high-order bit set.
55.TP 15
56[ENAMETOOLONG]
57A component of a pathname exceeded 255 characters,
58or an entire path name exceeded 1023 characters.
9726efd6
KM
59.TP 15
60[ENOENT]
b5984ffe 61The named directory does not exist.
9726efd6 62.TP 15
b5984ffe
KM
63[ELOOP]
64Too many symbolic links were encountered in translating the pathname.
9726efd6
KM
65.TP 15
66[EACCES]
67Search permission is denied for any component of
68the path name.
69.TP 15
70[EFAULT]
71.I Path
72points outside the process's allocated address space.
fd690c8b
KM
73.TP 15
74[EIO]
75An I/O error occurred while reading from or writing to the file system.
e28eab18
KM
76.LP
77.I Fchdir
78will fail and the current working directory will be unchanged if
79one or more of the following are true:
80.TP 15
1267c1ec
KB
81[EACCES]
82Search permission is denied for the directory referenced by the
83file descriptor.
84.TP 15
e28eab18
KM
85[ENOTDIR]
86The file descriptor does not reference a directory.
87.TP 15
88EBADF
1267c1ec 89The argument
e28eab18 90.I fd
1267c1ec 91is not a valid file descriptor.
be16c266 92.SH "SEE ALSO"
9726efd6 93chroot(2)