1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
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>
31 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
33 .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
34 .\" all rights reserved.
35 .\" Translated 1996-06-24, Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
36 .\" Modified 1997-12-13, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
37 .\" Updated & Modified 2005-02-05, Yuichi SATO <ysato444@yahoo.co.jp>
38 .\" Updated 2006-08-12, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.39
39 .\" Updated 2007-09-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.64
41 .TH CHDIR 2 2007-07-26 "Linux" "Linux Programmer's Manual"
44 .\"O chdir, fchdir \- change working directory
45 chdir, fchdir \- ºî¶È¥Ç¥£¥ì¥¯¥È¥ê¤ÎÊѹ¹
48 .B #include <unistd.h>
50 .BI "int chdir(const char *" path );
52 .BI "int fchdir(int " fd );
55 .\"O Feature Test Macro Requirements for glibc (see
56 .\"O .BR feature_test_macros (7)):
57 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
58 .RB ( feature_test_macros (7)
63 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
67 .\"O changes the current working directory of the calling process to the
68 .\"O directory specified in
71 ¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¸½ºß¤Îºî¶È¥Ç¥£¥ì¥¯¥È¥ê (current working directory) ¤ò¡¢
73 ¤Ë»ØÄꤵ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ËÊѹ¹¤¹¤ë¡£
78 .\"O the only difference is that the directory is given as an
79 .\"O open file descriptor.
81 ¤Ï¡¢¥Ç¥£¥ì¥¯¥È¥ê¤¬¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤È¤·¤Æ
85 .\"O .SH "RETURN VALUE"
87 .\"O On success, zero is returned.
88 .\"O On error, \-1 is returned, and
90 .\"O is set appropriately.
91 À®¸ù¤¹¤ë¤È¡¢0 ¤òÊÖ¤¹¡£¼ºÇÔ¤¹¤ë¤È¡¢\-1 ¤òÊÖ¤·¡¢
93 ¤ËŬÀÚ¤ÊÃͤò¥»¥Ã¥È¤¹¤ë¡£
96 .\"O Depending on the file system, other errors can be returned.
98 .\"O general errors for
100 .\"O are listed below:
101 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¾¤Î¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤ë»ö¤¬¤¢¤ë¡£
103 ¤Ç°ìÈÌŪ¤Ê¥¨¥é¡¼¤ò°Ê²¼¤Ëµó¤²¤ë:
106 .\"O Search permission is denied for one of the components of
109 .\"O .BR path_resolution (7).)
111 ¤Î¹½À®Í×ÁǤΤ¤¤º¤ì¤«¤Ë¸¡º÷µö²Ä (search permission) ¤¬¤Ê¤¤
112 .RB ( path_resolution (7)
117 .\"O points outside your accessible address space.
118 ³ä¤êÅö¤Æ¤é¤ì¤¿¥¢¥É¥ì¥¹¶õ´Ö³°¤ò
123 .\"O An I/O error occurred.
124 I/O ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
127 .\"O Too many symbolic links were encountered in resolving
130 ¤ò²ò·è¤¹¤ëºÝ¤ËÁø¶ø¤·¤¿¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤ë¡£
139 .\"O The file does not exist.
141 .\"Osato: file ¤Ç¤Ï¤Ê¤¯ directory ¤Î´Ö°ã¤¤¤«?
143 ¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ï¸ºß¤·¤Ê¤¤¡£
146 .\"O Insufficient kernel memory was available.
147 ¥«¡¼¥Í¥ë¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¡£
152 .\"O is not a directory.
154 ¤Î¹½À®Í×ÁǤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤Ê¤¤¡£
156 .\"O The general errors for
158 .\"O are listed below:
160 ¤Ç°ìÈÌŪ¤Ê¥¨¥é¡¼¤ò°Ê²¼¤Ëµó¤²¤ë:
163 .\"O Search permission was denied on the directory open on
166 ¤ò¥Ç¥£¥ì¥¯¥È¥ê¤È¤·¤Æ¥ª¡¼¥×¥ó¤¹¤ë¤¿¤á¤Î¸¡º÷µö²Ä¤¬¤Ê¤¤¡£
170 .\"O is not a valid file descriptor.
172 ¤¬Å¬Àڤʥե¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤Ç¤Ê¤¤¡£
173 .\"O .SH "CONFORMING TO"
175 SVr4, 4.4BSD, POSIX.1-2001.
178 .\"O The current working directory is the starting point for interpreting
179 .\"O relative pathnames (those not starting with \(aq/\(aq)).
180 ¸½ºß¤Îºî¶È¥Ç¥£¥ì¥¯¥È¥ê¤Ï¡¢ÁêÂХѥ¹Ì¾ (\(aq/\(aq) ¤Ç»Ï¤Þ¤Ã¤Æ¤¤¤Ê¤¤¥Ñ¥¹Ì¾) ¤ò
181 ²ò¼á¤¹¤ëºÝ¤Î³«»ÏÅÀ¤Ç¤¢¤ë¡£
183 .\"O A child process created via
185 .\"O inherits its parent's current working directory.
186 .\"O The current working directory is left unchanged by
189 ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¡¢¿Æ¥×¥í¥»¥¹¤Î¸½ºß¤Îºî¶È¥Ç¥£¥ì¥¯¥È¥ê¤ò
192 ¤ÎÁ°¸å¤Ç¡¢¸½ºß¤Îºî¶È¥Ç¥£¥ì¥¯¥È¥ê¤ÏÊѹ¹¤µ¤ì¤Ê¤¤¡£
194 .\"O The prototype for
196 .\"O is only available if
199 .\"O .B _XOPEN_SOURCE
200 .\"O is defined with the value 500.
202 ¤Î¥×¥í¥È¥¿¥¤¥×¤¬Í¸ú¤Ë¤Ê¤ë¤Î¤Ï¡¢
206 ¤òÃÍ 500 ¤ÇÄêµÁ¤·¤¿¾ì¹ç¤Î¤ß¤Ç¤¢¤ë¡£
211 .BR path_resolution (7)