OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / draft / man2 / chroot.2
1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1994-08-21 by Michael Chastain <mec@shell.portal.com>
28 .\" Modified 1996-06-13 by aeb
29 .\" Modified 1996-11-06 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 .\"*******************************************************************
34 .\"
35 .\" This file was generated with po4a. Translate the source file.
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
40 .\"         all rights reserved.
41 .\" Translated Mon Jun 24 14:29:55 JST 1996
42 .\"         by Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
43 .\" Modified Sat Dec 13 23:29:07 JST 1997
44 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
45 .\" Updated & Modified Fri 6 Apr 2001
46 .\"         by NAKANO Takeo <nakano@apm.seikei.ac.jp>
47 .\" Updated & Modified Thu Dec 23 10:04:20 JST 2004
48 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
49 .\"
50 .TH CHROOT 2 2010\-09\-20 Linux "Linux Programmer's Manual"
51 .SH 名前
52 chroot \- ルートディレクトリを変更する
53 .SH 書式
54 \fB#include <unistd.h>\fP
55 .sp
56 \fBint chroot(const char *\fP\fIpath\fP\fB);\fP
57 .sp
58 .in -4n
59 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
60 .in
61 .sp
62 \fBchroot\fP():
63 .ad l
64 .RS 4
65 .PD 0
66 .TP  4
67 glibc 2.2.2 以降:
68 .nf
69 _BSD_SOURCE ||
70     (_XOPEN_SOURCE\ >=\ 500 ||
71         _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
72     !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
73 .TP  4
74 .fi
75 glibc 2.2.2 より前: なし
76 .PD
77 .RE
78 .ad b
79 .SH 説明
80 \fBchroot\fP()  は、呼び出し元プロセスのルートディレクトリを \fIpath\fP で指定されたディレクトリに変更する。 このディレクトリ以下が
81 \fI/\fP から始まるパス名として使われる。 このルートディレクトリは呼び出し元のプロセスの全ての子プロセスに受け継がれる。
82
83 特権プロセス (Linux では、 \fBCAP_SYS_CHROOT\fP ケーパビリティを持つプロセス) のみが \fBchroot\fP()
84 を呼び出すことができる。
85
86 このコールはパス名解決の過程で構成要素を変更するのみで、 その他には何も行わない。
87
88 このコールは現在の作業ディレクトリ (working directory) を変更しない。 そのため、このコールの後に \(aq\fI.\fP\(aq が
89 \(aq\fI/\fP\(aq を 根とするツリーの外になる場合がある。 特に、スーパーユーザーは以下のようにすることで "chroot jail"
90 から逃げ出せてしまう。
91 .nf
92
93     mkdir foo; chroot foo; cd ..
94 .fi
95
96 このコールはオープンファイルディスクリプターをクローズしないので、 このようなファイルディスクリプターは chroot ツリーの外にある
97 ファイルにアクセスできる。
98 .SH 返り値
99 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
100 .SH エラー
101 ファイルシステムによっては他のエラーが返される事がある。 一般的なエラーを以下に挙げる:
102 .TP 
103 \fBEACCES\fP
104 .\" Also search permission is required on the final component,
105 .\" maybe just to guarantee that it is a directory?
106 パス名の構成要素に検索許可がない (\fBpath_resolution\fP(7)  も見よ)。
107 .TP 
108 \fBEFAULT\fP
109 \fIpath\fP がアクセスできるアドレス空間外を指している。
110 .TP 
111 \fBEIO\fP
112 I/O エラーが発生した。
113 .TP 
114 \fBELOOP\fP
115 \fIpath\fP を解決する際に遭遇したシンボリックリンクが多過ぎる。
116 .TP 
117 \fBENAMETOOLONG\fP
118 \fIpath\fP が長過ぎる。
119 .TP 
120 \fBENOENT\fP
121 ファイルが存在しない。
122 .TP 
123 \fBENOMEM\fP
124 カーネルに十分なメモリーがない。
125 .TP 
126 \fBENOTDIR\fP
127 \fIpath\fP の構成要素がディレクトリではない。
128 .TP 
129 \fBEPERM\fP
130 呼び出し側に十分な特権がない。
131 .SH 準拠
132 .\" SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions.
133 .\" X/OPEN does not document EIO, ENOMEM or EFAULT error conditions.
134 SVr4, 4.4BSD, SUSv2 (但し、SUSv2 では過去の名残とされている)。 この関数は POSIX.1\-2001 にはない。
135 .SH 注意
136 \fBfork\fP(2)  で作成された子プロセスは、 親プロセスのルートディレクトリを継承する。 \fBexecve\fP(2)
137 の場合も、ルートディレクトリは変更されない。
138
139 .\" FIXME . eventually say something about containers,
140 .\" virtual servers, etc.?
141 FreeBSD にはより強力な \fBjail\fP()  システムコールがある。
142 .SH 関連項目
143 \fBchdir\fP(2), \fBpath_resolution\fP(7)
144 .SH この文書について
145 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
146 である。プロジェクトの説明とバグ報告に関する情報は
147 http://www.kernel.org/doc/man\-pages/ に書かれている。