我正在阅读 fcntl
manual page遇到 dnotify
:
File and directory change notification (dnotify)
建议新应用程序应该使用 inotify
代替,但我认为它们不一样,因为 inotify
使用 char *
路径使其遭受文件重命名(或 cathing MOVED_FROM
/MOVED_TO
事件)但 dnotify
使用不同的文件描述符:
int fcntl(int fd, int cmd, ... /* arg */ );
据我所知,dnotify
不是 inotify
的子集,反之亦然。
是否不鼓励在较新的内核中使用 dnotify
,即使我想通过文件描述符而不是 inotify
允许的文件路径来订阅事件?
最佳答案
如果您阅读 the manual page for inotify_add_watch
更近一点,那么是的,它需要一条路径但是它返回一个“监视描述符”
for the filesystem object (inode) that corresponds to
pathname
所以路径只是用来定位inode的。完成后,您将获得对 inode 的引用,并且可以毫无问题地更改文件名。
关于c - dnotify 在内核 4.x 中是否已过时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54587360/