OSDN Git Service

20d3cd2a9a934a5c32f00846c62a3ae0fa091cf6
[linuxjm/LDP_man-pages.git] / draft / man2 / pivot_root.2
1 .\" Copyright (C) 2000 by Werner Almesberger
2 .\" May be distributed under GPL
3 .\"
4 .\" Written 2000-02-23 by Werner Almesberger
5 .\" Modified 2004-06-17 Michael Kerrisk <mtk.manpages@gmail.com>
6 .\"
7 .\" Japanese Version Copyright (c) 2000 NAKANO Takeo all rights reserved.
8 .\" Translated Wed Jun 14 2000 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
9 .\"
10 .TH PIVOT_ROOT 2 2007-06-01 "Linux" "Linux Programmer's Manual"
11 .\"O .SH NAME
12 .\"O pivot_root \- change the root file system
13 .SH 名前
14 pivot_root \- root ファイルシステムを変更する
15 .\"O .SH SYNOPSIS
16 .SH 書式
17 .BI "int pivot_root(const char *" new_root ", const char *" put_old );
18 .\"O .SH DESCRIPTION
19 .SH 説明
20 .\"O .BR pivot_root ()
21 .\"O moves the root file system of the calling process to the
22 .\"O directory \fIput_old\fP and makes \fInew_root\fP the new root file system
23 .\"O of the calling process.
24 .BR pivot_root ()
25 は呼び出し元のプロセスの root ファイルシステムを
26 .I put_old
27 ディレクトリに移動し、
28 .I new_root
29 を呼び出し元のプロセスの新しい root ファイルシステムにする。
30 .\"O .\"
31 .\"O .\" The
32 .\"O .\" .B CAP_SYS_ADMIN
33 .\"O .\" capability is required.
34 .\"
35 .\" .B CAP_SYS_ADMIN
36 .\" ケーパビリティが必要である。
37
38 .\"O The typical use of
39 .\"O .BR pivot_root ()
40 .\"O is during system startup, when the
41 .\"O system mounts a temporary root file system (e.g., an \fBinitrd\fP), then
42 .\"O mounts the real root file system, and eventually turns the latter into
43 .\"O the current root of all relevant processes or threads.
44 .BR pivot_root ()
45 の典型的な利用法は、システムの起動中にシステムが一時的な
46 root ファイルシステム (例えば
47 .BR initrd )
48 をマウントし、これに続いて本当の root ファイルシステムをマウントし、
49 後者を必要な全てのプロセス・スレッドの
50 カレント root に変更するような場合である。
51
52 .\"O .BR pivot_root ()
53 .\"O may or may not change the current root and the current
54 .\"O working directory of any processes or threads which use the old
55 .\"O root directory.
56 .\"O The caller of
57 .\"O .BR pivot_root ()
58 .\"O must ensure that processes with root or current working directory
59 .\"O at the old root operate correctly in either case.
60 .\"O An easy way to ensure this is to change their
61 .\"O root and current working directory to \fInew_root\fP before invoking
62 .\"O .BR pivot_root ().
63 古い root ディレクトリを使っていた全てのプロセスやスレッドの
64 カレント root とカレントワーキングディレクトリを、
65 .BR pivot_root ()
66 が変更するかどうかはわからない。
67 .BR pivot_root ()
68 の呼びだしプロセスは、古い root やカレントワーキングディレクトリを使っていた
69 プロセスが、いずれの場合でも正しく動作することを保証しなければならない。
70 これを簡単に行うには、それらのプロセスの root と
71 カレントワーキングディレクトリを
72 .BR pivot_root ()
73 を呼び出す前に
74 .I new_root
75 に変更しておくことである。
76
77 .\"O The paragraph above is intentionally vague because the implementation
78 .\"O of
79 .\"O .BR pivot_root ()
80 .\"O may change in the future.
81 .\"O At the time of writing,
82 .\"O .BR pivot_root ()
83 .\"O changes root and current working directory of each process or
84 .\"O thread to \fInew_root\fP if they point to the old root directory.
85 .\"O This
86 .\"O is necessary in order to prevent kernel threads from keeping the old
87 .\"O root directory busy with their root and current working directory,
88 .\"O even if they never access
89 .\"O the file system in any way.
90 .\"O In the future, there may be a mechanism for
91 .\"O kernel threads to explicitly relinquish any access to the file system,
92 .\"O such that this fairly intrusive mechanism can be removed from
93 .\"O .BR pivot_root ().
94 上記の段落は、将来
95 .BR pivot_root ()
96 が変更されるかも知れないことを鑑みて、わざと曖昧に書いてある。
97 本ページを記述している時点では、
98 .BR pivot_root ()
99 は古い root ディレクトリを用いている全てのプロセス・スレッドの root と
100 カレントワーキングディレクトリを
101 .I new_root
102 に変更する。これはカーネルのスレッドが古い root ディレクトリを
103 busy 状態にしないために必要である。これらのスレッドが
104 古いディレクトリを root やカレントワーキングディレクトリとしていると、
105 ファイルシステムに一切アクセスしない場合でも
106 古い root が busy になってしまうからである。
107 .\"nakano: ちと冗長...
108 将来は、カーネルスレッドがあらゆるファイルシステムへのアクセスを
109 明示的に放棄するメカニズムができ、このでしゃばりな機能は
110 .BR pivot_root ()
111 から削除されるかもしれない。
112
113 .\"O Note that this also applies to the calling process:
114 .\"O .BR pivot_root ()
115 .\"O may
116 .\"O or may not affect its current working directory.
117 .\"O It is therefore recommended to call
118 .\"O \fBchdir("/")\fP immediately after
119 .\"O .BR pivot_root ().
120 これは呼び出し元のプロセスについても当てはまることに注意。
121 .BR pivot_root ()
122 がカレントプロセスのカレントワーキングディレクトリに影響するかどうかは
123 分からない。したがって
124 .BR pivot_root ()
125 の直後に
126 .B chdir("/")
127 を呼び出すとよい。
128
129 .\"O The following restrictions apply to \fInew_root\fP and \fIput_old\fP:
130 .IR new_root " および " put_old
131 には以下の制限がある:
132 .IP \- 3
133 .\"O They must be directories.
134 ディレクトリでなければならない。
135 .IP \- 3
136 .\"O \fInew_root\fP and \fIput_old\fP must not be on the same file system as
137 .\"O the current root.
138 .IR new_root " と " put_old
139 は現在の root と同じファイルシステムにあってはならない。
140 .IP \- 3
141 .\"O \fIput_old\fP must be underneath \fInew_root\fP, that is, adding a nonzero
142 .\"O number of \fI/..\fP to the string pointed to by \fIput_old\fP must yield
143 .\"O the same directory as \fInew_root\fP.
144 .IR put_old " は " new_root
145 以下になければならない。すなわち
146 .I put_old
147 を差す文字列に 1 個以上の
148 .I ../
149 を付けることによって
150 .I new_root
151 と同じディレクトリが得られなければならない。
152 .IP \- 3
153 .\"O No other file system may be mounted on \fIput_old\fP.
154 他のファイルシステムが
155 .I put_old
156 にマウントされていてはならない。
157 .PP
158 .\"O See also
159 .\"O .BR pivot_root (8)
160 .\"O for additional usage examples.
161 利用例については
162 .BR pivot_root (8)
163 を参照のこと。
164
165 .\"O If the current root is not a mount point (e.g., after
166 .\"O .BR chroot (2)
167 .\"O or
168 .\"O .BR pivot_root (),
169 .\"O see also below), not the old root directory, but the
170 .\"O mount point of that file system is mounted on \fIput_old\fP.
171 現在の root がマウントポイントではない
172 .RB ( chroot (2)
173
174 .BR pivot_root ()
175 の後など。以下も参照) 場合、
176 古い root ディレクトリではなく、
177 そのファイルシステムのマウントポイントが
178 .I put_old
179 にマウントされる。
180
181 .\"O \fInew_root\fP does not have to be a mount point.
182 .\"O In this case,
183 .\"O \fI/proc/mounts\fP will show the mount point of the file system containing
184 .\"O \fInew_root\fP as root (\fI/\fP).
185 .I new_root
186 はマウントポイントでなくてもよい。
187 この場合
188 .I /proc/mounts
189 は、
190 .I new_root
191 を root
192 .RI ( / )
193 とするファイルシステムのマウントポイントを表示する。
194 .\"O .SH "RETURN VALUE"
195 .SH 返り値
196 .\"O On success, zero is returned.
197 .\"O On error, \-1 is returned, and
198 .\"O \fIerrno\fP is set appropriately.
199 成功すると 0 を返す。エラーが起ると \-1 を返し、
200 .I errno
201 が適切な値に設定される。
202 .\"O .SH ERRORS
203 .SH エラー
204 .\"O .BR pivot_root ()
205 .\"O may return (in \fIerrno\fP) any of the errors returned by
206 .\"O .BR stat (2).
207 .\"O Additionally, it may return:
208 .BR pivot_root ()
209
210 .BR stat (2)
211 の返すあらゆるエラーを
212 .RI ( errno
213 に) 返す可能性がある。さらに以下を返すことがある:
214 .TP
215 .B EBUSY
216 .\"O \fInew_root\fP or \fIput_old\fP are on the current root file system,
217 .\"O or a file system is already mounted on \fIput_old\fP.
218 .IR new_root " または " put_old
219 が、現在の root ファイルシステム上にあるか、既に
220 .I put_old
221 になんらかのファイルシステムがマウントされている。
222 .TP
223 .B EINVAL
224 .\"O \fIput_old\fP is not underneath \fInew_root\fP.
225 .IR put_old " が " new_root
226 の下層にない。
227 .TP
228 .B ENOTDIR
229 .\"O \fInew_root\fP or \fIput_old\fP is not a directory.
230 .IR new_root " または " put_old
231 がディレクトリでない。
232 .TP
233 .B EPERM
234 .\"O The calling process does not have the
235 .\"O .B CAP_SYS_ADMIN
236 .\"O capability.
237 呼び出し元のプロセスが
238 .B CAP_SYS_ADMIN
239 ケーパビリティを持っていない。
240 .\"O .SH VERSIONS
241 .SH バージョン
242 .\"O .BR pivot_root ()
243 .\"O was introduced in Linux 2.3.41.
244 .BR pivot_root ()
245 は Linux 2.3.41 で導入された。
246 .\"O .SH "CONFORMING TO"
247 .SH 準拠
248 .\"O .BR pivot_root ()
249 .\"O is Linux-specific and hence is not portable.
250 .BR pivot_root ()
251 は Linux に固有のものなので、移植性はない。
252 .\"O .SH NOTES
253 .SH 注意
254 .\"O Glibc does not provide a wrapper for this system call; call it using
255 .\"O .BR syscall (2).
256 glibc はこのシステムコールに対するラッパー関数を提供していない。
257 .BR syscall (2)
258 を使って呼び出すこと。
259 .\"O .SH BUGS
260 .SH バグ
261 .\"O .BR pivot_root ()
262 .\"O should not have to change root and current working directory of all other
263 .\"O processes in the system.
264 .BR pivot_root ()
265 はシステムの他のプロセス全ての root と
266 カレントワーキングディレクトリとを変更しなくてもよいはずである。
267
268 .\"O Some of the more obscure uses of
269 .\"O .BR pivot_root ()
270 .\"O may quickly lead to
271 .\"O insanity.
272 .BR pivot_root ()
273 の使い方がもうちょっと曖昧になると、
274 あっという間にわけのわからない状態になってしまうだろう
275 .\"O .SH "SEE ALSO"
276 .SH 関連項目
277 .BR chdir (2),
278 .BR chroot (2),
279 .BR stat (2),
280 .BR initrd (4),
281 .BR pivot_root (8)