.\" Copyright (C) 2005 Robert Love .\" and Copyright, 2006 Michael Kerrisk .\" .\" %%%LICENSE_START(GPLv2+_DOC_FULL) .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .\" %%%LICENSE_END .\" .\" 2005-07-19 Robert Love - initial version .\" 2006-02-07 mtk, various changes .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI .\" all rights reserved. .\" Translated 2006-08-15, Akihiro MOTOKI , LDP v2.39 .\" .TH INOTIFY_ADD_WATCH 2 2014\-07\-08 Linux "Linux Programmer's Manual" .SH 名前 inotify_add_watch \- 初期化済み inotify インスタンスに監視対象を追加する .SH 書式 \fB#include \fP .sp \fBint inotify_add_watch(int \fP\fIfd\fP\fB, const char *\fP\fIpathname\fP\fB, uint32_t \fP\fImask\fP\fB);\fP .SH 説明 \fBinotify_add_watch\fP() は、 \fIpathname\fP で指定された位置にあるファイルを監視する監視アイテム (watch) の新規追加、 または既存の監視アイテムの変更を行う。 呼び出し元は、監視対象のファイルに対する読み出し許可を 持っていなければならない。 \fIfd\fP 引き数は、変更を行う監視対象リスト (watch list) を持つ inotify インスタンスを参照するファイルディスクリプターである。 \fIpathname\fP のどのイベントを監視するかは、引き数のビットマスク \fImask\fP で指定する。 \fImask\fP に設定できるビットの説明については \fBinotify\fP(7) を参照のこと。 \fBinotify_add_watch\fP() の呼び出しが成功すると、 \fIpathname\fP に対応するファイルシステムオブジェクトに対する、 一意な監視対象ディスクリプター (watch descriptor) を、 対象の inotify インスタンスに対して返す。 そのファイルシステムオブジェクトが対象の inotify インスタンスによって以前に監視されていない場合には、 監視対象ディスクリプターは新規に割り当てられる。 ファイルシステムオブジェクトが (おそらく同じオブジェクトに対する異なるリンク経由で) すでに監視されている場合には、 既存の監視に対するディスクリプターが返される。 これ以降に inotify ファイルディスクリプターから \fBread\fP(2) を行うと、監視対象ディスクリプターが返される。 これらの \fBread\fP() を行うと、ファイルシステムイベントを示す \fIinotify_event\fP 構造体が読み出される (\fBinotify\fP(7) 参照)。この構造体内の監視対象ディスクリプターにより、 どのオブジェクトでそのイベントが発生したかを特定できる。 .SH 返り値 成功すると、 \fBinotify_add_watch\fP() は非負の監視対象ディスクリプターを返す。 エラーの場合、\-1 を返し、 \fIerrno\fP を適切に設定する。 .SH エラー .TP \fBEACCES\fP 指定されたファイルに対する読み出しアクセスが許可されていない。 .TP \fBEBADF\fP 指定されたファイルディスクリプターが有効ではない。 .TP \fBEFAULT\fP \fIpathname\fP が指すアドレスがプロセスがアクセスできるアドレス空間外である。 .TP \fBEINVAL\fP 指定されたイベントマスクに有効なイベントが含まれていない。 もしくは \fIfd\fP が inotify ファイルディスクリプターではない。 .TP \fBENAMETOOLONG\fP \fIpathname\fP が長過ぎる。 .TP \fBENOENT\fP \fIpathname\fP のディレクトリ部分の構成要素が、存在しないか、 リンク切れのシンボリックリンクである。 .TP \fBENOMEM\fP カーネルメモリーが十分になかった。 .TP \fBENOSPC\fP inotify 監視対象の総数がユーザーが追加できる上限に達していた。 もしくは、必要な資源の割り当てにカーネルが失敗した。 .SH バージョン inotify は Linux カーネル 2.6.13 に組み込まれた。 .SH 準拠 このシステムコールは Linux 独自である。 .SH 関連項目 \fBinotify_init\fP(2), \fBinotify_rm_watch\fP(2), \fBinotify\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。