]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" Modified by Michael Haardt <michael@moria.de> | |
26 | .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu> | |
27 | .\" Modified 1995-04-15 by Michael Chastain <mec@shell.portal.com>: | |
28 | .\" Added 'fchdir'. Fixed bugs in error section. | |
29 | .\" Modified 1996-10-21 by Eric S. Raymond <esr@thyrsus.com> | |
30 | .\" Modified 1997-08-21 by Joseph S. Myers <jsm28@cam.ac.uk> | |
c11b1abf | 31 | .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 32 | .\" |
63121bd4 | 33 | .TH CHDIR 2 2019-08-02 "Linux" "Linux Programmer's Manual" |
fea681da MK |
34 | .SH NAME |
35 | chdir, fchdir \- change working directory | |
36 | .SH SYNOPSIS | |
37 | .B #include <unistd.h> | |
68e4db0a | 38 | .PP |
fea681da MK |
39 | .BI "int chdir(const char *" path ); |
40 | .br | |
41 | .BI "int fchdir(int " fd ); | |
68e4db0a | 42 | .PP |
cc4615cc MK |
43 | .in -4n |
44 | Feature Test Macro Requirements for glibc (see | |
45 | .BR feature_test_macros (7)): | |
46 | .in | |
68e4db0a | 47 | .PP |
cc4615cc | 48 | .BR fchdir (): |
64dd856b MK |
49 | .PD 0 |
50 | .ad l | |
51 | .RS 4 | |
16347c67 | 52 | _XOPEN_SOURCE\ >=\ 500 |
cf7fa0a1 | 53 | .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED |
cf7fa0a1 | 54 | || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L |
16347c67 | 55 | || /* Glibc up to and including 2.19: */ _BSD_SOURCE |
64dd856b MK |
56 | .RE |
57 | .ad | |
58 | .PD | |
fea681da | 59 | .SH DESCRIPTION |
e511ffb6 | 60 | .BR chdir () |
551d5b7a | 61 | changes the current working directory of the calling process to the |
ee62201f | 62 | directory specified in |
fea681da MK |
63 | .IR path . |
64 | .PP | |
e511ffb6 | 65 | .BR fchdir () |
fea681da | 66 | is identical to |
e511ffb6 | 67 | .BR chdir (); |
fea681da MK |
68 | the only difference is that the directory is given as an |
69 | open file descriptor. | |
47297adb | 70 | .SH RETURN VALUE |
c13182ef MK |
71 | On success, zero is returned. |
72 | On error, \-1 is returned, and | |
fea681da MK |
73 | .I errno |
74 | is set appropriately. | |
75 | .SH ERRORS | |
9ee4a2b6 | 76 | Depending on the filesystem, other errors can be returned. |
c13182ef | 77 | The more |
fea681da | 78 | general errors for |
e511ffb6 | 79 | .BR chdir () |
fea681da MK |
80 | are listed below: |
81 | .TP | |
82 | .B EACCES | |
ee62201f | 83 | Search permission is denied for one of the components of |
fea681da MK |
84 | .IR path . |
85 | (See also | |
ad7cc990 | 86 | .BR path_resolution (7).) |
fea681da MK |
87 | .TP |
88 | .B EFAULT | |
89 | .I path | |
90 | points outside your accessible address space. | |
91 | .TP | |
92 | .B EIO | |
93 | An I/O error occurred. | |
94 | .TP | |
95 | .B ELOOP | |
96 | Too many symbolic links were encountered in resolving | |
97 | .IR path . | |
98 | .TP | |
99 | .B ENAMETOOLONG | |
100 | .I path | |
101 | is too long. | |
102 | .TP | |
103 | .B ENOENT | |
2a70e42b MK |
104 | The directory specified in |
105 | .I path | |
106 | does not exist. | |
fea681da MK |
107 | .TP |
108 | .B ENOMEM | |
109 | Insufficient kernel memory was available. | |
110 | .TP | |
111 | .B ENOTDIR | |
112 | A component of | |
113 | .I path | |
114 | is not a directory. | |
115 | .PP | |
116 | The general errors for | |
e511ffb6 | 117 | .BR fchdir () |
fea681da MK |
118 | are listed below: |
119 | .TP | |
120 | .B EACCES | |
121 | Search permission was denied on the directory open on | |
122 | .IR fd . | |
123 | .TP | |
124 | .B EBADF | |
125 | .I fd | |
126 | is not a valid file descriptor. | |
283db6f6 MK |
127 | .TP |
128 | .B ENOTDIR | |
129 | .I fd | |
130 | does not refer to a directory. | |
47297adb | 131 | .SH CONFORMING TO |
b5b45808 | 132 | POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD. |
fea681da | 133 | .SH NOTES |
ee62201f | 134 | The current working directory is the starting point for interpreting |
f81fb444 | 135 | relative pathnames (those not starting with \(aq/\(aq). |
efeece04 | 136 | .PP |
75fcdb08 MK |
137 | A child process created via |
138 | .BR fork (2) | |
139 | inherits its parent's current working directory. | |
140 | The current working directory is left unchanged by | |
141 | .BR execve (2). | |
47297adb | 142 | .SH SEE ALSO |
fea681da | 143 | .BR chroot (2), |
ad7cc990 | 144 | .BR getcwd (3), |
6a326a85 | 145 | .BR path_resolution (7) |