OSDN Git Service

(split) LDP: Fix editorical error in nanosleep.2
[linuxjm/LDP_man-pages.git] / draft / 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 .\"*******************************************************************
18 .\"
19 .\" This file was generated with po4a. Translate the source file.
20 .\"
21 .\"*******************************************************************
22 .TH UNSHARE 2 2010\-10\-30 Linux "Linux Programmer's Manual"
23 .SH 名前
24 unshare \- プロセス実行コンテキストの一部を分離する
25 .SH 書式
26 .nf
27 .\" Actually _BSD_SOURCE || _SVID_SOURCE
28 .\" FIXME See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
29 \fB#define _GNU_SOURCE\fP             /* feature_test_macros(7) 参照 */
30 \fB#include <sched.h>\fP
31 .sp
32 \fBint unshare(int \fP\fIflags\fP\fB);\fP
33 .fi
34 .SH 説明
35 \fBunshare\fP()  を使うと、プロセスは他のプロセスと現在共有している 実行コンテキストの一部を分離することができる。
36 実行コンテキストの一部、たとえばマウント名前空間 (mount namespace)  などは、新しいプロセスを \fBfork\fP(2)  または
37 \fBvfork\fP(2)  を使って生成したときに、暗黙のうちに共有される。 一方、仮想メモリなどは、 \fBclone\fP(2)
38 を使ってプロセスを生成するときに、明示的に共有することを要求できる。
39
40 \fBunshare\fP()  の主な利用法は、プロセスが新しいプロセスを生成することなく、 共有実行コンテキストを制御することである。
41
42 \fIflags\fP 引き数はビットマスクであり、 実行コンテキストのどの部分の共有を解除するかを表す。 この引き数は、以下の定数の 0 個以上の OR
43 で指定する:
44 .TP 
45 \fBCLONE_FILES\fP
46 \fBclone\fP(2)  \fBCLONE_FILES\fP フラグの効果を取り消す。 ファイルディスクリプタテーブルを共有させず、
47 呼び出し元プロセスは他のプロセスとファイルディスクリプタを共有しなくなる。
48 .TP 
49 \fBCLONE_FS\fP
50 \fBclone\fP(2)  \fBCLONE_FS\fP フラグの効果を取り消す。 ファイルシステム属性を共有させず、
51 呼び出し元プロセスは他のプロセスとルートディレクトリ・ カレントディレクトリ・umask 属性を共有しなくなる。 \fBchroot\fP(2),
52 \fBchdir\fP(2), \fBumask\fP(2)  に影響する。
53 .TP 
54 \fBCLONE_NEWIPC\fP (Linux 2.6.19 以降)
55 このフラグは \fBclone\fP(2) \fBCLONE_NEWIPC\fP フラグと同じ効果を持つ。
56 System V IPC 名前空間を共有せず、呼び出し元プロセスは 他のプロセスとは
57 共有しない固有の System V IPC 名前空間のコピーを持つ。 このフラグを指定
58 すると、 \fBCLONE_SYSVSEM\fP も暗黙のうちに指定される。 \fBCLONE_NEWIPC\fP を
59 使用するには \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
60 .TP 
61 \fBCLONE_NEWNET\fP (Linux 2.6.24 以降)
62 このフラグは \fBclone\fP(2) \fBCLONE_NEWNET\fP フラグと同じ効果を持つ。ネット
63 ワーク名前空間を共有せず、呼び出し元プロセスは他のプロセスとは共有しな
64 い固有のネットワーク名前空間のコピーを持つ。\fBCLONE_NEWNET\fP を使用する
65 には \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
66 .TP 
67 \fBCLONE_NEWNS\fP
68 .\" These flag name are inconsistent:
69 .\" CLONE_NEWNS does the same thing in clone(), but CLONE_VM,
70 .\" CLONE_FS, and CLONE_FILES reverse the action of the clone()
71 .\" flags of the same name.
72 このフラグは \fBclone\fP(2) \fBCLONE_NEWNS\fP フラグと同じ効果を持つ。 マウン
73 ト名前空間を共有せず、呼び出し元プロセスは 他のプロセスとは共有しない固
74 有の名前空間のコピーを持つ。 このフラグを指定すると、 \fBCLONE_FS\fP も暗
75 黙のうちに指定される。 \fBCLONE_NEWNS\fP を使用するには \fBCAP_SYS_ADMIN\fP
76 ケーパビリティが必要である。
77 .TP 
78 \fBCLONE_SYSVSEM\fP (Linux 2.6.26 以降)
79 このフラグは \fBclone\fP(2) \fBCLONE_SYSVSEM\fP フラグの効果を逆転させる。
80 System V セマフォのアンドゥ値を共有せず、呼び出し元プロセスは 他のプロ
81 セスとは共有しない固有のコピーを持つ。\fBCLONE_SYSVSEM\fP を使用するには
82 \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
83 .TP 
84 \fBCLONE_NEWUTS\fP (Linux 2.6.19 以降)
85 .\" As at 2.6.16, the following forced implications also apply,
86 .\" although the relevant flags are not yet implemented.
87 .\" If CLONE_THREAD is set force CLONE_VM.
88 .\" If CLONE_VM is set, force CLONE_SIGHAND.
89 .\" CLONE_NEWNSIf CLONE_SIGHAND is set and signals are also being shared
90 .\" (i.e., current->signal->count > 1), force CLONE_THREAD.
91 .\"
92 .\" FIXME . CLONE_VM is not (yet, as at 2.6.16) implemented.
93 .\" .TP
94 .\" .B CLONE_VM
95 .\" Reverse the effect of the
96 .\" .BR clone (2)
97 .\" .B CLONE_VM
98 .\" flag.
99 .\" .RB ( CLONE_VM
100 .\" is also implicitly set by
101 .\" .BR vfork (2),
102 .\" and can be reversed using this
103 .\" .BR unshare ()
104 .\" flag.)
105 .\" Unshare virtual memory, so that the calling process no
106 .\" longer shares its virtual address space with any other process.
107 このフラグは \fBclone\fP(2) \fBCLONE_NEWUTS\fP フラグと同じ効果を持つ。 UTS
108 IPC 名前空間を共有せず、呼び出し元プロセスは他のプロセスとは共有しない
109 固有の UTS IPC 名前空間のコピーを持つ。 このフラグを指定すると、
110 \fBCLONE_FS\fP も暗黙のうちに指定される。\fBCLONE_NEWUTS\fP を使用するには
111 \fBCAP_SYS_ADMIN\fP ケーパビリティが必要である。
112 .PP
113 \fIflags\fP に 0 が指定された場合、 \fBunshare\fP()  は何も行わないので、
114 呼び出し元プロセスの実行コンテキストは、何も変更されない。
115 .SH 返り値
116 成功した場合は 0 が返される。 失敗した場合は \-1 が返されて、 \fIerrno\fP にはエラーを示す値が設定される。
117 .SH エラー
118 .TP 
119 \fBEINVAL\fP
120 \fIflags\fP に不正なビットが指定された。
121 .TP 
122 \fBENOMEM\fP
123 呼び出し元のコンテキストのうち共有を解除する必要がある部分をコピーするために、 十分なメモリが確保できなかった。
124 .TP 
125 \fBEPERM\fP
126 呼び出し元プロセスはこの操作を行うのに必要な特権を持っていなかった。
127 .SH バージョン
128 \fBunshare\fP()  システムコールは Linux カーネル 2.6.16 で追加された。
129 .SH 準拠
130 \fBunshare\fP()  システムコールは Linux 固有である。
131 .SH 注意
132 .\" However, we can do unshare(CLONE_SIGHAND) if CLONE_SIGHAND
133 .\" was not specified when doing clone(); i.e., unsharing
134 .\" signal handlers is permitted if we are not actually
135 .\" sharing signal handlers.   mtk
136 .\" FIXME . check future kernel versions (e.g., 2.6.17)
137 .\" to see if CLONE_VM gets implemented.
138 .\" However, as at 2.6.16, we can do unshare(CLONE_VM) if CLONE_VM
139 .\" was not specified when doing clone(); i.e., unsharing
140 .\" virtual memory is permitted if we are not actually
141 .\" sharing virtual memory.   mtk
142 .\"
143 .\"9) Future Work
144 .\"--------------
145 .\"The current implementation of unshare does not allow unsharing of
146 .\"signals and signal handlers. Signals are complex to begin with and
147 .\"to unshare signals and/or signal handlers of a currently running
148 .\"process is even more complex. If in the future there is a specific
149 .\"need to allow unsharing of signals and/or signal handlers, it can
150 .\"be incrementally added to unshare without affecting legacy
151 .\"applications using unshare.
152 .\"
153 \fBclone\fP(2)  で新しいプロセスを生成したときに共有される全てのプロセス属性を、 \fBunshare\fP()
154 によって共有の解除ができるわけではない。 特に、カーネル 2.6.16 においては、 \fBunshare\fP()  に \fBCLONE_SIGHAND\fP,
155 \fBCLONE_SYSVSEM\fP, \fBCLONE_THREAD\fP, \fBCLONE_VM\fP の効果を取り消すためのフラグが実装されていない。
156 これらの機能は、必要であれば将来追加されるかもしれない。
157 .SH 関連項目
158 \fBclone\fP(2), \fBfork\fP(2), \fBvfork\fP(2), Documentation/unshare.txt
159 .SH この文書について
160 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.41 の一部
161 である。プロジェクトの説明とバグ報告に関する情報は
162 http://www.kernel.org/doc/man\-pages/ に書かれている。