Kqueue dir extended watch 做什么动作?

What action does Kqueue dir extended watch?

我正在 OS X 上玩 rb-kqueue,我不知道如何让 extend 标志触发。

来自 OpenBSD kqueue man page(也匹配 OS X 手册页):

NOTE_EXTEND The file referenced by the descriptor was extended

这是非常循环的。

FreeBSD kqueue man page 有:

NOTE_EXTEND For regular file, the file referenced by the descriptor was extended. For directory, reports that a directory entry was added or removed, as the result of rename operation. The NOTE_EXTEND event is not reported when a name is changed inside the directory.

这更具有描述性,但是,我已经 运行 一个目录上的 kqueue 并尽我所能尝试我无法触发扩展标志。我试过 mvrenamexattr(因为搜索“扩展”会返回很多关于扩展属性的结果),添加子目录和文件 mkdirtouch 并重定向,但 没有任何结果 导致 extend 标志成为事件的一部分,只是 write and/or link .

因此我对 extend 到底是什么感到困惑。仅仅是因为我 运行 它在 OS X 上吗?

我希望对这个问题有所了解。

标志NOTE_EXTEND 对应于对文件执行的操作。在您的情况下,您应该在 文件大小增加时触发操作

推理

引用原论文- Kquote: A generic and scalable event notification facility:

The fflags field is used to specify which actions on the descriptor the application is interested in on registration, and upon return, which actions have occurred. The possible actions are:

  • NOTE DELETE
  • NOTE WRITE
  • NOTE EXTEND
  • NOTE ATTRIB
  • NOTE LINK
  • NOTE RENAME

These correspond to the actions that the filesystem performs on the file and thus will not be explained here. These notes may be OR-d together in the returned kevent, if multiple actions have occurred. E.g.: a file was written, then renamed. The final general purpose filter is the PROC filter, which detects process changes. For this filter, the ident field is interpreted as a process identifier. This filter can watch for several types of events, and the fflags that control this filter are outlined in Figure 3

EVFILT PROC 的图 3:

Input/Output Flags:

  • NOTE EXIT Process exited.

  • NOTE FORK Process called fork()

  • NOTE EXEC Process executed a new process via execve(2) or similar call.

  • NOTE TRACK Follow a process across fork() calls. The parent process will return with NOTE TRACK set in the flags field, while the child process will return with NOTE CHILD set in fflags and the parent PID in data.

Output Flags only:

  • NOTE CHILD This is the child process of a TRACKed process which called fork().

  • NOTE TRACKERR This flag is returned if the system was unable to attach an event to the child process, usually due to resource limitations.