]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Hey Emacs! This file is -*- nroff -*- source. |
2 | .\" | |
3 | .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 | |
4 | .\" | |
5 | .\" Permission is granted to make and distribute verbatim copies of this | |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
fea681da MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
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> | |
305a0578 | 31 | .\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net> |
fea681da MK |
32 | .\" |
33 | .TH CHDIR 2 2004-06-23 "Linux 2.6.7" "Linux Programmer's Manual" | |
34 | .SH NAME | |
35 | chdir, fchdir \- change working directory | |
36 | .SH SYNOPSIS | |
37 | .B #include <unistd.h> | |
38 | .sp | |
39 | .BI "int chdir(const char *" path ); | |
40 | .br | |
41 | .BI "int fchdir(int " fd ); | |
42 | .SH DESCRIPTION | |
e511ffb6 | 43 | .BR chdir () |
75fcdb08 | 44 | changes the current working directory to that specified in |
fea681da MK |
45 | .IR path . |
46 | .PP | |
e511ffb6 | 47 | .BR fchdir () |
fea681da | 48 | is identical to |
e511ffb6 | 49 | .BR chdir (); |
fea681da MK |
50 | the only difference is that the directory is given as an |
51 | open file descriptor. | |
52 | .SH "RETURN VALUE" | |
c13182ef MK |
53 | On success, zero is returned. |
54 | On error, \-1 is returned, and | |
fea681da MK |
55 | .I errno |
56 | is set appropriately. | |
57 | .SH ERRORS | |
c13182ef MK |
58 | Depending on the file system, other errors can be returned. |
59 | The more | |
fea681da | 60 | general errors for |
e511ffb6 | 61 | .BR chdir () |
fea681da MK |
62 | are listed below: |
63 | .TP | |
64 | .B EACCES | |
c13182ef | 65 | Search permission is denied for one of the directories |
75fcdb08 | 66 | in the path prefix of |
fea681da MK |
67 | .IR path . |
68 | (See also | |
69 | .BR path_resolution (2).) | |
70 | .TP | |
71 | .B EFAULT | |
72 | .I path | |
73 | points outside your accessible address space. | |
74 | .TP | |
75 | .B EIO | |
76 | An I/O error occurred. | |
77 | .TP | |
78 | .B ELOOP | |
79 | Too many symbolic links were encountered in resolving | |
80 | .IR path . | |
81 | .TP | |
82 | .B ENAMETOOLONG | |
83 | .I path | |
84 | is too long. | |
85 | .TP | |
86 | .B ENOENT | |
87 | The file does not exist. | |
88 | .TP | |
89 | .B ENOMEM | |
90 | Insufficient kernel memory was available. | |
91 | .TP | |
92 | .B ENOTDIR | |
93 | A component of | |
94 | .I path | |
95 | is not a directory. | |
96 | .PP | |
97 | The general errors for | |
e511ffb6 | 98 | .BR fchdir () |
fea681da MK |
99 | are listed below: |
100 | .TP | |
101 | .B EACCES | |
102 | Search permission was denied on the directory open on | |
103 | .IR fd . | |
104 | .TP | |
105 | .B EBADF | |
106 | .I fd | |
107 | is not a valid file descriptor. | |
108 | .SH NOTES | |
75fcdb08 MK |
109 | A child process created via |
110 | .BR fork (2) | |
111 | inherits its parent's current working directory. | |
112 | The current working directory is left unchanged by | |
113 | .BR execve (2). | |
114 | ||
fea681da | 115 | The prototype for |
e511ffb6 | 116 | .BR fchdir () |
fea681da | 117 | is only available if |
c13182ef | 118 | .B _BSD_SOURCE |
ead83042 MK |
119 | is defined, or |
120 | .B _XOPEN_SOURCE | |
121 | is defined with the value 500. | |
fea681da | 122 | .SH "CONFORMING TO" |
97c1eac8 | 123 | SVr4, 4.4BSD, POSIX.1-2001. |
fea681da MK |
124 | .SH "SEE ALSO" |
125 | .BR chroot (2), | |
126 | .BR path_resolution (2), | |
127 | .BR getcwd (3) |