OSDN Git Service

(split) LDP: Update draft
[linuxjm/LDP_man-pages.git] / draft / man7 / inotify.7
index 9dcdb1f..c15071b 100644 (file)
@@ -1,8 +1,7 @@
-'\" t
-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
-.\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
+.\" t
+.\" Copyright (C) 2006, 2014 Michael Kerrisk <mtk.manpages@gmail.com>
 .\"
+.\" %%%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.
 .\"
 .\" 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.
+.\"
+.\"*******************************************************************
 .\"
 .\" Japanese Version Copyright (c) 2006 Yuichi SATO
 .\"     and Copyright (c) 2007-2008 Akihiro MOTOKI
 .\" Updated 2007-06-13, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.55
 .\" Updated 2008-08-10, Akihiro MOTOKI, LDP v3.05
 .\" Updated 2008-09-19, Akihiro MOTOKI, LDP v3.08
+.\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2012-05-01, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-07-22, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-08-21, Akihiro MOTOKI <amotoki@gmail.com>, LDP v3.53
 .\"
-.TH INOTIFY 7 2008-11-18 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH Ì¾Á°
-.\"O inotify \- monitoring file system events
-inotify \- ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¥¤¥Ù¥ó¥È¤ò´Æ»ë¤¹¤ë
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O The
-.\"O .I inotify
-.\"O API provides a mechanism for monitoring file system events.
-.I inotify
-API ¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¥¤¥Ù¥ó¥È¤ò´Æ»ë¤¹¤ë¤¿¤á¤Îµ¡¹½¤òÄ󶡤¹¤ë¡£
-.\"O Inotify can be used to monitor individual files,
-.\"O or to monitor directories.
-inotify ¤Ï¸Ä¡¹¤Î¥Õ¥¡¥¤¥ë¤ä¥Ç¥£¥ì¥¯¥È¥ê¤ò´Æ»ë¤¹¤ë¤Î¤Ë»È¤¨¤ë¡£
-.\"O When a directory is monitored, inotify will return events
-.\"O for the directory itself, and for files inside the directory.
-¥Ç¥£¥ì¥¯¥È¥ê¤ò´Æ»ë¤¹¤ë¾ì¹ç¡¢inotify ¤Ï¥Ç¥£¥ì¥¯¥È¥ê¼«¿È¤È
-¥Ç¥£¥ì¥¯¥È¥êÆâ¤Î¥Õ¥¡¥¤¥ë¤Î¥¤¥Ù¥ó¥È¤òÊÖ¤¹¡£
-
-.\"O The following system calls are used with this API:
-.\"O .BR inotify_init (2)
-.\"O (or
-.\"O .BR inotify_init1 (2)),
-.\"O .BR inotify_add_watch (2),
-.\"O .BR inotify_rm_watch (2),
-.\"O .BR read (2),
-.\"O and
-.\"O .BR close (2).
-°Ê²¼¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬¤³¤Î API ¤È¶¦¤Ë»ÈÍѤµ¤ì¤ë:
-.BR inotify_init (2)
-(¤ä
-.BR inotify_init1 (2)),
-.BR inotify_add_watch (2),
-.BR inotify_rm_watch (2),
-.BR read (2),
-.BR close (2).
+.TH INOTIFY 7 2014\-04\-01 Linux "Linux Programmer's Manual"
+.SH 名前
+inotify \- ファイルシステムイベントを監視する
+.SH 説明
+\fIinotify\fP API はファイルシステムイベントを監視するための機構を提供する。 inotify
+は個々のファイルやディレクトリを監視するのに使える。 ディレクトリを監視する場合、inotify はディレクトリ自身と
+ディレクトリ内のファイルのイベントを返す。
 
-.\"O .BR inotify_init (2)
-.\"O creates an inotify instance and returns a file descriptor
-.\"O referring to the inotify instance.
-.\"O The more recent
-.\"O .BR inotify_init1 (2)
-.\"O is like
-.\"O .BR inotify_init (2),
-.\"O but provides some extra functionality.
-.BR inotify_init (2)
-¤Ï inotify ¥¤¥ó¥¹¥¿¥ó¥¹¤òºîÀ®¤·¡¢inotify ¥¤¥ó¥¹¥¿¥ó¥¹¤ò»²¾È¤¹¤ë
-¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
-¤â¤Ã¤È¿·¤·¤¤
-.BR inotify_init1 (2)
-¤â
-.BR inotify_init (2)
-¤ÈƱÍͤÀ¤¬¡¢¤¤¤¯¤Ä¤«¤ÎÄɲäε¡Ç½¤¬Ä󶡤µ¤ì¤Æ¤¤¤ë¡£
+この API では以下のシステムコールが使用される。
+.IP * 3
+\fBinotify_init\fP(2)  は inotify インスタンスを作成し、inotify インスタンスを参照する ファイルディスクリプタを返す。
+もっと新しい \fBinotify_init1\fP(2)  も \fBinotify_init\fP(2)  と同様だが、いくつかの追加の機能を利用するための
+\fIflags\fP 引き数を持っている。
+.IP *
+\fBinotify_add_watch\fP(2)  は inotify インスタンスに関連づけられた「監視対象 (watch) リスト」を操作する。
+監視対象リストの各アイテム ("watch") は、 ファイルまたはディレクトリのパス名と、 そのパス名で参照されるファイルに対して
+カーネルが監視する複数のイベントの集合を指定する。 \fBinotify_add_watch\fP(2)
+は新しい監視アイテムの作成や既存の監視対象の変更ができる。 各監視対象は一意の「監視対象ディスクリプタ」を持つ。 これは監視対象を作成したときに
+\fBinotify_add_watch\fP(2)  から返される整数である。
+.IP *
+When events occur for monitored files and directories, those events are made
+available to the application as structured data that can be read from the
+inotify file descriptor using \fBread\fP(2)  (see below).
+.IP *
+\fBinotify_rm_watch\fP(2)  は inotify の監視対象リストからアイテムを削除する。
+.IP *
+inotify インスタンスを指している 全てのファイルディスクリプタが (\fBclose\fP(2) を使って) クローズされた場合、
+その下層にあるオブジェクトとそのリソースは、 カーネルで再利用するために解放される。 関連が切られた監視対象は自動的に解放される。
 
-.\"O .BR inotify_add_watch (2)
-.\"O manipulates the "watch list" associated with an inotify instance.
-.BR inotify_add_watch (2)
-¤Ï inotify ¥¤¥ó¥¹¥¿¥ó¥¹¤Ë´ØÏ¢¤Å¤±¤é¤ì¤¿¡Ö´Æ»ëÂоݠ(watch) ¥ê¥¹¥È¡×¤òÁàºî¤¹¤ë¡£
-.\"O Each item ("watch") in the watch list specifies the pathname of
-.\"O a file or directory,
-.\"O along with some set of events that the kernel should monitor for the
-.\"O file referred to by that pathname.
-´Æ»ëÂоݥꥹ¥È¤Î³Æ¥¢¥¤¥Æ¥à ("watch") ¤Ï¡¢
-¥Õ¥¡¥¤¥ë¤Þ¤¿¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Ñ¥¹Ì¾¤È¡¢
-¤½¤Î¥Ñ¥¹Ì¾¤Ç»²¾È¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ
-¥«¡¼¥Í¥ë¤¬´Æ»ë¤¹¤ëÊ£¿ô¤Î¥¤¥Ù¥ó¥È¤Î½¸¹ç¤ò»ØÄꤹ¤ë¡£
-.\"O .BR inotify_add_watch (2)
-.\"O either creates a new watch item, or modifies an existing watch.
-.BR inotify_add_watch (2)
-¤Ï¿·¤·¤¤´Æ»ë¥¢¥¤¥Æ¥à¤ÎºîÀ®¤ä´û¸¤Î´Æ»ëÂоݤÎÊѹ¹¤¬¤Ç¤­¤ë¡£
-.\"O Each watch has a unique "watch descriptor", an integer
-.\"O returned by
-.\"O .BR inotify_add_watch (2)
-.\"O when the watch is created.
-³Æ´Æ»ëÂоݤϰì°Õ¤Î¡Ö´Æ»ëÂоݥǥ£¥¹¥¯¥ê¥×¥¿¡×¤ò»ý¤Ä¡£
-¤³¤ì¤Ï´Æ»ëÂоݤòºîÀ®¤·¤¿¤È¤­¤Ë
-.BR inotify_add_watch (2)
-¤«¤éÊÖ¤µ¤ì¤ëÀ°¿ô¤Ç¤¢¤ë¡£
+With careful programming, an application can use inotify to efficiently
+monitor and cache the state of a set of filesystem objects.  However, robust
+applications should allow for the fact that bugs in the monitoring logic or
+races of the kind described below may leave the cache inconsistent with the
+filesystem state.  It is probably wise to to do some consistency checking,
+and rebuild the cache when inconsistencies are detected.
+.SS "inotify ファイルディスクリプタからのイベントの読み出し"
+どのようなイベントが起こっていたかを知るには、 アプリケーションで inotify ファイルディスクリプタを \fBread\fP(2)  すればよい。
+これまでに何もイベントが起こっていない場合、 停止 (blocking) モードのファイルディスクリプタであれば、 少なくとも 1
+つのイベントが起こるまで \fBread\fP(2)  は停止する (シグナルにより割り込まれなかった場合。
+シグナルによる割り込みがあった場合、呼び出しはエラー \fBEINTR\fP で失敗する。 \fBsignal\fP(7)  参照)。
 
