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