fanotify_init

FANOTIFY_INIT(2)           Linux Programmer's Manual          FANOTIFY_INIT(2)



åå
       fanotify_init - fanotify ã°ã«ã¼ããä½æããåæåãã

æ¸å¼
       #include <fcntl.h>
       #include <sys/fanotify.h>

       int fanotify_init(unsigned int flags, unsigned int event_f_flags);

説æ
       fanotify API ã®æ¦è¦ã«ã¤ãã¦ã¯ fanotify(7) ãåç§ã

       fanotify_init() ã¯æ°ãã fanotify ã°ã«ã¼ããåæåãã
       ãã®ã°ã«ã¼ãã«é¢é£ä»ããããã¤ãã³ããã¥ã¼ã«å¯¾ãããã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ãè¿ãã

       ãã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ã¯ã fanotify_mark(2) ã®å¼ã³åºã㧠fanotify
       ã¤ãã³ããä½æããããã¡ã¤ã«ã ãã£ã¬ã¯ããªã ãã¦ã³ããæå®ããã®ã«ä½¿ç¨ã§ããã
       fanotify_mark(2) ã§æå®ãããã¡ã¤ã«ã ãããã®ã¤ãã³ãã¯ã
       ãã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ããã®èªã¿åºãã§åä¿¡ããã ããã¤ãã®ã¤ãã³ãã¯ã
       ãã¡ã¤ã«ãã¢ã¯ã»ã¹ããããã¨ã示ãåãªãæå ±ã§ããã ä»ã®ããã¤ãã®ã¤ãã³ãã¯ã
       å¥ã®ã¢ããªã±ã¼ã·ã§ã³ããã¡ã¤ã«ããã£ã¬ã¯ããªã«ã¢ã¯ã»ã¹ãã許å¯ãä¸ããããå¤å®ããã®ã«ä½¿ç¨ãããã
       ãã¡ã¤ã«ã·ã¹ãã ãªãã¸ã§ã¯ãã¸ã®ã¢ã¯ã»ã¹è¨±å¯ã¤ãã³ãã«ã¤ãã¦ã¯ã
       æ¿èªçµæããã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ã«æ¸ãè¾¼ãã

       è¤æ°ã®ããã°ã©ã ãåæã« fanotify
       ã¤ã³ã¿ã¼ãã§ã¼ã¹ã使ã£ã¦åããã¡ã¤ã«ãåæã«ç£è¦ãããã¨ãã§ããã

       ç¾å¨ã®å®è£ã§ã¯ã ã¦ã¼ã¶ã¼ãããã® fanotify ã°ã«ã¼ãæ°ã¯ 128 ã«å¶éããã¦ããã
       ãã®å¶éã¯ä¸æ¸ããããã¨ãã§ããªãã

       fanotify_init() ãå¼ã³åºãã«ã¯ CAP_SYS_ADMIN ã±ã¼ãããªãã£ã¼ãå¿è¦ã§ããã
       ãã®å¶ç´ã¯å°æ¥ã®ãã¼ã¸ã§ã³ã® API ã§ç·©åãããå¯è½æ§ãããã ãã®ããã
       以ä¸ã«ç¤ºãã±ã¼ãããªãã£ã¼ãã§ãã¯ã®ããã¤ããå®è£ããã¦ããã

       flags å¼ãæ°ã¯ã
       ã¤ãã³ããå¾ã¤ã¢ããªã±ã¼ã·ã§ã³ã®éç¥ã¯ã©ã¹ãå®ç¾©ããè¤æ°ãããã®ãã£ã¼ã«ãã§ããã
       ããã«å ãã¦ã ãã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ã®åä½ã示ã 1 ãããã®ãã£ã¼ã«ããããã

       ã¢ã¯ã»ã¹è¨±å¯ã¤ãã³ããç£è¦ãã¦ããããã°ã©ã ãè¤æ°ããå ´åã
       éç¥ã¯ã©ã¹ã使ã£ã¦ç£è¦ããããã°ã©ã ã®ã¤ãã³ãåä¿¡é åºã管çãããã

       以ä¸ã®éç¥ã¯ã©ã¹ã®ããããä¸ã¤ã ãã flags ã«æå®ã§ããã

       FAN_CLASS_PRE_CONTENT
              ãã®å¤ã¯ã ãã¡ã¤ã«ãã¢ã¯ã»ã¹ããããã¨ãéç¥ããã¤ãã³ãã¨ã
              ãã¡ã¤ã«ã¸ã®ã¢ã¯ã»ã¹ãããã®è¨±å¯ã®å¤æãæ±ããã¤ãã³ããåä¿¡ãããã¨ã示ãã
              ããã¯ã¤ãã³ãåä¿¡èããã¡ã¤ã«ãæçµçãªãã¼ã¿ãæ ¼ç´ããåã«ãã®ãã¡ã¤ã«ã«ã¢ã¯ã»ã¹ããå¿è¦ãããå ´åã«ä½¿ç¨ãããã
              ãã®éç¥ã¯ã©ã¹ã¯ä¾ãã°é層åã¹ãã¬ã¼ã¸ç®¡çãªã©ã§ä½¿ç¨ãããã

       FAN_CLASS_CONTENT
              ãã®å¤ã¯ã ãã¡ã¤ã«ãã¢ã¯ã»ã¹ããããã¨ãéç¥ããã¤ãã³ãã¨ã
              ãã¡ã¤ã«ã¸ã®ã¢ã¯ã»ã¹ãããã®è¨±å¯ã®å¤æãæ±ããã¤ãã³ããåä¿¡ãããã¨ã示ãã
              ããã¯ã¤ãã³ãåä¿¡èããã¡ã¤ã«ã«æçµçãªãã¼ã¿ãæ ¼ç´ãããéã«ãã®ãã¡ã¤ã«ã«ã¢ã¯ã»ã¹ããå¿è¦ãããå ´åã«ä½¿ç¨ãããã
              ãã®éç¥ã¯ã©ã¹ã¯ä¾ãã°ã¦ã¤ã«ã¹æ¤ç¥ããã°ã©ã ãªã©ã§ä½¿ç¨ãããã

       FAN_CLASS_NOTIF
              ããã¯ããã©ã«ãå¤ã§ããã ãã®å¤ãæå®ããå¿è¦ã¯ãªãã ãã®å¤ã¯ã
              ãã¡ã¤ã«ãã¢ã¯ã»ã¹ããããã¨ãéç¥ããã¤ãã³ãã®åä¿¡ã ããè¡ããã¨ãæå³ããã
              ãã¡ã¤ã«ãã¢ã¯ã»ã¹ããåã«ã¢ã¯ã»ã¹è¨±å¯ã®å¤å®ãè¡ããã¨ã¯ã§ããªãã

       ç°ãªãéç¥ã¯ã©ã¹ã®åä¿¡è㯠FAN_CLASS_PRE_CONTENT, FAN_CLASS_CONTENT,
       FAN_CLASS_NOTIF ã®é åºã§ã¤ãã³ããåä¿¡ããã
       åãéç¥ã¯ã©ã¹ã®åä¿¡èã§ã®éç¥é åºã¯ä¸å®ã§ããã

       flags ã«ã¯ä»¥ä¸ã®ãããã追å ã§ã»ãããããã¨ãã§ããã

       FAN_CLOEXEC
              close-on-exec ãã©ã° (FD_CLOEXEC)
              ãæ°ãããã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ã«ã»ããããã open(2) ã® O_CLOEXEC
              ãã©ã°ã®èª¬æãåç§ã

       FAN_NONBLOCK
              ãã³ããããã³ã°ãã©ã° (O_NONBLOCK)
              ããã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ã§æå¹ã«ããã
              ãã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ããã®èªã¿åºãã¯åæ¢ããªãã ãã®ä»£ããã èª‐
              ã¿ã ãå¯è½ãªãã¼ã¿ãä½ããªãå ´åã read(2) ã¯ã¨ã©ã¼ EAGAIN ã§å¤±æããã

       FAN_UNLIMITED_QUEUE
              ãã®ã¤ãã³ããã¥ã¼ã® 16384 ã¤ãã³ãã®ä¸éãåé¤ããã ãã®ãã©ã°ã使ç¨ããã«ã¯
              CAP_SYS_ADMIN ã±ã¼ãããªãã£ã¼ãå¿è¦ã§ããã

       FAN_UNLIMITED_MARKS
              8192 ãã¼ã¯ã®ä¸éãåé¤ããã ãã®ãã©ã°ã使ç¨ããã«ã¯ CAP_SYS_ADMIN
              ã±ã¼ãããªãã£ã¼ãå¿è¦ã§ããã

       event_f_flags å¼ãæ°ã¯ fanotify
       ã¤ãã³ããä½æããããªã¼ãã³ãã¡ã¤ã«è¨è¿°ã«ã»ããããããã¡ã¤ã«ç¶æãã©ã°ãå®ç¾©ããã
       ãããã®ãã©ã°ã®è©³ç´°ã«ã¤ãã¦ã¯ open(2) ã® flags å¤ã®èª¬æãåç§ã®ãã¨ã
       event_f_flags ã«ã¯ã¢ã¯ã»ã¹ã¢ã¼ãã®ããããè¤æ°å¥ãããã¨ãã§ããã
       ãã®ãã£ã¼ã«ãã«ã¯ä»¥ä¸ã®å¤ãæå®ãããã¨ãã§ããã

       O_RDONLY
              èªã¿åºãã¢ã¯ã»ã¹ã®ã¿ã許å¯ããã

       O_WRONLY
              æ¸ãè¾¼ã¿ã¢ã¯ã»ã¹ã®ã¿ã許å¯ããã

       O_RDWR èªã¿åºãã¨æ¸ãè¾¼ã¿ã®ä¸¡æ¹ã許å¯ããã

       ä»ã®ãããã event_f_flags ãã»ãããããã¨ãã§ããã å½¹ç«ã¤ã§ãããå¤ã¯ä»¥ä¸ã§ããã

       O_LARGEFILE
              2 GB ãè¶ãããã¡ã¤ã«ã®ãµãã¼ããæå¹ã«ããã ãã®ãã©ã°ã®ã»ããã«å¤±æããã¨ã 32
              ãããã·ã¹ãã 㧠fanotify
              ã°ã«ã¼ããç£è¦ããã©ã¼ã¸ãã¡ã¤ã«ããªã¼ãã³ãããã¨ããéã« EOVERFLOW
              ã¨ã©ã¼ã¨ãªãã

       O_CLOEXEC
              ãã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ã§ close-on-exec ãã©ã°ãæå¹ã«ããã
              ãã®ãã©ã°ãå½¹ç«ã¤çç±ã«ã¤ãã¦ã¯ open(2) ã® O_CLOEXEC
              ãã©ã°ã®èª¬æãåç§ã

       O_APPEND, O_DSYNC, O_NOATIME, O_NONBLOCK, O_SYNC ãæå®ãããã¨ãã§ããã
       event_f_flags ã«ãã以å¤ã®ãã©ã°ãæå®ããã¨ã ã¨ã©ã¼ EINVAL ãèµ·ãã
       (ãã ãããã°ãåç§)ã

