1CHDIR(2) System Calls Manual CHDIR(2)
2
3
4
6 chdir, fchdir - change current working directory
7
9 chdir(path)
10 char *path;
11
12 fchdir(fd)
13 int fd;
14
16 The path argument points to the pathname of a directory. The fd argu‐
17 ment is a file descriptor which references a directory. The chdir
18 function causes this directory to become the current working directory,
19 the starting point for path names not beginning with ``/''.
20
21 The fchdir function causes the directory referenced by fd to become the
22 current working directory, the starting point for path searches of
23 pathnames not beginning with a slahs, '/'.
24
25 In order for a directory to become the current directory, a process
26 must have execute (search) access to the directory.
27
29 Upon successful completion, a value of 0 is returned. Otherwise, a
30 value of -1 is returned and errno is set to indicate the error.
31
33 Chdir will fail and the current working directory will be unchanged if
34 one or more of the following are true:
35
36 [ENOTDIR] A component of the path prefix is not a directory.
37
38 [EINVAL] The pathname contains a character with the high-order
39 bit set.
40
41 [ENAMETOOLONG] A component of a pathname exceeded 63 characters, or an
42 entire path name exceeded 255 characters.
43
44 [ENOENT] The named directory does not exist.
45
46 [ELOOP] Too many symbolic links were encountered in translating
47 the pathname.
48
49 [EACCES] Search permission is denied for any component of the
50 path name.
51
52 [EFAULT] Path points outside the process's allocated address
53 space.
54
55 [EIO] An I/O error occurred while reading from or writing to
56 the file system.
57
58 Fchdir will fail and the current working directory will be unchanged if
59 one or more of the following are true:
60
61 [EACCES] Search permission is denied for the directory referenced
62 by the file descriptor.
63
64 [ENOTDIR] The file descriptor fd does not reference a directory.
65
66 [EBADF] The argument fd is not a valid file descriptor.
67
69 chroot(2)
70
71
72
734th Berkeley Distribution April 21, 1994 CHDIR(2)