1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
|
.\" Copyright (C) 2013, Heinrich Schuchardt <xypron.glpk@gmx.de>
.\"
.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of
.\" this manual under the conditions for verbatim copying, provided that
.\" the entire resulting derived work is distributed under the terms of
.\" a permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume.
.\" no responsibility for errors or omissions, or for damages resulting.
.\" from the use of the information contained herein. The author(s) may.
.\" not have taken the same level of care in the production of this.
.\" manual, which is licensed free of charge, as they might when working.
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%LICENSE_END
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.TH FANOTIFY_MARK 2 2020\-11\-01 Linux "Linux Programmer's Manual"
.SH 名前
fanotify_mark \- ファイルシステムオブジェクトへの fanotify マークの追加、削除、変更
.SH 書式
.nf
\fB#include <sys/fanotify.h>\fP
.PP
\fBint fanotify_mark(int \fP\fIfanotify_fd\fP\fB, unsigned int \fP\fIflags\fP\fB,\fP
\fB uint64_t \fP\fImask\fP\fB, int \fP\fIdirfd\fP\fB, const char *\fP\fIpathname\fP\fB);\fP
.fi
.SH 説明
fanotify API の概要については \fBfanotify\fP(7) を参照。
.PP
\fBfanotify_mark\fP() はファイルシステムオブジェクトに対する fanotify マークの追加、削除、変更を行う。
呼び出し元はマークを付けるファイルシステムオブジェクトに対する読み出し許可を持っていなければならない。
.PP
\fIfanotify_fd\fP 引数は \fBfanotify_init\fP(2) で返されたファイルディスクリプターである。
.PP
\fIflags\fP は実行する操作内容を示すビットマスクである。 以下の値のいずれか一つだけを指定しなければならない。
.TP
\fBFAN_MARK_ADD\fP
\fImask\fP のイベントを mark マスク (もしくは ignore マスク) に追加する。 \fImask\fP は空であってはいけない。
空の場合はエラー \fBEINVAL\fP が発生する。
.TP
\fBFAN_MARK_REMOVE\fP
引数 \fImask\fP のイベントを mark マスク (もしくは ignore マスク) から削除する。 \fImask\fP は空であってはいけない。
空の場合はエラー \fBEINVAL\fPが発生する。
.TP
\fBFAN_MARK_FLUSH\fP
Remove either all marks for filesystems, all marks for mounts, or all marks
for directories and files from the fanotify group. If \fIflags\fP contains
\fBFAN_MARK_MOUNT\fP, all marks for mounts are removed from the group. If
\fIflags\fP contains \fBFAN_MARK_FILESYSTEM\fP, all marks for filesystems are
removed from the group. Otherwise, all marks for directories and files are
removed. No flag other than and at most one of the flags \fBFAN_MARK_MOUNT\fP
or \fBFAN_MARK_FILESYSTEM\fP can be used in conjunction with
\fBFAN_MARK_FLUSH\fP. \fImask\fP is ignored.
.PP
上記のどの値も指定されなかった場合、 または 2 つ以上の値が指定された場合、 呼び出しはエラー \fBEINVAL\fP で失敗する。
.PP
これに加えて、 \fIflags\fP に以下の値を 0 個以上ビット単位の論理和 (OR) で指定できる。
.TP
\fBFAN_MARK_DONT_FOLLOW\fP
\fIpathname\fP がシンボリックリンクの場合、 リンクが参照するファイルではなく、 リンク自身にマークを付ける (デフォルトでは
\fBfanotify_mark\fP() は \fIpathname\fP がシンボリックリンクの場合シンボリックリンクの展開を行う)。
.TP
\fBFAN_MARK_ONLYDIR\fP
マークが付けられたファイルシステムオブジェクトがディレクトリでない場合、 エラー \fBENOTDIR\fP が発生する。
.TP
\fBFAN_MARK_MOUNT\fP
Mark the mount point specified by \fIpathname\fP. If \fIpathname\fP is not itself
a mount point, the mount point containing \fIpathname\fP will be marked. All
directories, subdirectories, and the contained files of the mount point will
be monitored. The events which require that filesystem objects are
identified by file handles, such as \fBFAN_CREATE\fP, \fBFAN_ATTRIB\fP,
\fBFAN_MOVE\fP, and \fBFAN_DELETE_SELF\fP, cannot be provided as a \fImask\fP when
\fIflags\fP contains \fBFAN_MARK_MOUNT\fP. Attempting to do so will result in the
error \fBEINVAL\fP being returned.
.TP
\fBFAN_MARK_FILESYSTEM\fP (Linux 4.20 以降)
.\" commit d54f4fba889b205e9cd8239182ca5d27d0ac3bc2
Mark the filesystem specified by \fIpathname\fP. The filesystem containing
\fIpathname\fP will be marked. All the contained files and directories of the
filesystem from any mount point will be monitored.
.TP
\fBFAN_MARK_IGNORED_MASK\fP
\fImask\fP のイベントの ignore マスクへの追加、もしくは削除を行う。
.TP
\fBFAN_MARK_IGNORED_SURV_MODIFY\fP
ignore マスクは変更イベントが発生しても残り続ける。 このフラグがセットされていない場合、
無視するファイルやディレクトリに対して変更イベントが発生した際に ignore マスクはクリアされる。
.PP
\fImask\fP はどのイベントに対して通知を受けるか (もしくはどのイベントを無視するか) を定義する。 以下の値から構成されるビットマスクである。
.TP
\fBFAN_ACCESS\fP
ファイルやディレクトリへのアクセス (読み出し) があった際にイベントを作成する (「バグ」も参照)。
.TP
\fBFAN_MODIFY\fP
ファイルが変更された (書き込み) 際にイベントを作成する。
.TP
\fBFAN_CLOSE_WRITE\fP
書き込み可能ファイルがクローズされた際にイベントを作成する。
.TP
\fBFAN_CLOSE_NOWRITE\fP
読み出し専用のファイルやディレクトリがクローズされた際にイベントを作成する。
.TP
\fBFAN_OPEN\fP
ファイルやディレクトリがオープンされた際にイベントを作成する。
.TP
\fBFAN_OPEN_EXEC\fP (Linux 5.0 以降)
.\" commit 9b076f1c0f4869b838a1b7aa0edb5664d47ec8aa
Create an event when a file is opened with the intent to be executed. See
NOTES for additional details.
.TP
\fBFAN_ATTRIB\fP (Linux 5.1 以降)
.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2
Create an event when the metadata for a file or directory has changed. An
fanotify group that identifies filesystem objects by file handles is
required.
.TP
\fBFAN_CREATE\fP (Linux 5.1 以降)
.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2
Create an event when a file or directory has been created in a marked parent
directory. An fanotify group that identifies filesystem objects by file
handles is required.
.TP
\fBFAN_DELETE\fP (Linux 5.1 以降)
.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2
Create an event when a file or directory has been deleted in a marked parent
directory. An fanotify group that identifies filesystem objects by file
handles is required.
.TP
\fBFAN_DELETE_SELF\fP (Linux 5.1 以降)
.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2
Create an event when a marked file or directory itself is deleted. An
fanotify group that identifies filesystem objects by file handles is
required.
.TP
\fBFAN_MOVED_FROM\fP (Linux 5.1 以降)
.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2
Create an event when a file or directory has been moved from a marked parent
directory. An fanotify group that identifies filesystem objects by file
handles is required.
.TP
\fBFAN_MOVED_TO\fP (Linux 5.1 以降)
.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2
Create an event when a file or directory has been moved to a marked parent
directory. An fanotify group that identifies filesystem objects by file
handles is required.
.TP
\fBFAN_MOVE_SELF\fP (Linux 5.1 以降)
.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2
Create an event when a marked file or directory itself has been moved. An
fanotify group that identifies filesystem objects by file handles is
required.
.TP
\fBFAN_OPEN_PERM\fP
ファイルやディレクトリをオープンするアクセス許可が要求された際にイベントを作成する。 fanotify ファイルディスクリプターが
\fBFAN_CLASS_PRE_CONTENT\fP か \fBFAN_CLASS_CONTENT\fP を指定されて作成されている必要がある。
.TP
\fBFAN_OPEN_EXEC_PERM\fP (since Linux 5.0)
.\" commit 66917a3130f218dcef9eeab4fd11a71cd00cd7c9
Create an event when a permission to open a file for execution is
requested. An fanotify file descriptor created with
\fBFAN_CLASS_PRE_CONTENT\fP or \fBFAN_CLASS_CONTENT\fP is required. See NOTES for
additional details.
.TP
\fBFAN_ACCESS_PERM\fP
ファイルやディレクトリを読み出すアクセス許可が要求された際にイベントを作成する。 fanotify ファイルディスクリプターが
\fBFAN_CLASS_PRE_CONTENT\fP か \fBFAN_CLASS_CONTENT\fP を指定されて作成されている必要がある。
.TP
\fBFAN_ONDIR\fP
Create events for directories\(emfor example, when \fBopendir\fP(3),
\fBreaddir\fP(3) (but see BUGS), and \fBclosedir\fP(3) are called. Without this
flag, events are created only for files. In the context of directory entry
events, such as \fBFAN_CREATE\fP, \fBFAN_DELETE\fP, \fBFAN_MOVED_FROM\fP, and
\fBFAN_MOVED_TO\fP, specifying the flag \fBFAN_ONDIR\fP is required in order to
create events when subdirectory entries are modified (i.e., \fBmkdir\fP(2)/
\fBrmdir\fP(2)).
.TP
\fBFAN_EVENT_ON_CHILD\fP
Events for the immediate children of marked directories shall be created.
The flag has no effect when marking mounts and filesystems. Note that
events are not generated for children of the subdirectories of marked
directories. More specifically, the directory entry modification events
\fBFAN_CREATE\fP, \fBFAN_DELETE\fP, \fBFAN_MOVED_FROM\fP, and \fBFAN_MOVED_TO\fP are not
generated for any entry modifications performed inside subdirectories of
marked directories. Note that the events \fBFAN_DELETE_SELF\fP and
\fBFAN_MOVE_SELF\fP are not generated for children of marked directories. To
monitor complete directory trees it is necessary to mark the relevant mount
or filesystem.
.PP
The following composed values are defined:
.TP
\fBFAN_CLOSE\fP
ファイルがクローズされた (\fBFAN_CLOSE_WRITE\fP|\fBFAN_CLOSE_NOWRITE\fP)。
.TP
\fBFAN_MOVE\fP
A file or directory has been moved (\fBFAN_MOVED_FROM\fP|\fBFAN_MOVED_TO\fP).
.PP
マークを付けるファイルシステムオブジェクトは、 ファイルディスクリプター \fIdirfd\fP と \fIpathname\fP
で指定されたパス名から決定される。
.IP * 3
\fIpathname\fP が NULL の場合、 \fIdirfd\fP でマークを付けるファイルシステムオブジェクトが定義される。
.IP *
\fIpathname\fP が NULL で、 \fIdirfd\fP が特別な値 \fBAT_FDCWD\fP の場合、
カレントワーキングディレクトリがマークされる。
.IP *
\fIpathname\fP が絶対パスの場合、 そのパス名によりマークを付けるファイルシステムオブジェクトが定義され、 \fIdirfd\fP は無視される。
.IP *
\fIpathname\fP が相対パスで、 \fIdirfd\fP が \fBAT_FDCWD\fP でない場合、 マークを付けるファイルシステムオブジェクトは
\fIdirfd\fP が参照するディレクトリに対する相対パス \fIpathname\fP を解釈して決定される。
.IP *
\fIpathname\fP が相対パスで、 \fIdirfd\fP が \fBAT_FDCWD\fP の場合、
マークを付けるファイルシステムオブジェクトはカレントワーキングディレクトリに対する相対パス \fIpathname\fP を解釈して決定される。
.SH 返り値
成功すると \fBfanotify_mark\fP() は 0 を返す。 エラーの場合、 \-1 を返し、 \fIerrno\fP にエラーの原因を示す値を設定する。
.SH エラー
.TP
\fBEBADF\fP
無効なファイルディスクリプターが \fIfanotify_fd\fP で渡された。
.TP
\fBEINVAL\fP
無効な値が \fIflags\fP か \fImask\fP に指定されたか、 \fIfanotify_fd\fP が fanotify
ファイルディスクリプターでなかった。
.TP
\fBEINVAL\fP
The fanotify file descriptor was opened with \fBFAN_CLASS_NOTIF\fP or the
fanotify group identifies filesystem objects by file handles and mask
contains a flag for permission events (\fBFAN_OPEN_PERM\fP or
\fBFAN_ACCESS_PERM\fP).
.TP
\fBENODEV\fP
The filesystem object indicated by \fIpathname\fP is not associated with a
filesystem that supports \fIfsid\fP (e.g., \fBtmpfs\fP(5)). This error can be
returned only with an fanotify group that identifies filesystem objects by
file handles.
.TP
\fBENOENT\fP
\fIdirfd\fP と \fIpathname\fP で指定されたファイルシステムオブジェクトが存在しない。
このエラーはマークされていないオブジェクトからマークを削除しようとした場合にも発生する。
.TP
\fBENOMEM\fP
必要なメモリーを割り当てできなかった。
.TP
\fBENOSPC\fP
マークの数が 8192 の上限を超過し、 \fBfanotify_init\fP(2) で fanotify ファイルディスクリプターが作成された際に
\fBFAN_UNLIMITED_MARKS\fP フラグが指定されていなかった。
.TP
\fBENOSYS\fP
このカーネルでは \fBfanotify_mark\fP() が実装されていない。 fanotify API が利用できるのは、 カーネルで
\fBCONFIG_FANOTIFY\fP が有効になっている場合だけである。
.TP
\fBENOTDIR\fP
\fIflags\fP に \fBFAN_MARK_ONLYDIR\fP が含まれているが、 \fIdirfd\fP と \fIpathname\fP
がディレクトリを指定していない。
.TP
\fBEOPNOTSUPP\fP
The object indicated by \fIpathname\fP is associated with a filesystem that
does not support the encoding of file handles. This error can be returned
only with an fanotify group that identifies filesystem objects by file
handles.
.TP
\fBEXDEV\fP
The filesystem object indicated by \fIpathname\fP resides within a filesystem
subvolume (e.g., \fBbtrfs\fP(5)) which uses a different \fIfsid\fP than its root
superblock. This error can be returned only with an fanotify group that
identifies filesystem objects by file handles.
.SH バージョン
\fBfanotify_mark\fP() は Linux カーネルのバージョン 2.6.36 で導入され、 バージョン 2.6.37 で有効になった。
.SH 準拠
このシステムコールは Linux 独自である。
.SH 注意
.SS "FAN_OPEN_EXEC と FAN_OPEN_EXEC_PERM"
When using either \fBFAN_OPEN_EXEC\fP or \fBFAN_OPEN_EXEC_PERM\fP within the
\fImask\fP, events of these types will be returned only when the direct
execution of a program occurs. More specifically, this means that events of
these types will be generated for files that are opened using \fBexecve\fP(2),
\fBexecveat\fP(2), or \fBuselib\fP(2). Events of these types will not be raised
in the situation where an interpreter is passed (or reads) a file for
interpretation.
.PP
Additionally, if a mark has also been placed on the Linux dynamic linker, a
user should also expect to receive an event for it when an ELF object has
been successfully opened using \fBexecve\fP(2) or \fBexecveat\fP(2).
.PP
For example, if the following ELF binary were to be invoked and a
\fBFAN_OPEN_EXEC\fP mark has been placed on /:
.PP
.in +4n
.EX
$ /bin/echo foo
.EE
.in
.PP
The listening application in this case would receive \fBFAN_OPEN_EXEC\fP events
for both the ELF binary and interpreter, respectively:
.PP
.in +4n
.EX
/bin/echo
/lib64/ld\-linux\-x86\-64.so.2
.EE
.in
.SH バグ
バージョン 3.16 より前の Linux カーネルでは以下のバグが存在した。
.IP * 3
.\" Fixed by commit 0a8dd2db579f7a0ac7033d6b857c3d5dbaa77563
\fIflags\fP に \fBFAN_MARK_FLUSH\fP が指定されている場合、 たとえそのオブジェクトが使用されない場合であっても、
\fIdirfd\fP と \fIpathname\fP には有効なファイルシステムオブジェクトを指定しなければならない。
.IP *
.\" Fixed by commit d4c7cf6cffb1bc711a833b5e304ba5bcfe76398b
\fBreaddir\fP(2) は \fBFAN_ACCESS\fP イベントを生成しない。
.IP *
.\" Fixed by commit cc299a98eb13a9853675a9cbb90b30b4011e1406
\fBfanotify_mark\fP() が \fBFAN_MARK_FLUSH\fP 付きで呼び出された場合、 \fIflags\fP
の値が無効かはチェックされない。
.SH 関連項目
\fBfanotify_init\fP(2), \fBfanotify\fP(7)
.SH この文書について
この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
\%https://www.kernel.org/doc/man\-pages/ に書かれている。
|