OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / release / man2 / unshare.2
1 .\" Copyright (C) 2006, Janak Desai <janak@us.ibm.com>
2 .\" and Copyright (C) 2006, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" Licensed under the GPL
4 .\"
5 .\" Patch Justification:
6 .\" unshare system call is needed to implement, using PAM,
7 .\" per-security_context and/or per-user namespace to provide
8 .\" polyinstantiated directories. Using unshare and bind mounts, a
9 .\" PAM module can create private namespace with appropriate
10 .\" directories(based on user's security context) bind mounted on
11 .\" public directories such as /tmp, thus providing an instance of
12 .\" /tmp that is based on user's security context. Without the
13 .\" unshare system call, namespace separation can only be achieved
14 .\" by clone, which would require porting and maintaining all commands
15 .\" such as login, and su, that establish a user session.
16 .\"
17 .\" FIXME Document CLONE_NEWIPC, which is new in 2.6.18
18 .\" FIXME Document CLONE_NEWUTS, which is new in 2.6.19
19 .\" FIXME Document CLONE_SYSVSEM, which is new in 2.6.26
20 .\"
21 .\" Japanese Version Copyright (c) 2006 Yuichi SATO
22 .\"         all rights reserved.
23 .\" Translated 2006-08-10 by Yuichi SATO <ysato444@yahoo.co.jp>, LDP v2.36
24 .\"
25 .TH UNSHARE 2 2010-09-10 "Linux" "Linux Programmer's Manual"
26 .SH 名前
27 unshare \- プロセス実行コンテキストの一部を分離する
28 .SH 書式
29 .nf
30 .BR "#define _GNU_SOURCE" "             /* feature_test_macros(7) 参照 */"
31 .\" Actually _BSD_SOURCE || _SVID_SOURCE
32 .\" See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
33 .B #include <sched.h>
34 .sp
35 .BI "int unshare(int " flags );
36 .fi
37 .SH 説明
38 .BR unshare ()
39 を使うと、プロセスは他のプロセスと現在共有している
40 実行コンテキストの一部を分離することができる。
41 実行コンテキストの一部、たとえばマウント名前空間 (mount namespace)
42 などは、新しいプロセスを
43 .BR fork (2)
44 または
45 .BR vfork (2)
46 を使って生成したときに、暗黙のうちに共有される。
47 一方、仮想メモリなどは、
48 .BR clone (2)
49 を使ってプロセスを生成するときに、明示的に共有することを要求できる。
50
51 .BR unshare ()
52 の主な利用法は、プロセスが新しいプロセスを生成することなく、
53 共有実行コンテキストを制御することである。
54
55 .I flags
56 引き数はビットマスクであり、
57 実行コンテキストのどの部分の共有を解除するかを表す。
58 この引き数は、以下の定数の 0 個以上の OR で指定する:
59 .TP
60 .B CLONE_FILES
61 .BR clone (2)
62 .B CLONE_FILES
63 フラグの効果を取り消す。
64 ファイルディスクリプタテーブルを共有させず、
65 呼び出し元プロセスは他のプロセスとファイルディスクリプタを共有しなくなる。
66 .TP
67 .B CLONE_FS
68 .BR clone (2)
69 .B CLONE_FS
70 フラグの効果を取り消す。
71 ファイルシステム属性を共有させず、
72 呼び出し元プロセスは他のプロセスとルートディレクトリ・
73 カレントディレクトリ・umask 属性を共有しなくなる。
74 .BR chroot (2),
75 .BR chdir (2),
76 .BR umask (2)
77 に影響する。
78 .TP
79 .B CLONE_NEWNS
80 .\" These flag name are inconsistent:
81 .\" CLONE_NEWNS does the same thing in clone(), but CLONE_VM,
82 .\" CLONE_FS, and CLONE_FILES reverse the action of the clone()
83 .\" flags of the same name.
84 このフラグは
85 .BR clone (2)
86 .B CLONE_NEWNS
87 フラグと\fI同じ\fR効果を持つ。
88 マウント名前空間を共有せず、呼び出し元プロセスは
89 他のプロセスとは共有しない固有の名前空間のコピーを持つ。
90 このフラグを指定すると、
91 .B CLONE_FS
92 も暗黙のうちに指定される。
93 .\" As at 2.6.16, the following forced implications also apply,
94 .\" although the relevant flags are not yet implemented.
95 .\" If CLONE_THREAD is set force CLONE_VM.
96 .\" If CLONE_VM is set, force CLONE_SIGHAND.
97 .\" If CLONE_SIGHAND is set and signals are also being shared
98 .\" (i.e., current->signal->count > 1), force CLONE_THREAD.
99 .\"
100 .\" FIXME . CLONE_VM is not (yet, as at 2.6.16) implemented.
101 .\" .TP
102 .\" .B CLONE_VM
103 .\" Reverse the effect of the
104 .\" .BR clone (2)
105 .\" .B CLONE_VM
106 .\" flag.
107 .\" .RB ( CLONE_VM
108 .\" is also implicitly set by
109 .\" .BR vfork (2),
110 .\" and can be reversed using this
111 .\" .BR unshare ()
112 .\" flag.)
113 .\" Unshare virtual memory, so that the calling process no
114 .\" longer shares its virtual address space with any other process.
115 .PP
116 .I flags
117 に 0 が指定された場合、
118 .BR unshare ()
119 は何も行わないので、
120 呼び出し元プロセスの実行コンテキストは、何も変更されない。
121 .SH 返り値
122 成功した場合は 0 が返される。
123 失敗した場合は \-1 が返されて、
124 .I errno
125 にはエラーを示す値が設定される。
126 .SH エラー
127 .TP
128 .B EINVAL
129 .I flags
130 に不正なビットが指定された。
131 .TP
132 .B ENOMEM
133 呼び出し元のコンテキストのうち共有を解除する必要がある部分をコピーするために、
134 十分なメモリが確保できなかった。
135 .TP
136 .B EPERM
137 .I flags
138
139 .B CLONE_NEWNS
140 が指定されたが、呼び出し元プロセスに特権
141 .RB ( CAP_SYS_ADMIN
142 ケーパビリティ) がなかった。
143 .SH バージョン
144 .BR unshare ()
145 システムコールは Linux カーネル 2.6.16 で追加された。
146 .SH 準拠
147 .BR unshare ()
148 システムコールは Linux 固有である。
149 .SH 注意
150 .BR clone (2)
151 で新しいプロセスを生成したときに共有される全てのプロセス属性を、
152 .BR unshare ()
153 によって共有の解除ができるわけではない。
154 特に、カーネル 2.6.16 においては、
155 .BR unshare ()
156
157 .BR CLONE_SIGHAND ,
158 .\" However, we can do unshare(CLONE_SIGHAND) if CLONE_SIGHAND
159 .\" was not specified when doing clone(); i.e., unsharing
160 .\" signal handlers is permitted if we are not actually
161 .\" sharing signal handlers.   mtk
162 .BR CLONE_SYSVSEM ,
163 .BR CLONE_THREAD ,
164 .\" FIXME . check future kernel versions (e.g., 2.6.17)
165 .\" to see if CLONE_VM gets implemented.
166 .B CLONE_VM
167 の効果を取り消すためのフラグが実装されていない。
168 .\" However, as at 2.6.16, we can do unshare(CLONE_VM) if CLONE_VM
169 .\" was not specified when doing clone(); i.e., unsharing
170 .\" virtual memory is permitted if we are not actually
171 .\" sharing virtual memory.   mtk
172 これらの機能は、必要であれば将来追加されるかもしれない。
173 .\"
174 .\"9) Future Work
175 .\"--------------
176 .\"The current implementation of unshare does not allow unsharing of
177 .\"signals and signal handlers. Signals are complex to begin with and
178 .\"to unshare signals and/or signal handlers of a currently running
179 .\"process is even more complex. If in the future there is a specific
180 .\"need to allow unsharing of signals and/or signal handlers, it can
181 .\"be incrementally added to unshare without affecting legacy
182 .\"applications using unshare.
183 .\"
184 .SH 関連項目
185 .BR clone (2),
186 .BR fork (2),
187 .BR vfork (2),
188 Documentation/unshare.txt