inotify --formfile指令

时间:2011-11-13 13:24:19

标签: linux security inotify

我有一个带有xfce窗口管理器的系统fedora 15。

我安装了一个inotify util来玩。

我想控制,在我的工作过程中我的文件会发生什么。 我今天使用一个命令来运行inotify

inotifywait --fromfile ~/list.inotify

该命令可以轻松读取要读取和忽略的文件夹和文件列表。 有我的清单(list.inotify)

/home/alex

@/home/alex/Torrnets/
@/home/alex/.pulse-cookie

所以它应该读取我的主文件夹并忽略Torrent文件夹和.pulse-cookie文件。

它也忽略了Torrent。但它不会忽略.pulse-cookie文件。

任何解决方案? (请不要发布使用基于模式的忽略的解决方案,我想使用绝对路径的文件列表)

$man inotify
   @<file>
          When watching a directory tree recursively, exclude the specified file from being watched.  The file must be specified with a relative or absolute path according to whether a relative or absolute path is given for watched directories.  If a  specific
          path is explicitly both included and excluded, it will always be watched.

          Note: If you need to watch a directory or file whose name starts with @, give the absolute path.

   --fromfile <file>
          Read filenames to watch or exclude from a file, one filename per line.  If filenames begin with @ they are excluded as described above.  If <file> is `-', filenames are read from standard input.  Use this option if you need to watch too many files to
          pass in as command line arguments.

1 个答案:

答案 0 :(得分:2)

如果您未指定-e参数,inotifywait将使用inotify_add_watch调用IN_ALL_EVENTS,这会导致监视目录中的文件发生事件 - 请注意{ {3}}说:

  

监控目录时,上面标有星号(*)的事件可能出现在目录中的文件中,在这种情况下   返回的inotify_event结构中的name字段标识目录中文件的名称。

如果您查看inotify(7),您会看到它只监视(并检查排除列表)目录。如果在指定不是目录的排除项或从未使用的排除项时发出警告,它可能会更加用户友好,但这就是它当前的方式。