我正在检查当前fatrace的源代码。
调用fanotify获取数据值的主循环如下:
res = read (fan_fd, buffer, 4096);
...
data = (struct fanotify_event_metadata *) buffer;
while (FAN_EVENT_OK (data, res)) {
...
data = FAN_EVENT_NEXT (data, res);
}
当提取与事件关联的文件名时,代码如下所示:
snprintf (printbuf, sizeof (printbuf), "/proc/self/fd/%i", data->fd);
len = readlink (printbuf, pathname, sizeof (pathname));
/proc/self/fd/"data->fd"
我很困惑为什么文件名是从而不是提取的/proc/"data->pid"/fd/"data->fd"
?