c - dnotify 在内核 4.x 中是否已过时?

标签 c linux inotify

我正在阅读 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/

相关文章:

python - 有没有办法在 Python 中以特定用户身份执行命令?

linux - 如何使用 grep 查找末尾为单个数字的行?

bash - "inotifywait -e close_write"即使尾部显示新行也不会触发

c - 使用daemon和inotify在C中制作一个文件监视器

c++ - 串口传输错误如何解决?

最接近2的幂

linux - Centos 2.6内核升级CPU占用率高

c - 开关盒内部 - 变量定义相关

c - 在C中设置环境变量

visual-studio-code - VS Code 不排除 Code 的 node_modules 被监视 - 已达到文件监视限制