-.\"O .BR inotify_rm_watch (2)
-.\"O removes an item from an inotify watch list.
-.BR inotify_rm_watch (2)
-¤Ï inotify ¤Î´Æ»ëÂоݥꥹ¥È¤«¤é¥¢¥¤¥Æ¥à¤òºï½ü¤¹¤ë¡£
-
-.\"O When all file descriptors referring to an inotify
-.\"O instance have been closed,
-.\"O the underlying object and its resources are
-.\"O freed for reuse by the kernel;
-.\"O all associated watches are automatically freed.
-inotify ¥¤¥ó¥¹¥¿¥ó¥¹¤ò»Ø¤·¤Æ¤¤¤ë
-Á´¤Æ¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬¥¯¥í¡¼¥º¤µ¤ì¤¿¾ì¹ç¡¢
-¤½¤Î²¼Áؤˤ¢¤ë¥ª¥Ö¥¸¥§¥¯¥È¤È¤½¤Î¥ê¥½¡¼¥¹¤Ï¡¢
-¥«¡¼¥Í¥ë¤ÇºÆÍøÍѤ¹¤ë¤¿¤á¤Ë²òÊü¤µ¤ì¤ë¡£
-´ØÏ¢¤¬ÀÚ¤é¤ì¤¿´Æ»ëÂоݤϼ«Æ°Åª¤Ë²òÊü¤µ¤ì¤ë¡£
-
-.\"O To determine what events have occurred, an application
-.\"O .BR read (2)s
-.\"O from the inotify file descriptor.
-¤É¤Î¤è¤¦¤Ê¥¤¥Ù¥ó¥È¤¬µ¯¤³¤Ã¤Æ¤¤¤¿¤«¤òÃΤë¤Ë¤Ï¡¢
-¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç inotify ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò
-.BR read (2)
-¤¹¤ì¤Ð¤è¤¤¡£
-.\"O If no events have so far occurred, then,
-.\"O assuming a blocking file descriptor,
-.\"O .BR read (2)
-.\"O will block until at least one event occurs
-.\"O (unless interrupted by a signal,
-.\"O in which case the call fails with the error
-.\"O .BR EINTR ;
-.\"O see
-.\"O .BR signal (7)).
-¤³¤ì¤Þ¤Ç¤Ë²¿¤â¥¤¥Ù¥ó¥È¤¬µ¯¤³¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
-Ää»ß (blocking) ¥â¡¼¥É¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ì¤Ð¡¢
-¾¯¤Ê¤¯¤È¤â 1 ¤Ä¤Î¥¤¥Ù¥ó¥È¤¬µ¯¤³¤ë¤Þ¤Ç
-.BR read (2)
-¤ÏÄä»ß¤¹¤ë (¥·¥°¥Ê¥ë¤Ë¤è¤ê³ä¤ê¹þ¤Þ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡£
-¥·¥°¥Ê¥ë¤Ë¤è¤ë³ä¤ê¹þ¤ß¤¬¤¢¤Ã¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¤Ï¥¨¥é¡¼
-.BR EINTR
-¤Ç¼ºÇÔ¤¹¤ë¡£
-.BR signal (7)
-»²¾È)¡£
-
-.\"O Each successful
-.\"O .BR read (2)
-.\"O returns a buffer containing one or more of the following structures:
-.BR read (2)
-¤¬À®¸ù¤¹¤ë¤È¡¢°Ê²¼¤Î¹½Â¤ÂΤò 1 ¤Ä°Ê¾å´Þ¤à¥Ð¥Ã¥Õ¥¡¤¬ÊÖ¤µ¤ì¤ë:
+\fBread\fP(2)  が成功すると、以下の構造体を 1 つ以上含むバッファが返される:
 .in +4n
 .nf
 
