OSDN Git Service

31044c63199b94feb2d4c48b18e45d6145c9dcec
[linuxjm/LDP_man-pages.git] / release / man2 / chdir.2
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.
13 .\"
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.
21 .\"
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>
31 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
32 .\"
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
40 .\"
41 .TH CHDIR 2 2010-09-26 "Linux" "Linux Programmer's Manual"
42 .SH 名前
43 chdir, fchdir \- 作業ディレクトリの変更
44 .SH 書式
45 .B #include <unistd.h>
46 .sp
47 .BI "int chdir(const char *" path );
48 .br
49 .BI "int fchdir(int " fd );
50 .sp
51 .in -4n
52 glibc 向けの機能検査マクロの要件
53 .RB ( feature_test_macros (7)
54 参照):
55 .in
56 .sp
57 .BR fchdir ():
58 .PD 0
59 .ad l
60 .RS 4
61 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
62 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
63 .br
64 || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L
65 .RE
66 .ad
67 .PD
68 .SH 説明
69 .BR chdir ()
70 は、呼び出し元プロセスの現在の作業ディレクトリ (current working directory) を、
71 .I path
72 に指定されたディレクトリに変更する。
73 .PP
74 .BR fchdir ()
75 は、ディレクトリがオープンされたファイル・ディスクリプターとして
76 指定される以外は、
77 .BR chdir ()
78 と同じである。
79 .SH 返り値
80 成功すると、0 を返す。失敗すると、\-1 を返し、
81 .I errno
82 に適切な値をセットする。
83 .SH エラー
84 ファイルシステムによっては他のエラーが返される事がある。
85 .BR chdir ()
86 で一般的なエラーを以下に挙げる:
87 .TP
88 .B EACCES
89 .I path
90 の構成要素のいずれかに検索許可 (search permission) がない
91 .RB ( path_resolution (7)
92 も参照すること)。
93 .TP
94 .B EFAULT
95 割り当てられたアドレス空間外を
96 .I path
97 が指している。
98 .TP
99 .B EIO
100 I/O エラーが発生した。
101 .TP
102 .B ELOOP
103 .I path
104 を解決する際に遭遇したシンボリック・リンクが多過ぎる。
105 .TP
106 .B ENAMETOOLONG
107 .I path
108 が長過ぎる。
109 .TP
110 .B ENOENT
111 そのディレクトリは存在しない。
112 .TP
113 .B ENOMEM
114 カーネルに十分なメモリがない。
115 .TP
116 .B ENOTDIR
117 .I path
118 の構成要素がディレクトリではない。
119 .PP
120 .BR fchdir ()
121 で一般的なエラーを以下に挙げる:
122 .TP
123 .B EACCES
124 .I fd
125 をディレクトリとしてオープンするための検索許可がない。
126 .TP
127 .B EBADF
128 .I fd
129 が適切なファイル・ディスクリプターでない。
130 .SH 準拠
131 SVr4, 4.4BSD, POSIX.1-2001.
132 .SH 注意
133 現在の作業ディレクトリは、相対パス名 (\(aq/\(aq) で始まっていないパス名) を
134 解釈する際の開始点である。
135
136 .BR fork (2)
137 で作成された子プロセスは、親プロセスの現在の作業ディレクトリを
138 継承する。
139 .BR execve (2)
140 の前後で、現在の作業ディレクトリは変更されない。
141
142 .BR fchdir ()
143 のプロトタイプが有効になるのは、
144 .B _BSD_SOURCE
145 を定義した場合か、
146 .B _XOPEN_SOURCE
147 を値 500 で定義した場合のみである。
148 .SH 関連項目
149 .BR chroot (2),
150 .BR getcwd (3),
151 .BR path_resolution (7)