]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
4 | .\" |
5 | .\" Modified by Michael Haardt <michael@moria.de> | |
6 | .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu> | |
7 | .\" Modified 1995-04-15 by Michael Chastain <mec@shell.portal.com>: | |
8 | .\" Added 'fchdir'. Fixed bugs in error section. | |
9 | .\" Modified 1996-10-21 by Eric S. Raymond <esr@thyrsus.com> | |
10 | .\" Modified 1997-08-21 by Joseph S. Myers <jsm28@cam.ac.uk> | |
c11b1abf | 11 | .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 12 | .\" |
1d767b55 | 13 | .TH CHDIR 2 2021-03-22 "Linux" "Linux Programmer's Manual" |
fea681da MK |
14 | .SH NAME |
15 | chdir, fchdir \- change working directory | |
dc6cd9dc AC |
16 | .SH LIBRARY |
17 | Standard C library | |
8fc3b2cf | 18 | .RI ( libc ", " \-lc ) |
fea681da | 19 | .SH SYNOPSIS |
c7db92b9 | 20 | .nf |
fea681da | 21 | .B #include <unistd.h> |
68e4db0a | 22 | .PP |
fea681da | 23 | .BI "int chdir(const char *" path ); |
fea681da | 24 | .BI "int fchdir(int " fd ); |
c7db92b9 | 25 | .fi |
68e4db0a | 26 | .PP |
d39ad78f | 27 | .RS -4 |
cc4615cc MK |
28 | Feature Test Macro Requirements for glibc (see |
29 | .BR feature_test_macros (7)): | |
d39ad78f | 30 | .RE |
68e4db0a | 31 | .PP |
cc4615cc | 32 | .BR fchdir (): |
9d2adbae | 33 | .nf |
5c10d2c5 MK |
34 | _XOPEN_SOURCE >= 500 |
35 | .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED | |
36 | || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L | |
9d2adbae MK |
37 | || /* Glibc up to and including 2.19: */ _BSD_SOURCE |
38 | .fi | |
fea681da | 39 | .SH DESCRIPTION |
e511ffb6 | 40 | .BR chdir () |
551d5b7a | 41 | changes the current working directory of the calling process to the |
ee62201f | 42 | directory specified in |
fea681da MK |
43 | .IR path . |
44 | .PP | |
e511ffb6 | 45 | .BR fchdir () |
fea681da | 46 | is identical to |
e511ffb6 | 47 | .BR chdir (); |
fea681da MK |
48 | the only difference is that the directory is given as an |
49 | open file descriptor. | |
47297adb | 50 | .SH RETURN VALUE |
c13182ef MK |
51 | On success, zero is returned. |
52 | On error, \-1 is returned, and | |
fea681da | 53 | .I errno |
f6a4078b | 54 | is set to indicate the error. |
fea681da | 55 | .SH ERRORS |
9ee4a2b6 | 56 | Depending on the filesystem, other errors can be returned. |
c13182ef | 57 | The more |
fea681da | 58 | general errors for |
e511ffb6 | 59 | .BR chdir () |
fea681da MK |
60 | are listed below: |
61 | .TP | |
62 | .B EACCES | |
ee62201f | 63 | Search permission is denied for one of the components of |
fea681da MK |
64 | .IR path . |
65 | (See also | |
ad7cc990 | 66 | .BR path_resolution (7).) |
fea681da MK |
67 | .TP |
68 | .B EFAULT | |
69 | .I path | |
70 | points outside your accessible address space. | |
71 | .TP | |
72 | .B EIO | |
73 | An I/O error occurred. | |
74 | .TP | |
75 | .B ELOOP | |
76 | Too many symbolic links were encountered in resolving | |
77 | .IR path . | |
78 | .TP | |
79 | .B ENAMETOOLONG | |
80 | .I path | |
81 | is too long. | |
82 | .TP | |
83 | .B ENOENT | |
2a70e42b MK |
84 | The directory specified in |
85 | .I path | |
86 | does not exist. | |
fea681da MK |
87 | .TP |
88 | .B ENOMEM | |
89 | Insufficient kernel memory was available. | |
90 | .TP | |
91 | .B ENOTDIR | |
92 | A component of | |
93 | .I path | |
94 | is not a directory. | |
95 | .PP | |
96 | The general errors for | |
e511ffb6 | 97 | .BR fchdir () |
fea681da MK |
98 | are listed below: |
99 | .TP | |
100 | .B EACCES | |
101 | Search permission was denied on the directory open on | |
102 | .IR fd . | |
103 | .TP | |
104 | .B EBADF | |
105 | .I fd | |
106 | is not a valid file descriptor. | |
283db6f6 MK |
107 | .TP |
108 | .B ENOTDIR | |
109 | .I fd | |
110 | does not refer to a directory. | |
3113c7f3 | 111 | .SH STANDARDS |
b5b45808 | 112 | POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD. |
fea681da | 113 | .SH NOTES |
ee62201f | 114 | The current working directory is the starting point for interpreting |
f81fb444 | 115 | relative pathnames (those not starting with \(aq/\(aq). |
efeece04 | 116 | .PP |
75fcdb08 MK |
117 | A child process created via |
118 | .BR fork (2) | |
119 | inherits its parent's current working directory. | |
120 | The current working directory is left unchanged by | |
121 | .BR execve (2). | |
47297adb | 122 | .SH SEE ALSO |
fea681da | 123 | .BR chroot (2), |
ad7cc990 | 124 | .BR getcwd (3), |
6a326a85 | 125 | .BR path_resolution (7) |