inotify inotify_event 事件->名称为空
我正在使用 inotify 来监视某些文件的更改。 问题是 inotify_event event->name 为空,所以我无法判断哪个文件被修改了,
为什么 event->name 为空?
fd = inotify_init();
wd = inotify_add_watch (m_fd, "/tmp/myfile", IN_MODIFY | IN_CREATE | IN_DELETE);
wd1 = inotify_add_watch (m_fd, "/tmp/myfile2", IN_MODIFY | IN_CREATE | IN_DELETE);
-----
unsigned char buffer[BUFFER_SIZE];
ssize_t len = ACE_OS::read(fd, buffer, sizeof(buffer));
ssize_t i = 0;
while (i < len)
{
inotify_event *event = ( struct inotify_event * ) &buffer[ i ];
i += EVENT_SIZE + event->len;
}
I am using inotify to monitor changes on some files.
The problem is that inotify_event event->name is empty so I cant tell which file was modified
why is event->name empty?
fd = inotify_init();
wd = inotify_add_watch (m_fd, "/tmp/myfile", IN_MODIFY | IN_CREATE | IN_DELETE);
wd1 = inotify_add_watch (m_fd, "/tmp/myfile2", IN_MODIFY | IN_CREATE | IN_DELETE);
-----
unsigned char buffer[BUFFER_SIZE];
ssize_t len = ACE_OS::read(fd, buffer, sizeof(buffer));
ssize_t i = 0;
while (i < len)
{
inotify_event *event = ( struct inotify_event * ) &buffer[ i ];
i += EVENT_SIZE + event->len;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 inotify 手册页...
由于您只是查看文件,而不是目录,因此名称将始终为空。
From the inotify man page...
Since you're just watching files, and not directories, name will always be empty.