OSDN Git Service

(split) LDP: Update draft and release (from the previous commit)
[linuxjm/LDP_man-pages.git] / draft / man2 / chmod.2
1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
2 .\" and Copyright (C) 2006, 2014 Michael Kerrisk
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
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 .\" %%%LICENSE_END
25 .\"
26 .\" Modified by Michael Haardt <michael@moria.de>
27 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
28 .\" Modified 1997-01-12 by Michael Haardt
29 .\"   <michael@cantor.informatik.rwth-aachen.de>: NFS details
30 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
31 .\"
32 .\"*******************************************************************
33 .\"
34 .\" This file was generated with po4a. Translate the source file.
35 .\"
36 .\"*******************************************************************
37 .\"
38 .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
39 .\"         all rights reserved.
40 .\" Translated 1996-06-24, Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
41 .\" Modified 1998-05-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
42 .\" Updated & Modified 2001-06-25, Yuichi SATO <ysato@h4.dion.ne.jp>
43 .\" Updated & Modified 2004-12-29, Yuichi SATO <ysato444@yahoo.co.jp>
44 .\" Updated 2008-08-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
45 .\"
46 .TH CHMOD 2 2014\-02\-21 Linux "Linux Programmer's Manual"
47 .SH 名前
48 chmod, fchmod, fchmodat \- change permissions of a file
49 .SH 書式
50 .nf
51 \fB#include <sys/stat.h>\fP
52 .sp
53 \fBint chmod(const char *\fP\fIpathname\fP\fB, mode_t \fP\fImode\fP\fB);\fP
54 .br
55 \fBint fchmod(int \fP\fIfd\fP\fB, mode_t \fP\fImode\fP\fB);\fP
56 .sp
57 \fB#include <fcntl.h>\fP           /* AT_* 定数の定義 */
58 \fB#include <sys/stat.h>\fP
59 .sp
60 \fBint fchmodat(int \fP\fIdirfd\fP\fB, const char *\fP\fIpathname\fP\fB, mode_t \fP\fImode\fP\fB, int \fP\fIflags\fP\fB);\fP
61 .fi
62 .sp
63 .in -4n
64 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
65 .in
66 .sp
67 .ad l
68 .PD 0
69 \fBfchmod\fP():
70 .RS 4
71 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
72 .br
73 || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L
74 .RE
75 .PD
76 .sp
77 \fBfchmodat\fP():
78 .PD 0
79 .ad l
80 .RS 4
81 .TP  4
82 glibc 2.10 以降:
83 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
84 .TP 
85 glibc 2.10 より前:
86 _ATFILE_SOURCE
87 .RE
88 .ad
89 .PD
90 .ad
91 .SH 説明
92 システムコール \fBchmod\fP() と \fBfchmod\fP() は、ファイルのアクセス許可 (permission) を変更する。
93 システムコール間の違いは、ファイルの指定の仕方だけである。
94 .IP * 2
95 \fBchmod\fP()  は、 \fIpathname\fP で指定されたパス名を持つファイルの許可を変更する。 \fIpathname\fP
96 がシンボリックリンクの場合は、リンクの展開が行われる。
97 .IP *
98 \fBfchmod\fP()  は、オープンされたファイルディスクリプタ \fIfd\fP により参照されるファイルの許可を変更する。
99 .PP
100 新しいファイル許可は \fImode\fP で指定される。 \fImode\fP は、以下に示す値の 0 個以上の OR (論理和) をとって作成される
101 ビットマスクである。
102 .TP  18
103 \fBS_ISUID\fP  (04000)
104 set\-user\-ID (\fBexecve\fP(2)  時にプロセスの実効ユーザ ID にセットされる)
105 .TP 
106 \fBS_ISGID\fP  (02000)
107 set\-group\-ID (以下の場合に (\fBexecve\fP(2)  実行時にプロセスの実効グループ ID にセットされる、 強制ロック
108 (mandatory locking) を行う (\fBfcntl\fP(2)  の説明を参照)、
109 新しいファイルのグループとして親ディレクトリと同じものを使う (\fBchown\fP(2)  と \fB(\fPmkdir\fB(2)\fP の説明を参照)
110 .TP 
111 \fBS_ISVTX\fP  (01000)
112 スティッキービット (sticky bit) (削除制限フラグ、 \fBunlink\fP(2)  の説明を参照)
113 .TP 
114 \fBS_IRUSR\fP  (00400)
115 所有者による読み取り
116 .TP 
117 \fBS_IWUSR\fP  (00200)
118 所有者による書き込み
119 .TP 
120 \fBS_IXUSR\fP  (00100)
121 所有者による実行 (execute) / 検索 (search)  (「検索」はディレクトリに対して適用されるもので、
122 そのディレクトリ内のエントリーへアクセスできるかを意味する)
123 .TP 
124 \fBS_IRGRP\fP  (00040)
125 グループによる読み取り
126 .TP 
127 \fBS_IWGRP\fP  (00020)
128 グループによる書き込み
129 .TP 
130 \fBS_IXGRP\fP  (00010)
131 グループによる実行 / 検索
132 .TP 
133 \fBS_IROTH\fP  (00004)
134 他人 (others) による読み取り
135 .TP 
136 \fBS_IWOTH\fP  (00002)
137 他人による書き込み
138 .TP 
139 \fBS_IXOTH\fP  (00001)
140 他人による実行 / 検索
141 .PP
142 呼び出したプロセスの実効 (effective) UID がファイルの所有者と一致するか、 そのプロセスが特権を持たなければならない (Linux では
143 \fBCAP_FOWNER\fP ケーパビリティ (capability) を持たなければならない)。
144
145 呼び出したプロセスに特権がなく (Linux では \fBCAP_FSETID\fP ケーパビリティがなく)、かつファイルのグループ ID が
146 プロセスの実効グループ ID または補助的なグループ ID にマッチしない場合、 \fBS_ISGID\fP
147 ビットはオフにされるが、これによってエラーが返されることはない。
148
149 安全のための処置として、 ファイルシステムによっては、ファイルの書き込みを行う時に セット・ユーザー ID とセット・グループ ID
150 ビットと実行ビットが オフにされることがある。 (Linux では、書き込みプロセスが \fBCAP_FSETID\fP
151 ケーパビリティを持っていない場合に、これが起こる。)  ファイルシステムの中には、スーパーユーザーだけが
152 特別の意味を持つスティッキービットを設定できるものがある。 スティッキービットとディレクトリに対する セット・ユーザー (グループ) ID
153 ビットについては、 \fBstat\fP(2)  を見よ。
154
155 .\"
156 .\"
157 NFS ファイルシステム上では、パーミッションを制限すると、 既にオープンされているファイルに対してすぐに影響が及ぶ。
158 これはアクセス制御がサーバー上で行われているが、 オープンされているファイルはクライアント側で管理されているためである。
159 クライアント側でファイル属性のキャッシュが有効になっている場合に、 パーミッションの制限を緩くすると、
160 他のクライアントに情報が伝わるのが遅れるかもしれない。
161 .SS fchmodat()
162 The \fBfchmodat\fP()  system call operates in exactly the same way as
163 \fBchmod\fP(), except for the differences described here.
164
165 If the pathname given in \fIpathname\fP is relative, then it is interpreted
166 relative to the directory referred to by the file descriptor \fIdirfd\fP
167 (rather than relative to the current working directory of the calling
168 process, as is done by \fBchmod\fP()  for a relative pathname).
169
170 If \fIpathname\fP is relative and \fIdirfd\fP is the special value \fBAT_FDCWD\fP,
171 then \fIpathname\fP is interpreted relative to the current working directory of
172 the calling process (like \fBchmod\fP()).
173
174 If \fIpathname\fP is absolute, then \fIdirfd\fP is ignored.
175
176 \fIflags\fP can either be 0, or include the following flag:
177 .TP 
178 \fBAT_SYMLINK_NOFOLLOW\fP
179 If \fIpathname\fP is a symbolic link, do not dereference it: instead operate on
180 the link itself.  This flag is not currently implemented.
181 .PP
182 See \fBopenat\fP(2)  for an explanation of the need for \fBfchmodat\fP().
183 .SH 返り値
184 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
185 .SH エラー
186 Depending on the filesystem, errors other than those listed below can be
187 returned.
188
189 The more general errors for \fBchmod\fP()  are listed below:
190 .TP 
191 \fBEACCES\fP
192 パス名の構成要素に検索許可がない (\fBpath_resolution\fP(7)  も見よ)。
193 .TP 
194 \fBEFAULT\fP
195 \fIpathname\fP がアクセス可能なアドレス空間の外を指している。
196 .TP 
197 \fBEIO\fP
198 I/O エラーが発生した。
199 .TP 
200 \fBELOOP\fP
201 \fIpathname\fP を解決するときに、解決すべきシンボリックリンクが多すぎた。
202 .TP 
203 \fBENAMETOOLONG\fP
204 \fIpathname\fP が長過ぎる。
205 .TP 
206 \fBENOENT\fP
207 ファイルが存在しない。
208 .TP 
209 \fBENOMEM\fP
210 カーネルに十分なメモリがない。
211 .TP 
212 \fBENOTDIR\fP
213 パス名の構成要素がディレクトリではない。
214 .TP 
215 \fBEPERM\fP
216 実効 UID がファイルの所有者と一致せず、プロセスに特権がない (Linux では \fBCAP_FOWNER\fP ケーパビリティを持たない)。
217 .TP 
218 \fBEROFS\fP
219 ファイルが読み込み専用 (read only) のファイルシステム上にある。
220 .PP
221 \fBfchmod\fP()  で一般的なエラーを挙げる:
222 .TP 
223 \fBEBADF\fP
224 ファイルディスクリプタ \fIfd\fP が有効でない。
225 .TP 
226 \fBEIO\fP
227 上記を参照。
228 .TP 
229 \fBEPERM\fP
230 上記を参照。
231 .TP 
232 \fBEROFS\fP
233 上記を参照。
234 .PP
235 The same errors that occur for \fBchmod\fP()  can also occur for
236 \fBfchmodat\fP().  The following additional errors can occur for \fBfchmodat\fP():
237 .TP 
238 \fBEBADF\fP
239 \fIdirfd\fP が適切なファイルディスクリプタでない。
240 .TP 
241 \fBEINVAL\fP
242 \fIflags\fP に無効なフラグが指定された。
243 .TP 
244 \fBENOTDIR\fP
245 \fIpathname\fP is relative and \fIdirfd\fP is a file descriptor referring to a
246 file other than a directory.
247 .TP 
248 \fBENOTSUP\fP
249 \fIflags\fP specified \fBAT_SYMLINK_NOFOLLOW\fP, which is not supported.
250 .SH バージョン
251 \fBfchmodat\fP()  was added to Linux in kernel 2.6.16; library support was
252 added to glibc in version 2.4.
253 .SH 準拠
254 \fBchmod\fP(), \fBfchmod\fP(): 4.4BSD, SVr4, POSIX.1\-2001i, POSIX.1\-2008.
255
256 \fBfchmodat\fP(): POSIX.1\-2008.
257 .SH 注意
258 The GNU C library \fBfchmodat\fP()  wrapper function implements the
259 POSIX\-specified interface described in this page.  This interface differs
260 from the underlying Linux system call, which does \fInot\fP have a \fIflags\fP
261 argument.
262 .SH 関連項目
263 \fBchown\fP(2), \fBexecve\fP(2), \fBopen\fP(2), \fBstat\fP(2), \fBpath_resolution\fP(7),
264 \fBsymlink\fP(7)
265 .SH この文書について
266 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.63 の一部
267 である。プロジェクトの説明とバグ報告に関する情報は
268 http://www.kernel.org/doc/man\-pages/ に書かれている。