è¿ãå¤
       æåãã㨠fanotify_init() ã¯æ°ãããã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ãè¿ãã ã¨ã©ã¼ã®å ´åã
       -1 ãè¿ãã errno ã«ã¨ã©ã¼ã示ãå¤ãè¨å®ããã

ã¨ã©ã¼
       EINVAL flags ã event_f_flags ã«ç¡å¹ãªå¤ã渡ãããã FAN_ALL_INIT_FLAGS ã§
              flags ã«æå®ã§ããå¨ããããå®ç¾©ããã¦ããã

       EMFILE ãã®ã¦ã¼ã¶ã¼ã® fanotify ã°ã«ã¼ãæ°ã 128 ãè¶éããã

       ENOMEM éç¥ã°ã«ã¼ãã¸ã®ã¡ã¢ãªã¼å²ãå½ã¦ã失æããã

       ENOSYS ãã®ã«ã¼ãã«ã¯ fanotify_init() ãå®è£ãã¦ããªãã fanotify API
              ãå©ç¨ã§ããã®ã¯ã ã«ã¼ãã«ã CONFIG_FANOTIFY
              ãæå¹ã«ãã¦ä½æããã¦ããå ´åã ãã§ããã

       EPERM  å¼ã³åºãåã CAP_SYS_ADMIN
              ã±ã¼ãããªãã£ã¼ãæã£ã¦ããªãã®ã§ãæä½ã許å¯ãããªãã