-struct inotify_event {
-.\"O     int      wd;       /* Watch descriptor */
-    int      wd;       /* ´Æ»ëÂоݥǥ£¥¹¥¯¥ê¥×¥¿ */
 .\" FIXME . The type of the 'wd' field should probably be "int32_t".
 .\" I submitted a patch to fix this.  See the LKML thread
 .\" "[patch] Fix type errors in inotify interfaces", 18 Nov 2008
 .\" Glibc bug filed: http://sources.redhat.com/bugzilla/show_bug.cgi?id=7040
-.\"O     uint32_t mask;     /* Mask of events */
-.\"O     uint32_t cookie;   /* Unique cookie associating related
-.\"O                           events (for rename(2)) */
-.\"O     uint32_t len;      /* Size of \(aqname\(aq field */
-.\"O     char     name[];   /* Optional null-terminated name */
-    uint32_t mask;     /* ¥¤¥Ù¥ó¥È¤Î¥Þ¥¹¥¯ */
-    uint32_t cookie;   /* ´ØÏ¢¤¹¤ë¥¤¥Ù¥ó¥È·²¤ò´ØÏ¢¤Å¤±¤ë
-                          °ì°Õ¤Ê¥¯¥Ã¥­¡¼ (rename(2) ÍÑ) */
-    uint32_t len;      /* \(aqname\(aq ¥Õ¥£¡¼¥ë¥É¤Î¥µ¥¤¥º */
-    char     name[];   /* NULL ¤Ç½ªÃ¼¤µ¤ì¤¿Ç¤°Õ¤Î̾Á° */
+struct inotify_event {
+    int      wd;       /* 監視対象ディスクリプタ */
+    uint32_t mask;     /* イベントのマスク */
+    uint32_t cookie;   /* 関連するイベント群を関連づける
+                          一意なクッキー (rename(2) 用) */
+    uint32_t len;      /* \(aqname\(aq フィールドのサイズ */
+    char     name[];   /* NULL で終端された任意の名前 */
 };
 .fi
 .in
 
-.\"O .I wd
-.\"O identifies the watch for which this event occurs.
-.\"O It is one of the watch descriptors returned by a previous call to
-.\"O .BR inotify_add_watch (2).
-.I wd
-¤Ï¥¤¥Ù¥ó¥ÈȯÀ¸¤Î´Æ»ëÂоݤò»ØÄꤹ¤ë¡£
-¤³¤ì¤Ï¡¢Á°¤â¤Ã¤Æ¹Ô¤ï¤ì¤¿
-.BR inotify_add_watch (2)
-¸Æ¤Ó½Ð¤·¤ÇÊÖ¤µ¤ì¤¿´Æ»ëÂоݥǥ£¥¹¥¯¥ê¥×¥¿¤Î¤¦¤Á¤Î 1 ¤Ä¤Ç¤¢¤ë¡£
+\fIwd\fP はイベント発生の監視対象を指定する。 これは、前もって行われた \fBinotify_add_watch\fP(2)
+呼び出しで返された監視対象ディスクリプタのうちの 1 つである。
 
-.\"O .I mask
-.\"O contains bits that describe the event that occurred (see below).
-.I mask
-¤Ë¤ÏȯÀ¸¤·¤¿¥¤¥Ù¥ó¥È (²¼µ­»²¾È) ¤òµ­½Ò¤¹¤ë¤¿¤á¤Î¥Ó¥Ã¥È¤¬´Þ¤Þ¤ì¤ë¡£
+\fImask\fP には発生したイベント (下記参照) を記述するためのビットが含まれる。
 
-.\"O .I cookie
-.\"O is a unique integer that connects related events.
-.I cookie
-¤Ï´ØÏ¢¤¹¤ë¥¤¥Ù¥ó¥È¤ò´ØÏ¢¤Å¤±¤ë¤¿¤á¤Î°ì°Õ¤ÊÀ°¿ô¤Ç¤¢¤ë¡£
-.\"O Currently this is only used for rename events, and
-.\"O allows the resulting pair of
-.\"O .B IN_MOVE_FROM
-.\"O and
-.\"O .B IN_MOVE_TO
-.\"O events to be connected by the application.
-¸½ºß¤Î¤È¤³¤í¡¢¤³¤ÎÃͤϠrename ¥¤¥Ù¥ó¥È¤ËÂФ·¤Æ¤Î¤ß»È¤ï¤ì¤Æ¤ª¤ê¡¢
-·ë²Ì¤Î¥Ú¥¢¤Ç¤¢¤ë
-.B IN_MOVE_FROM
-¤È
-.B IN_MOVE_TO
-¥¤¥Ù¥ó¥È¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç´ØÏ¢¤Å¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
+\fIcookie\fP は関連するイベントを関連づけるための一意な整数である。
+現在のところ、この値は rename イベントに対してのみ使われており、
+結果のペアである \fBIN_MOVED_FROM\fP と \fBIN_MOVED_TO\fP イベントを
+アプリケーションで関連づけることができる。
+他のイベント種別の場合には、 \fIcookie\fP は 0 に設定する。
 
-.\"O The
-.\"O .I name
-.\"O field is only present when an event is returned
-.\"O for a file inside a watched directory;
-.\"O it identifies the file pathname relative to the watched directory.
-.I name
-¥Õ¥£¡¼¥ë¥É¤Ï´Æ»ë¤·¤Æ¤¤¤ë¥Ç¥£¥ì¥¯¥È¥êÆâ¤Î¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ
-¥¤¥Ù¥ó¥È¤¬ÊÖ¤µ¤ì¤ë¾ì¹ç¤Î¤¿¤á¤Ë¤À¤±Â¸ºß¤¹¤ë¡£
-´Æ»ë¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤«¤é¤Î¥Õ¥¡¥¤¥ë¤ÎÁêÂХѥ¹Ì¾¤òɽ¤¹¡£
-.\"O This pathname is null-terminated,
-.\"O and may include further null bytes to align subsequent reads to a
-.\"O suitable address boundary.
-¤³¤Î¥Ñ¥¹Ì¾¤Ï NULL ¤Ç½ªÃ¼¤µ¤ì¡¢
-¤½¤Î¸å¤ÎÆɤ߹þ¤ß¤ÇŬÀڤʥ¢¥É¥ì¥¹¶­³¦¤ËÄ´À°¤¹¤ë¤¿¤á¤Ë¡¢
-¤µ¤é¤Ë NULL ¥Ð¥¤¥È¤¬´Þ¤Þ¤ì¤ë¾ì¹ç¤â¤¢¤ë¡£
+\fIname\fP フィールドは監視しているディレクトリ内のファイルに対して イベントが返される場合のためにだけ存在する。
+監視するディレクトリからのファイルの相対パス名を表す。 このパス名は NULL で終端され、 その後の読み込みで適切なアドレス境界に調整するために、
+さらに NULL バイト (\(aq\e0\(aq) が含まれる場合もある。
 
-.\"O The
-.\"O .I len
-.\"O field counts all of the bytes in
-.\"O .IR name ,
-.\"O including the null bytes;
-.\"O the length of each
-.\"O .I inotify_event
-.\"O structure is thus
-.\"O .IR "sizeof(inotify_event)+len" .
-.I len
-¥Õ¥£¡¼¥ë¥É¤Ï NULL ¥Ð¥¤¥È¤ò´Þ¤à
-.I name
-¤ÎÁ´¤Æ¤Î¥Ð¥¤¥È¿ô¤òɽ¤¹¡£
-¤è¤Ã¤Æ¡¢
-.I inotify_event
-¹½Â¤ÂΤΥµ¥¤¥º¤Ï
-.I "sizeof(inotify_event)+len"
-¤Ç¤¢¤ë¡£
+\fIlen\fP フィールドは NULL バイトを含む \fIname\fP の全てのバイト数を表す。
+よって、 \fIinotify_event\fP 構造体のサイズは
+\fIsizeof(struct inotify_event)+len\fP である。
 
-.\"O The behavior when the buffer given to
-.\"O .BR read (2)
-.\"O is too small to return information about the next event depends
-.\"O on the kernel version: in kernels before 2.6.21,
-.\"O .BR read (2)
-.\"O returns 0; since kernel 2.6.21,
-.\"O .BR read (2)
-.\"O fails with the error
-.\"O .BR EINVAL .
-.BR read (2)
-¤ËÅϤµ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤¬¾®¤µ¤¹¤®¤Æ¼¡¤Î¥¤¥Ù¥ó¥È¤Ë´Ø¤¹¤ë¾ðÊó¤òÊÖ¤»¤Ê¤¤
-¾ì¹ç¤ÎÆ°ºî¤Ï¥«¡¼¥Í¥ë¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤ê°Û¤Ê¤ë¡£
-2.6.21 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
-.BR read (2)
-¤Ï 0 ¤òÊÖ¤¹¡£
-2.6.21 °Ê¹ß¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
-.BR read (2)
-¤Ï¥¨¥é¡¼
-.B EINVAL
-¤Ç¼ºÇÔ¤¹¤ë¡£
-.\"O .SS inotify events
-.SS inotify ¥¤¥Ù¥ó¥È
-.\"O The
-.\"O .BR inotify_add_watch (2)
-.\"O .I mask
-.\"O argument and the
-.\"O .I mask
-.\"O field of the
-.\"O .I inotify_event
-.\"O structure returned when
-.\"O .BR read (2)ing
-.\"O an inotify file descriptor are both bit masks identifying
-.\"O inotify events.
-.BR inotify_add_watch (2)
-¤Î
-.I mask
-°ú¤­¿ô¤È¡¢inotify ¥Õ¥¡¥¤¥ë¹½Â¤ÂΤò
-.BR read (2)
-¤·¤¿¤È¤­¤ËÊÖ¤µ¤ì¤ë
-.I inotify_event
-¹½Â¤ÂΤÎ
-.I mask
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢¤È¤â¤Ë inotify ¥¤¥Ù¥ó¥È¤ò¼±Ê̤¹¤ë¤¿¤á¤Î
-¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¤¢¤ë¡£
-.\"O The following bits can be specified in
-.\"O .I mask
-.\"O when calling
-.\"O .BR inotify_add_watch (2)
-.\"O and may be returned in the
-.\"O .I mask
-.\"O field returned by
-.\"O .BR read (2):
-°Ê²¼¤Î¥Ó¥Ã¥È¤¬
-.BR inotify_add_watch (2)
-¤ò¸Æ¤Ö¤È¤­¤Î
-.I mask
-¤Ë»ØÄê²Äǽ¤Ç¤¢¤ê¡¢
-.BR read (2)
-¤ÇÊÖ¤µ¤ì¤ë
-.I mask
-¥Õ¥£¡¼¥ë¥É¤ÇÊÖ¤µ¤ì¤ë:
+\fBread\fP(2) に渡されたバッファが小さすぎて次のイベントに関する情報を返せ
+ない場合の動作はカーネルのバージョンにより異なる。 2.6.21 より前のカー
+ネルでは、 \fBread\fP(2) は 0 を返す。 2.6.21 以降のカーネルでは、
+\fBread\fP(2) はエラー \fBEINVAL\fP で失敗する。
+バッファサイズとして
+
+    sizeof(struct inotify_event) + NAME_MAX + 1
+
+を指定すれば、少なくとも 1 イベントで読み出しを行うには十分である。
+.SS "inotify イベント"
+\fBinotify_add_watch\fP(2)  の \fImask\fP 引き数と、inotify ファイル構造体を \fBread\fP(2)
+したときに返される \fIinotify_event\fP 構造体の \fImask\fP フィールドは、ともに inotify イベントを識別するための
+ビットマスクである。 以下のビットが \fBinotify_add_watch\fP(2)  を呼ぶときの \fImask\fP に指定可能であり、
+\fBread\fP(2)  で返される \fImask\fP フィールドで返される:
 .RS 4
-.sp
-.PD 0
-.TP 18
-.B IN_ACCESS
-.\"O File was accessed (read) (*).
-¥Õ¥¡¥¤¥ë¤¬¥¢¥¯¥»¥¹ (read) ¤µ¤ì¤¿¡£(*)
-.TP
-.B IN_ATTRIB
-.\"O Metadata changed, e.g., permissions, timestamps, extended attributes,
-.\"O link count (since Linux 2.6.25), UID, GID, etc. (*).
-¥á¥¿¥Ç¡¼¥¿¤¬Êѹ¹¤µ¤ì¤¿¡£
-¥á¥¿¥Ç¡¼¥¿¤È¤Ï¡¢Î㤨¤Ð¡¢µö²Ä (permission)¡¢¥¿¥¤¥à¥¹¥¿¥ó¥×¡¢³Èĥ°À­¡¢
-¥ê¥ó¥¯¥«¥¦¥ó¥È (Linux 2.6.25 °Ê¹ß)¡¢UID¡¢GID ¤Ê¤É¤Ç¤¢¤ë¡£(*)
-.TP
-.B IN_CLOSE_WRITE
-.\"O File opened for writing was closed (*).
-½ñ¤­¹þ¤ß¤Î¤¿¤á¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤¬¥¯¥í¡¼¥º¤µ¤ì¤¿¡£(*)
-.TP
-.B IN_CLOSE_NOWRITE
-.\"O File not opened for writing was closed (*).
-½ñ¤­¹þ¤ß°Ê³°¤Î¤¿¤á¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤¬¥¯¥í¡¼¥º¤µ¤ì¤¿¡£(*)
-.TP
-.B IN_CREATE
-.\"O File/directory created in watched directory (*).
-´Æ»ëÂоݥǥ£¥ì¥¯¥È¥êÆâ¤Ç¥Õ¥¡¥¤¥ë¤ä¥Ç¥£¥ì¥¯¥È¥ê¤¬ºîÀ®¤µ¤ì¤¿¡£(*)
-.TP
-.B IN_DELETE
-.\"O File/directory deleted from watched directory (*).
-´Æ»ëÂоݥǥ£¥ì¥¯¥È¥êÆâ¤Ç¥Õ¥¡¥¤¥ë¤ä¥Ç¥£¥ì¥¯¥È¥ê¤¬ºï½ü¤µ¤ì¤¿¡£(*)
-.TP
-.B IN_DELETE_SELF
-.\"O Watched file/directory was itself deleted.
-´Æ»ëÂоݤΥǥ£¥ì¥¯¥È¥ê¤Þ¤¿¤Ï¥Õ¥¡¥¤¥ë¼«¿È¤¬ºï½ü¤µ¤ì¤¿¡£
-.TP
-.B IN_MODIFY
-.\"O File was modified (*).
-¥Õ¥¡¥¤¥ë¤¬½¤Àµ¤µ¤ì¤¿¡£(*)
-.TP
-.B IN_MOVE_SELF
-.\"O Watched file/directory was itself moved.
-´Æ»ëÂоݤΥǥ£¥ì¥¯¥È¥ê¤Þ¤¿¤Ï¥Õ¥¡¥¤¥ë¼«¿È¤¬°ÜÆ°¤µ¤ì¤¿¡£
-.TP
-.B IN_MOVED_FROM
-.\"O File moved out of watched directory (*).
-¥Õ¥¡¥¤¥ë¤¬´Æ»ëÂоݥǥ£¥ì¥¯¥È¥ê³°¤Ø°ÜÆ°¤µ¤ì¤¿¡£(*)
-.TP
-.B IN_MOVED_TO
-.\"O File moved into watched directory (*).
-¥Õ¥¡¥¤¥ë¤¬´Æ»ëÂоݥǥ£¥ì¥¯¥È¥êÆâ¤Ø°ÜÆ°¤µ¤ì¤¿¡£(*)
-.TP
-.B IN_OPEN
-.\"O File was opened (*).
-¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤¿¡£(*)
-.PD
+.TP 
+\fBIN_ACCESS\fP (*)
+(\fBread\fP(2), \fBexecve\fP(2) などで) ファイルがアクセスされた。
+.TP 
+\fBIN_ATTRIB\fP (*)
+メタデータが変更された。 メタデータとは、例えば、アクセス許可 (\fBchmod\fP(2))、タイムスタンプ (\fButimensat\fP(2)
+など)、拡張属性 (\fBsetxattr\fP(2))、 リンクカウント (Linux 2.6.25 以降; \fBlink\fP(2) のリンク先や
+\fBunlink\fP(2) など)、ユーザー/グループ ID (\fBchown\fP(2) など) などである。
+.TP 
+\fBIN_CLOSE_WRITE\fP (*)
+書き込みのためにオープンされたファイルがクローズされた。
+.TP 
+\fBIN_CLOSE_NOWRITE\fP (*)
+書き込み以外のためにオープンされたファイルがクローズされた。
+.TP 
+\fBIN_CREATE\fP (*)
+監視対象ディレクトリ内でファイルやディレクトリが作成された (\fBopen\fP(2)  \fBO_CREAT\fP, \fBmkdir\fP(2),
+\fBlink\fP(2), \fBsymlink\fP(2), UNIX ドメインソケットに対する \fBbind\fP(2) など)。
+.TP 
+\fBIN_DELETE\fP (*)
+監視対象ディレクトリ内でファイルやディレクトリが削除された。
+.TP 
+\fBIN_DELETE_SELF\fP
+Watched file/directory was itself deleted.  (This event also occurs if an
+object is moved to another filesystem, since \fBmv\fP(1)  in effect copies the
+file to the other filesystem and then deletes it from the original
+filesystem.)  In addition, an \fBIN_IGNORED\fP event will subsequently be
+generated for the watch descriptor.
+.TP 
+\fBIN_MODIFY\fP (*)
+ファイルが変更された (\fBwrite\fP(2), \fBtruncate\fP(2) など)。
+.TP 
+\fBIN_MOVE_SELF\fP
+監視対象のディレクトリまたはファイル自身が移動された。
+.TP 
+\fBIN_MOVED_FROM\fP (*)
+ファイル名の変更を行った際に変更前のファイル名が含まれるディレクトリに対して生成される。
+.TP 
+\fBIN_MOVED_TO\fP (*)
+ファイル名の変更を行った際に新しいファイル名が含まれるディレクトリに対して生成される。
+.TP 
+\fBIN_OPEN\fP (*)
+ファイルがオープンされた。
 .RE
 .PP
-.\"O When monitoring a directory,
-.\"O the events marked with an asterisk (*) above can occur for
-.\"O files in the directory, in which case the
-.\"O .I name
-.\"O field in the returned
-.\"O .I inotify_event
-.\"O structure identifies the name of the file within the directory.
-¥Ç¥£¥ì¥¯¥È¥ê¤ò´Æ»ë¤¹¤ë¾ì¹ç¡¢
-¾åµ­¤Ç¥¢¥¹¥¿¥ê¥¹¥¯ (*) ¤òÉÕ¤±¤¿¥¤¥Ù¥ó¥È¤Ï¡¢
-¤½¤Î¥Ç¥£¥ì¥¯¥È¥êÆâ¤Î¥Õ¥¡¥¤¥ë¤ËÂФ·¤ÆȯÀ¸¤¹¤ë¡£
-¤³¤Î¤È¤­
-.I inotify_event
-¹½Â¤ÂΤÇÊÖ¤µ¤ì¤ë
-.I name
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Ç¥£¥ì¥¯¥È¥êÆâ¤Î¥Õ¥¡¥¤¥ë̾¤òɽ¤¹¡£
+ディレクトリを監視する場合、 上記でアスタリスク (*) を付けたイベントは、 そのディレクトリ内のファイルに対して発生する。 このとき
+\fIinotify_event\fP 構造体で返される \fIname\fP フィールドは、ディレクトリ内のファイル名を表す。
 .PP
-.\"O The
-.\"O .B IN_ALL_EVENTS
-.\"O macro is defined as a bit mask of all of the above events.
-.\"O This macro can be used as the
-.\"O .I mask
-.\"O argument when calling
-.\"O .BR inotify_add_watch (2).
-.B IN_ALL_EVENTS
-¥Þ¥¯¥í¤Ï¾åµ­¤Î¥¤¥Ù¥ó¥ÈÁ´¤Æ¤Î¥Þ¥¹¥¯¤È¤·¤ÆÄêµÁ¤µ¤ì¤ë¡£
-¤³¤Î¥Þ¥¯¥í¤Ï
-.BR inotify_add_watch (2)
-¤ò¸Æ¤Ó½Ð¤¹¤È¤­¤Î
-.I mask
-°ú¤­¿ô¤È¤·¤Æ»È¤¨¤ë¡£
+\fBIN_ALL_EVENTS\fP マクロは上記のイベント全てのマスクとして定義される。 このマクロは \fBinotify_add_watch\fP(2)
+を呼び出すときの \fImask\fP 引き数として使える。
 
-.\"O Two additional convenience macros are
-.\"O .BR IN_MOVE ,
-.\"O which equates to
-.\"O IN_MOVED_FROM|IN_MOVED_TO,
-.\"O and
-.\"O .B IN_CLOSE
-.\"O which equates to
-.\"O IN_CLOSE_WRITE|IN_CLOSE_NOWRITE.
-¤µ¤é¤Ë 2 ¤Ä¤ÎÊØÍø¤Ê¥Þ¥¯¥í¤¬¤¢¤ë¡£
-.B IN_MOVE
-¤Ï
-IN_MOVED_FROM|IN_MOVED_TO
-¤ÈÅù¤·¤¯¡¢
-.B IN_CLOSE
-¤Ï
-IN_CLOSE_WRITE|IN_CLOSE_NOWRITE
-¤ÈÅù¤·¤¤¡£
+以下の 2 つの便利なマクロが定義されている。
+.RS 4
+.TP 
+\fBIN_MOVE\fP
+\fBIN_MOVED_FROM | IN_MOVED_TO\fP と等価。
+.TP 
+\fBIN_CLOSE\fP
+\fBIN_CLOSE_WRITE | IN_CLOSE_NOWRITE\fP と等価。
+.RE
 .PP
-.\"O The following further bits can be specified in
-.\"O .I mask
-.\"O when calling
-.\"O .BR inotify_add_watch (2):
-¤½¤Î¾¤Ë¤â°Ê²¼¤Î¥Ó¥Ã¥È¤ò
-.BR inotify_add_watch (2)
-¤ò¸Æ¤Ö¤È¤­¤Î
-.I mask
-¤Ë»ØÄê¤Ç¤­¤ë:
+その他にも以下のビットを \fBinotify_add_watch\fP(2)  を呼ぶときの \fImask\fP に指定できる:
+.RS 4
+.TP 
+\fBIN_DONT_FOLLOW\fP (Linux 2.6.15 以降)
+\fIpathname\fP がシンボリックリンクである場合に辿らない。 (Linux 2.6.15 以降)
+.TP 
+\fBIN_EXCL_UNLINK\fP (Linux 2.6.36 以降)
+.\" commit 8c1934c8d70b22ca8333b216aec6c7d09fdbd6a6
+デフォルトでは、あるディレクトリの子ファイルに関するイベントを監視 (watch) した際、ディレクトリからその子ファイルが削除 (unlink)
+された場合であってもその子ファイルに対してイベントが生成される。このことは、アプリケーションによってはあまり興味のないイベントが大量に発生することにつながる
+(例えば、\fI/tmp\fP を監視している場合、たくさんのアプリケーションが、すぐにその名前が削除される一時ファイルをそのディレクトリに作成する)。
+\fBIN_EXCL_UNLINK\fP
+を指定するとこのデフォルトの動作を変更でき、監視対象のディレクトリから子ファイルが削除された後に子ファイルに関するイベントが生成されなくなる。
+.TP 
+\fBIN_MASK_ADD\fP
+\fIpathname\fP に対する監視マスクが既に存在する場合、 (マスクの置き換えではなく) イベントを追加 (OR) する。
+.TP 
+\fBIN_ONESHOT\fP
+1 つのイベントについて \fIpathname\fP を監視し、 イベントが発生したら監視対象リストから削除する。
+.TP 
+\fBIN_ONLYDIR\fP (Linux 2.6.15 以降)
+\fIpathname\fP がディレクトリの場合にのみ監視する。
+.RE
+.PP
+以下のビットが \fBread\fP(2)  で返される \fImask\fP フィールドに設定される:
+.RS 4
+.TP 
+\fBIN_IGNORED\fP
+監視対象が (\fBinotify_rm_watch\fP(2) により) 明示的に 削除された。もしくは (ファイルの削除、またはファイル
+システムのアンマウントにより) 自動的に削除された。「バグ」も参照のこと。
+.TP 
+\fBIN_ISDIR\fP
+このイベントの対象がディレクトリである。
+.TP 
+\fBIN_Q_OVERFLOW\fP
+イベントキューが溢れた (このイベントの場合、\fIwd\fP は \-1 である)。
+.TP 
+\fBIN_UNMOUNT\fP
+監視対象オブジェクトを含むファイルシステムがアンマウントされた。さらに、この監視対象ディスクリプタに対して \fBIN_IGNORED\fP
+イベントが生成される。
+.RE
+.SS 例
+Suppose an application is watching the directory \fIdir\fP and the file
+\fIdir/myfile\fP for all events.  The examples below show some events that will
+be generated for these two objects.
 .RS 4
-.sp
-.PD 0
-.TP 18
-.B IN_DONT_FOLLOW
-.\"O Don't dereference \fIpathname\fP if it is a symbolic link
-.\"O (since Linux 2.6.15).
-\fIpathname\fP ¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Ç¤¢¤ë¾ì¹ç¤Ëé¤é¤Ê¤¤¡£
-(Linux 2.6.15 °Ê¹ß)
-.TP
-.B IN_MASK_ADD
-.\"O Add (OR) events to watch mask for this pathname if
-.\"O it already exists (instead of replacing mask).
-\fIpathname\fP ¤ËÂФ¹¤ë´Æ»ë¥Þ¥¹¥¯¤¬´û¤Ë¸ºß¤¹¤ë¾ì¹ç¡¢
-(¥Þ¥¹¥¯¤ÎÃÖ¤­´¹¤¨¤Ç¤Ï¤Ê¤¯) ¥¤¥Ù¥ó¥È¤òÄɲà(OR) ¤¹¤ë¡£
-.TP
-.B IN_ONESHOT
-.\"O Monitor \fIpathname\fP for one event, then remove from
-.\"O watch list.
-1 ¤Ä¤Î¥¤¥Ù¥ó¥È¤Ë¤Ä¤¤¤Æ \fIpathname\fP ¤ò´Æ»ë¤·¡¢
-¥¤¥Ù¥ó¥È¤¬È¯À¸¤·¤¿¤é´Æ»ëÂоݥꥹ¥È¤«¤éºï½ü¤¹¤ë¡£
-.TP
-.\"O .BR IN_ONLYDIR " (since Linux 2.6.15)"
-.BR IN_ONLYDIR " (Linux 2.6.15 °Ê¹ß)"
-.\"O Only watch \fIpathname\fP if it is a directory.
-\fIpathname\fP ¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç¤Ë¤Î¤ß´Æ»ë¤¹¤ë¡£
-.PD
+.TP 
+fd = open("dir/myfile", O_RDWR);
+\fIdir\fP と \fIdir/myfile\fP の両方に対して \fBIN_OPEN\fP イベントが生成される。
+.TP 
+read(fd, buf, count);
+\fIdir\fP と \fIdir/myfile\fP の両方に対して \fBIN_ACCESS\fP イベントが生成される
+.TP 
+write(fd, buf, count);
+\fIdir\fP と \fIdir/myfile\fP の両方に対して \fBIN_MODIFY\fP イベントが生成される
+.TP 
+fchmod(fd, mode);
+\fIdir\fP と \fIdir/myfile\fP の両方に対して \fBIN_ATTRIB\fP イベントが生成される
+.TP 
+close(fd);
+\fIdir\fP と \fIdir/myfile\fP の両方に対して \fBIN_CLOSE_WRITE\fP イベントが生成される
 .RE
 .PP
-.\"O The following bits may be set in the
-.\"O .I mask
-.\"O field returned by
-.\"O .BR read (2):
-°Ê²¼¤Î¥Ó¥Ã¥È¤¬
-.BR read (2)
-¤ÇÊÖ¤µ¤ì¤ë
-.I mask
-¥Õ¥£¡¼¥ë¥É¤ËÀßÄꤵ¤ì¤ë:
+Suppose an application is watching the directories \fIdir1\fP and \fIdir\fP, and
+the file \fIdir1/myfile\fP.  The following examples show some events that may
+be generated.
 .RS 4
-.sp
-.PD 0
-.TP 18
-.B IN_IGNORED
-.\"O Watch was removed explicitly (\fBinotify_rm_watch\fP(2))
-.\"O or automatically (file was deleted, or file system was unmounted).
-´Æ»ëÂоݤ¬ (\fBinotify_rm_watch\fP(2) ¤Ë¤è¤ê) ÌÀ¼¨Åª¤Ë
-ºï½ü¤µ¤ì¤¿¡£¤â¤·¤¯¤Ï (¥Õ¥¡¥¤¥ë¤Îºï½ü¡¢¤Þ¤¿¤Ï¥Õ¥¡¥¤¥ë
-¥·¥¹¥Æ¥à¤Î¥¢¥ó¥Þ¥¦¥ó¥È¤Ë¤è¤ê) ¼«Æ°Åª¤Ëºï½ü¤µ¤ì¤¿¡£
-.TP
-.B IN_ISDIR
-.\"O Subject of this event is a directory.
-¤³¤Î¥¤¥Ù¥ó¥È¤ÎÂоݤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤¢¤ë¡£
-.TP
-.B IN_Q_OVERFLOW
-.\"O Event queue overflowed (\fIwd\fP is \-1 for this event).
-¥¤¥Ù¥ó¥È¥­¥å¡¼¤¬°î¤ì¤¿ (¤³¤Î¥¤¥Ù¥ó¥È¤Î¾ì¹ç¡¢\fIwd\fP ¤Ï \-1 ¤Ç¤¢¤ë)¡£
-.TP
-.B IN_UNMOUNT
-.\"O File system containing watched object was unmounted.
-´Æ»ëÂоݥª¥Ö¥¸¥§¥¯¥È¤ò´Þ¤à¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬¥¢¥ó¥Þ¥¦¥ó¥È¤µ¤ì¤¿¡£
-.PD
+.TP 
+link("dir/myfile", "dir2/new");
+\fImyfile\fP に対して \fBIN_ATTRIB\fP イベントが生成され、 \fIdir2\fP に対して \fBIN_CREATE\fP イベントが生成される。
+.TP 
+rename("dir1/myfile", "dir2/myfile");
+\fIdir1\fP に対してイベント \fBIN_MOVED_FROM\fP が、 \fIdir2\fP に対してイベント \fBIN_MOVED_TO\fP が、
+\fImyfile\fP に対してイベント \fBIN_MOVE_SELF\fP が生成される。この際 イベント \fBIN_MOVED_FROM\fP と
+\fBIN_MOVED_TO\fP は同じ \fIcookie\fP 値を持つ。
 .RE
-.\"O .SS /proc interfaces
-.SS /proc ¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹
-.\"O The following interfaces can be used to limit the amount of
-.\"O kernel memory consumed by inotify:
-°Ê²¼¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ï¡¢inotify ¤Ç¾ÃÈñ¤µ¤ì¤ë
-¥«¡¼¥Í¥ë¥á¥â¥ê¤ÎÁíÎ̤òÀ©¸Â¤¹¤ë¤Î¤Ë»ÈÍѤǤ­¤ë:
-.TP
-.I /proc/sys/fs/inotify/max_queued_events
-.\"O The value in this file is used when an application calls
-.\"O .BR inotify_init (2)
-.\"O to set an upper limit on the number of events that can be
-.\"O queued to the corresponding inotify instance.
-¤³¤Î¥Õ¥¡¥¤¥ë¤ÎÃͤϡ¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬
-.BR inotify_init (2)
-¤ò¸Æ¤Ó½Ð¤¹¤È¤­¤Ë»ÈÍѤµ¤ì¡¢Âбþ¤¹¤ë inotify ¥¤¥ó¥¹¥¿¥ó¥¹¤Ë¤Ä¤¤¤Æ
-¥­¥å¡¼¤ËÆþ¤ì¤é¤ì¤ë¥¤¥Ù¥ó¥È¤Î¿ô¤Î¾å¸Â¤òÀßÄꤹ¤ë¡£
-.\"O Events in excess of this limit are dropped, but an
-.\"O .B IN_Q_OVERFLOW
-.\"O event is always generated.
-¤³¤ÎÀ©¸Â¤òĶ¤¨¤¿¥¤¥Ù¥ó¥È¤ÏÇË´þ¤µ¤ì¤ë¤¬¡¢
-.B IN_Q_OVERFLOW
-¥¤¥Ù¥ó¥È¤¬¾ï¤ËÀ¸À®¤µ¤ì¤ë¡£
-.TP
-.I /proc/sys/fs/inotify/max_user_instances
-.\"O This specifies an upper limit on the number of inotify instances
-.\"O that can be created per real user ID.
-1 ¤Ä¤Î¼Â¥æ¡¼¥¶ ID ¤ËÂФ·¤ÆÀ¸À®¤Ç¤­¤ë
-inotify ¥¤¥ó¥¹¥¿¥ó¥¹¤Î¿ô¤Î¾å¸Â¤ò»ØÄꤹ¤ë¡£
-.TP
-.I /proc/sys/fs/inotify/max_user_watches
-.\"O This specifies an upper limit on the number of watches
-.\"O that can be created per real user ID.
-ºîÀ®²Äǽ¤Ê´Æ»ëÂоݤοô¤Î¼Â UID Ã±°Ì¤Î¾å¸Â¤ò»ØÄꤹ¤ë¡£
-.\"O .SH "VERSIONS"
-.SH ¥Ð¡¼¥¸¥ç¥ó
-.\"O Inotify was merged into the 2.6.13 Linux kernel.
-.\"O The required library interfaces were added to glibc in version 2.4.
-.\"O .RB ( IN_DONT_FOLLOW ,
-.\"O .BR IN_MASK_ADD ,
-.\"O and
-.\"O .B IN_ONLYDIR
-.\"O were only added in version 2.5.)
-inotify ¤Ï 2.6.13 ¤Î Linux ¥«¡¼¥Í¥ë¤ËÁȹþ¤Þ¤ì¤¿¡£
-¤³¤ì¤ËɬÍפʥ饤¥Ö¥é¥ê¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ï¡¢
-glibc ¤Î¥Ð¡¼¥¸¥ç¥ó 2.4 ¤ËÄɲ䵤줿
-.RB ( IN_DONT_FOLLOW ,
-.BR IN_MASK_ADD ,
-.B IN_ONLYDIR
-¤À¤±¤Ï¥Ð¡¼¥¸¥ç¥ó 2.5 ¤ÇÄɲ䵤줿)¡£
-.\"O .SH "CONFORMING TO"
-.SH ½àµò
-.\"O The inotify API is Linux-specific.
-inotify API ¤Ï Linux Æȼ«¤Î¤â¤Î¤Ç¤¢¤ë¡£
-.\"O .SH "NOTES"
-.SH Ãí°Õ
-.\"O Inotify file descriptors can be monitored using
-.\"O .BR select (2),
-.\"O .BR poll (2),
-.\"O and
-.\"O .BR epoll (7).
-inotify ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï
-.BR select (2),
-.BR poll (2),
-.BR epoll (7)
-¤ò»È¤Ã¤Æ´Æ»ë¤Ç¤­¤ë¡£
-.\"O When an event is available, the file descriptor indicates as readable.
-¥¤¥Ù¥ó¥È¤¬¤¢¤ë¾ì¹ç¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÏÆɤ߹þ¤ß²Äǽ¤ÈÄÌÃΤ¹¤ë¡£
+.PP
+Suppose that \fIdir1/xx\fP and \fIdir2/yy\fP are (the only) links to the same
+file, and an application is watching \fIdir1\fP, \fIdir2\fP, \fIdir1/xx\fP, and
+\fIdir2/yy\fP.  Executing the following calls in the order given below will
+generate the following events:
+.RS 4
+.TP 
+unlink("dir2/yy");
+Generates \fBIN_ATTRIB\fP event for \fIxx\fP (because its link count changes)  and
+an \fBIN_DELETE\fP event for \fIdir2\fP.
+.TP 
+unlink("dir1/xx");
+Generates \fBIN_ATTRIB\fP, \fBIN_DELETE_SELF\fP, and \fBIN_IGNORED\fP events for
+\fIxx\fP, and an \fBIN_DELETE\fP for \fIdir1\fP.
+.RE
+.PP
+Suppose an application is watching the directory \fIdir\fP and (the empty)
+directory \fIdir/subdir\fP.  The following examples show some events that may
+be generated.
+.RS 4
+.TP 
+mkdir("dir/new", mode);
+Generates an \fBIN_CREATE | IN_ISDIR\fP event for \fIdir\fP.
+.TP 
+rmdir("dir/sub");
+Generates \fBIN_DELETE_SELF\fP and \fBIN_IGNORED\fP events for \fIsubdir\fP, and an
+\fBIN_DELETE | IN_ISDIR\fP event for \fIdir\fP.
+.RE
+.SS "/proc インターフェース"
+以下のインターフェースは、inotify で消費される カーネルメモリの総量を制限するのに使用できる:
+.TP 
+\fI/proc/sys/fs/inotify/max_queued_events\fP
+このファイルの値は、アプリケーションが \fBinotify_init\fP(2)  を呼び出すときに使用され、対応する inotify インスタンスについて
+キューに入れられるイベントの数の上限を設定する。 この制限を超えたイベントは破棄されるが、 \fBIN_Q_OVERFLOW\fP イベントが常に生成される。
+.TP 
+\fI/proc/sys/fs/inotify/max_user_instances\fP
+1 つの実ユーザ ID に対して生成できる inotify インスタンスの数の上限を指定する。
+.TP 
+\fI/proc/sys/fs/inotify/max_user_watches\fP
+作成可能な監視対象の数の実 UID 単位の上限を指定する。
+.SH バージョン
+inotify は 2.6.13 の Linux カーネルに組込まれた。 これに必要なライブラリのインターフェースは、 glibc のバージョン 2.4
+に追加された (\fBIN_DONT_FOLLOW\fP, \fBIN_MASK_ADD\fP, \fBIN_ONLYDIR\fP は glibc バージョン 2.5
+で追加された)。
+.SH 準拠
+inotify API は Linux 独自のものである。
+.SH 注意
+inotify ファイルディスクリプタは \fBselect\fP(2), \fBpoll\fP(2), \fBepoll\fP(7)  を使って監視できる。
+イベントがある場合、ファイルディスクリプタは読み込み可能と通知する。
+
+Linux 2.6.25 以降では、シグナル駆動 (signal\-driven) I/O の通知が inotify
+ファイルディスクリプタについて利用可能である。 \fBfcntl\fP(2)  に書かれている (\fBO_ASYNC\fP フラグを設定するための)
+\fBF_SETFL\fP, \fBF_SETOWN\fP, \fBF_SETSIG\fP の議論を参照のこと。 シグナルハンドラに渡される \fIsiginfo_t\fP
+構造体は、以下のフィールドが設定される (\fIsiginfo_t\fP は \fBsigaction\fP(2)  で説明されている)。 \fIsi_fd\fP には
+inotify ファイルディスクリプタ番号が、 \fIsi_signo\fP にはシグナル番号が、 \fIsi_code\fP には \fBPOLL_IN\fP が、
+\fIsi_band\fP には \fBPOLLIN\fP が設定される。
+
+If successive output inotify events produced on the inotify file descriptor
+are identical (same \fIwd\fP, \fImask\fP, \fIcookie\fP, and \fIname\fP), then they are
+coalesced into a single event if the older event has not yet been read (but
+see BUGS).  This reduces the amount of kernel memory required for the event
+queue, but also means that an application can't use inotify to reliably
+count file events.
+
+inotify ファイルディスクリプタの読み込みで返されるイベントは、 順序付けられたキューになる。
+従って、たとえば、あるディレクトリの名前を別の名前に変更した場合、 inotify ファイルディスクリプタについての正しい順番で
+イベントが生成されることが保証される。
 
-.\"O Since Linux 2.6.25,
-.\"O signal-driven I/O notification is available for inotify file descriptors;
-.\"O see the discussion of
-.\"O .B F_SETFL
-.\"O (for setting the
-.\"O .B O_ASYNC
-.\"O flag),
-.\"O .BR F_SETOWN ,
-.\"O and
-.\"O .B F_SETSIG
-.\"O in
-.\"O .BR fcntl (2).
-Linux 2.6.25 °Ê¹ß¤Ç¤Ï¡¢¥·¥°¥Ê¥ë¶îÆ° (signal-driven) I/O ¤ÎÄÌÃΤ¬
-inotify ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë¤Ä¤¤¤ÆÍøÍѲÄǽ¤Ç¤¢¤ë¡£
-.BR fcntl (2)
-¤Ë½ñ¤«¤ì¤Æ¤¤¤ë
-.RB ( O_ASYNC
-¥Õ¥é¥°¤òÀßÄꤹ¤ë¤¿¤á¤Î)
-.BR F_SETFL ,
-.BR F_SETOWN ,
-.B F_SETSIG
-¤ÎµÄÏÀ¤ò»²¾È¤Î¤³¤È¡£
-.\"O The
-.\"O .I siginfo_t
-.\"O structure (described in
-.\"O .BR sigaction (2))
-.\"O that is passed to the signal handler has the following fields set:
-.\"O .IR si_fd
-.\"O is set to the inotify file descriptor number;
-.\"O .IR si_signo
-.\"O is set to the signal number;
-.\"O .IR si_code
-.\"O is set to
-.\"O .BR POLL_IN ;
-.\"O and
-.\"O .B POLLIN
-.\"O is set in
-.\"O .IR si_band .
-¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ËÅϤµ¤ì¤ë
-.I siginfo_t
-¹½Â¤ÂΤϡ¢°Ê²¼¤Î¥Õ¥£¡¼¥ë¥É¤¬ÀßÄꤵ¤ì¤ë
-.RI ( siginfo_t
-¤Ï
-.BR sigaction (2)
-¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë)¡£
-.I si_fd
-¤Ë¤Ï inotify ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿Èֹ椬¡¢
-.I si_signo
-¤Ë¤Ï¥·¥°¥Ê¥ëÈֹ椬¡¢
-.I si_code
-¤Ë¤Ï
-.BR POLL_IN
-¤¬¡¢
-.I si_band
-¤Ë¤Ï
-.B POLLIN
-¤¬ÀßÄꤵ¤ì¤ë¡£
+\fBFIONREAD\fP \fBioctl\fP(2)  は inotify ファイルディスクリプタから何バイト読み込めるかを返す。
+.SS 制限と警告
+inotify API では、inotify イベントが発生するきっかけとなったユーザやプロセスに関する情報は提供されない。とりわけ、inotify
+経由でイベントを監視しているプロセスが、自分自身がきっかけとなったイベントと他のプロセスがきっかけとなったイベントを区別する簡単な手段はない。
 
-.\"O If successive output inotify events produced on the
-.\"O inotify file descriptor are identical (same
-.\"O .IR wd ,
-.\"O .IR mask ,
-.\"O .IR cookie ,
-.\"O and
-.\"O .IR name )
-.\"O then they are coalesced into a single event if the
-.\"O older event has not yet been read (but see BUGS).
-inotify ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ
-Ϣ³¤·¤ÆÀ¸À®¤µ¤ì¤ë½ÐÎÏ inotify ¥¤¥Ù¥ó¥È¤¬Æ±°ì¤Î¾ì¹ç
-.RI ( wd ,
-.IR mask ,
-.IR cookie ,
-.I name
-¤¬Åù¤·¤¤¾ì¹ç)¡¢
-Á°¤Î¥¤¥Ù¥ó¥È¤¬¤Þ¤ÀÆɤ߹þ¤Þ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
-Ϣ³¤¹¤ë¥¤¥Ù¥ó¥È¤¬ 1 ¤Ä¤Î¥¤¥Ù¥ó¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë
-(¤¿¤À¤·¡Ö¥Ð¥°¡×¤ÎÀá¤â»²¾È¤Î¤³¤È)¡£
+Inotify reports only events that a user\-space program triggers through the
+filesystem API.  As a result, it does not catch remote events that occur on
+network filesystems.  (Applications must fall back to polling the filesystem
+to catch such events.)  Furthermore, various pseudo\-filesystems such as
+\fI/proc\fP, \fI/sys\fP, and \fI/dev/pts\fP are not monitorable with inotify.
 
-.\"O The events returned by reading from an inotify file descriptor
-.\"O form an ordered queue.
-.\"O Thus, for example, it is guaranteed that when renaming from
-.\"O one directory to another, events will be produced in the
-.\"O correct order on the inotify file descriptor.
-.\"Osato:
-.\"Osato: °Ê²¼¤ÎÌõ¤¬¾å¼ê¤¯¤Ç¤­¤Æ¤¤¤Ê¤¤µ¤¤¬¤¹¤ë¡£
-.\"Osato:
-inotify ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÆɤ߹þ¤ß¤ÇÊÖ¤µ¤ì¤ë¥¤¥Ù¥ó¥È¤Ï¡¢
-½ç½øÉÕ¤±¤é¤ì¤¿¥­¥å¡¼¤Ë¤Ê¤ë¡£
-½¾¤Ã¤Æ¡¢¤¿¤È¤¨¤Ð¡¢¤¢¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Î̾Á°¤òÊ̤Î̾Á°¤ËÊѹ¹¤·¤¿¾ì¹ç¡¢
-inotify ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë¤Ä¤¤¤Æ¤ÎÀµ¤·¤¤½çÈÖ¤Ç
-¥¤¥Ù¥ó¥È¤¬À¸À®¤µ¤ì¤ë¤³¤È¤¬Êݾڤµ¤ì¤ë¡£
+The inotify API does not report file accesses and modifications that may
+occur because of \fBmmap\fP(2)  and \fBmsync\fP(2).
+
+inotify API では影響が受けるファイルをファイル名で特定する。
+しかしながら、アプリケーションが inotify イベントを処理する時点では、
+そのファイル名がすでに削除されたり変更されたりしている可能性がある。
+
+The inotify API identifies events via watch descriptors.  It is the
+application's responsibility to cache a mapping (if one is needed) between
+watch descriptors and pathnames.  Be aware that directory renamings may
+affect multiple cached pathnames.
+
+inotify によるディレクトリの監視は再帰的に行われない: あるディレクトリ以下の
+サブディレクトリを監視する場合、 監視対象を追加で作成しなければならない。
+大きなディレクトリツリーの場合には、この作業にかなり時間がかかることがある。
+
+If monitoring an entire directory subtree, and a new subdirectory is created
+in that tree or an existing directory is renamed into that tree, be aware
+that by the time you create a watch for the new subdirectory, new files (and
+subdirectories) may already exist inside the subdirectory.  Therefore, you
+may want to scan the contents of the subdirectory immediately after adding
+the watch (and, if desired, recursively add watches for any subdirectories
+that it contains).
+
+Note that the event queue can overflow.  In this case, events are lost.
+Robust applications should handle the possibility of lost events
+gracefully.  For example, it may be necessary to rebuild part or all of the
+application cache.  (One simple, but possibly expensive, approach is to
+close the inotify file descriptor, empty the cache, create a new inotify
+file descriptor, and then re\-create watches and cache entries for the
+objects to be monitored.)
+.SS "rename() イベントの取り扱い"
+As noted above, the \fBIN_MOVED_FROM\fP and \fBIN_MOVED_TO\fP event pair that is
+generated by \fBrename\fP(2)  can be matched up via their shared cookie value.
+However, the task of matching has some challenges.
+
+These two events are usually consecutive in the event stream available when
+reading from the inotify file descriptor.  However, this is not guaranteed.
+If multiple processes are triggering events for monitored objects, then (on
+rare occasions) an arbitrary number of other events may appear between the
+\fBIN_MOVED_FROM\fP and \fBIN_MOVED_TO\fP events.
+
+Matching up the \fBIN_MOVED_FROM\fP and \fBIN_MOVED_TO\fP event pair generated by
+\fBrename\fP(2)  is thus inherently racy.  (Don't forget that if an object is
+renamed outside of a monitored directory, there may not even be an
+\fBIN_MOVED_TO\fP event.)  Heuristic approaches (e.g., assume the events are
+always consecutive)  can be used to ensure a match in most cases, but will
+inevitably miss some cases, causing the application to perceive the
+\fBIN_MOVED_FROM\fP and \fBIN_MOVED_TO\fP events as being unrelated.  If watch
+descriptors are destroyed and re\-created as a result, then those watch
+descriptors will be inconsistent with the watch descriptors in any pending
+events.  (Re\-creating the inotify file descriptor and rebuilding the cache
+may be useful to deal with this scenario.)
+
+Applications should also allow for the possibility that the \fBIN_MOVED_FROM\fP
+event was the last event that could fit in the buffer returned by the
+current call to \fBread\fP(2), and the accompanying \fBIN_MOVED_TO\fP event might
+be fetched only on the next \fBread\fP(2).
+.SH バグ
+.\" FIXME kernel commit 611da04f7a31b2208e838be55a42c7a1310ae321
+.\" implies that unmount events were buggy 2.6.11 to 2.6.36
+.\"
+2.6.16 以前のカーネルでは \fBIN_ONESHOT\fP \fImask\fP フラグが働かない。
 
-.\"O The
-.\"O .B FIONREAD
-.\"O .BR ioctl (2)
-.\"O returns the number of bytes available to read from an
-.\"O inotify file descriptor.
-.B FIONREAD
-.BR ioctl (2)
-¤Ï inotify ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤«¤é²¿¥Ð¥¤¥ÈÆɤ߹þ¤á¤ë¤«¤òÊÖ¤¹¡£
+As originally designed and implemented, the \fBIN_ONESHOT\fP flag did not cause
+an \fBIN_IGNORED\fP event to be generated when the watch was dropped after one
+event.  However, as an unintended effect of other changes, since Linux
+2.6.36, an \fBIN_IGNORED\fP event is generated in this case.
 
-.\"O Inotify monitoring of directories is not recursive:
-.\"O to monitor subdirectories under a directory,
-.\"O additional watches must be created.
-inotify ¤Ë¤è¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Î´Æ»ë¤ÏºÆµ¢Åª¤Ë¹Ô¤ï¤ì¤Ê¤¤:
-¤¢¤ë¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤ò´Æ»ë¤¹¤ë¾ì¹ç¡¢
-´Æ»ëÂоݤòÄɲäǺîÀ®¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
-.\"O .SH "BUGS"
-.SH ¥Ð¥°
-.\"O In kernels before 2.6.16, the
-.\"O .B IN_ONESHOT
-.\"O .I mask
-.\"O flag does not work.
-2.6.16 °ÊÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï
-.B IN_ONESHOT
-.I mask
-¥Õ¥é¥°¤¬Æ¯¤«¤Ê¤¤¡£
+.\" commit 1c17d18e3775485bf1e0ce79575eb637a94494a2
+カーネル 2.6.25 より前では、 連続する同一のイベントを一つにまとめることを意図したコード (古い方のイベントがまだ読み込まれていない場合に、
+最新の 2 つのイベントを一つにまとめられる可能性がある) が、 最新のイベントが「最も古い」読み込まれていないイベントとまとめられるか
+をチェックするようになっていた。
+.SH 関連項目
+\fBinotifywait\fP(1), \fBinotifywatch\fP(1), \fBinotify_add_watch\fP(2),
+\fBinotify_init\fP(2), \fBinotify_init1\fP(2), \fBinotify_rm_watch\fP(2), \fBread\fP(2),
+\fBstat\fP(2)
 
-.\"O Before kernel 2.6.25,
-.\"O the kernel code that was intended to coalesce successive identical events
-.\"O (i.e., the two most recent events could potentially be coalesced
-.\"O if the older had not yet been read)
-.\"O instead checked if the most recent event could be coalesced with the
-.\"O .I oldest
-.\"O unread event.
-¥«¡¼¥Í¥ë 2.6.25 ¤è¤êÁ°¤Ç¤Ï¡¢
-Ϣ³¤¹¤ëƱ°ì¤Î¥¤¥Ù¥ó¥È¤ò°ì¤Ä¤Ë¤Þ¤È¤á¤ë¤³¤È¤ò°Õ¿Þ¤·¤¿¥³¡¼¥É
-(¸Å¤¤Êý¤Î¥¤¥Ù¥ó¥È¤¬¤Þ¤ÀÆɤ߹þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¡¢
-ºÇ¿·¤Î 2 ¤Ä¤Î¥¤¥Ù¥ó¥È¤ò°ì¤Ä¤Ë¤Þ¤È¤á¤é¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë) ¤¬¡¢
-ºÇ¿·¤Î¥¤¥Ù¥ó¥È¤¬¡ÖºÇ¤â¸Å¤¤¡×Æɤ߹þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¥¤¥Ù¥ó¥È¤È¤Þ¤È¤á¤é¤ì¤ë¤«
-¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤¿¡£
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR inotify_add_watch (2),
-.BR inotify_init (2),
-.BR inotify_init1 (2),
-.BR inotify_rm_watch (2),
-.BR read (2),
-.BR stat (2),
-.IR Documentation/filesystems/inotify.txt .
+Linux カーネルソース内の \fIDocumentation/filesystems/inotify.txt\fP
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.64 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。