dnotify 在内核 4.x 中是否已过时?
Is dnotify obsolete in kernel 4.x?
我正在阅读 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
,那么是的,它需要一条路径 但是 它 returns a "watch descriptor"
for the filesystem object (inode) that corresponds to pathname
所以路径只是用来定位inode的。完成后,您将获得对 inode 的引用,并且可以毫无问题地更改文件名。
我正在阅读 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
,那么是的,它需要一条路径 但是 它 returns a "watch descriptor"
for the filesystem object (inode) that corresponds to
pathname
所以路径只是用来定位inode的。完成后,您将获得对 inode 的引用,并且可以毫无问题地更改文件名。