ãã¼ã¸ã§ã³
       fanotify_init() 㯠Linux ã«ã¼ãã«ã®ãã¼ã¸ã§ã³ 2.6.36 ã§å°å¥ããã ãã¼ã¸ã§ã³
       2.6.37 ã§æå¹ã«ãªã£ãã

æºæ
       ãã®ã·ã¹ãã ã³ã¼ã«ã¯ Linux ç¬èªã§ããã

ãã°
       Linux 3.17 æç¹ã§ã¯ã 以ä¸ã®ãã°ãåå¨ããã

       *  O_CLOEXEC ã event_f_flags ã«æå®ãããå ´åã ç¡è¦ãããã

       ãã¼ã¸ã§ã³ 3.14 ããåã® Linux ã«ã¼ãã«ã«ã¯ä»¥ä¸ã®ãã°ãåå¨ããã

       *  event_f_flags å¼ãæ°ã«ç¡å¹ãªãã©ã°ããªããã®ãã§ãã¯ãè¡ãããªãã FMODE_EXEC
          ãªã©ã®åé¨ã§ã®ä½¿ç¨ã®ã¿ãæå³ããããã©ã°ãæå®ãããã¨ãã§ãã ãã®å ´å fanotify
          ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ããã®èª‐
          ã¿åºãæã«è¿ããããã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã¼ã«ãã®ãã©ã°ãã»ãããããã

é¢é£é ç®
       fanotify_mark(2), fanotify(7)

ãã®ææ¸ã«ã¤ãã¦
       ãã® man ãã¼ã¸ã¯ Linux man-pages ããã¸ã§ã¯ãã®ãªãªã¼ã¹ 3.79 ã®ä¸é¨
       ã§ãããããã¸ã§ã¯ãã®èª¬æã¨ãã°å ±åã«é¢ããæå ±ã¯
       http://www.kernel.org/doc/man-pages/ ã«æ¸ããã¦ããã



Linux                             2014-10-02                  FANOTIFY_INIT(2)