1chdir(2) System Calls chdir(2)
2
3
4
6 chdir, fchdir - change working directory
7
9 #include <unistd.h>
10
11 int chdir(const char *path);
12
13
14 int fchdir(int fildes);
15
16
18 The chdir() and fchdir() functions cause a directory pointed to by path
19 or fildes to become the current working directory. The starting point
20 for path searches for path names not beginning with / (slash). The path
21 argument points to the path name of a directory. The fildes argument is
22 an open file descriptor of a directory.
23
24
25 For a directory to become the current directory, a process must have
26 execute (search) access to the directory.
27
29 Upon successful completion, 0 is returned. Otherwise, −1 is returned,
30 the current working directory is unchanged, and errno is set to indi‐
31 cate the error.
32
34 The chdir() function will fail if:
35
36 EACCES Search permission is denied for any component of the
37 path name.
38
39
40 EFAULT The path argument points to an illegal address.
41
42
43 EINTR A signal was caught during the execution of the chdir()
44 function.
45
46
47 EIO An I/O error occurred while reading from or writing to
48 the file system.
49
50
51 ELOOP Too many symbolic links were encountered in translating
52 path.
53
54
55 ENAMETOOLONG The length of the path argument exceeds PATH_MAX, or
56 the length of a path component exceeds NAME_MAX while
57 _POSIX_NO_TRUNC is in effect.
58
59
60 ENOENT Either a component of the path prefix or the directory
61 named by path does not exist or is a null pathname.
62
63
64 ENOLINK The path argument points to a remote machine and the
65 link to that machine is no longer active.
66
67
68 ENOTDIR A component of the path name is not a directory.
69
70
71
72 The fchdir() function will fail if:
73
74 EACCES Search permission is denied for fildes.
75
76
77 EBADF The fildes argument is not an open file descriptor.
78
79
80 EINTR A signal was caught during the execution of the fchdir()
81 function.
82
83
84 EIO An I/O error occurred while reading from or writing to the
85 file system.
86
87
88 ENOLINK The fildes argument points to a remote machine and the link
89 to that machine is no longer active.
90
91
92 ENOTDIR The open file descriptor fildes does not refer to a direc‐
93 tory.
94
95
97 See attributes(5) for descriptions of the following attributes:
98
99
100
101
102 ┌─────────────────────────────┬─────────────────────────────┐
103 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
104 ├─────────────────────────────┼─────────────────────────────┤
105 │Interface Stability │Standard │
106 ├─────────────────────────────┼─────────────────────────────┤
107 │MT-Level │Async-Signal-Safe │
108 └─────────────────────────────┴─────────────────────────────┘
109
111 chroot(2), attributes(5), standards(5)
112
113
114
115SunOS 5.11 28 Dec 1996 chdir(2)