fanotify: Add pids to events
Pass the process identifiers of the triggering processes to fanotify listeners: this information is useful for event filtering and logging. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Родитель
22aa425dec
Коммит
32c3263221
|
@ -10,8 +10,9 @@ static bool should_merge(struct fsnotify_event *old, struct fsnotify_event *new)
|
||||||
{
|
{
|
||||||
pr_debug("%s: old=%p new=%p\n", __func__, old, new);
|
pr_debug("%s: old=%p new=%p\n", __func__, old, new);
|
||||||
|
|
||||||
if ((old->to_tell == new->to_tell) &&
|
if (old->to_tell == new->to_tell &&
|
||||||
(old->data_type == new->data_type)) {
|
old->data_type == new->data_type &&
|
||||||
|
old->tgid == new->tgid) {
|
||||||
switch (old->data_type) {
|
switch (old->data_type) {
|
||||||
case (FSNOTIFY_EVENT_PATH):
|
case (FSNOTIFY_EVENT_PATH):
|
||||||
if ((old->path.mnt == new->path.mnt) &&
|
if ((old->path.mnt == new->path.mnt) &&
|
||||||
|
|
|
@ -103,6 +103,7 @@ static ssize_t fill_event_metadata(struct fsnotify_group *group,
|
||||||
metadata->event_len = FAN_EVENT_METADATA_LEN;
|
metadata->event_len = FAN_EVENT_METADATA_LEN;
|
||||||
metadata->vers = FANOTIFY_METADATA_VERSION;
|
metadata->vers = FANOTIFY_METADATA_VERSION;
|
||||||
metadata->mask = fanotify_outgoing_mask(event->mask);
|
metadata->mask = fanotify_outgoing_mask(event->mask);
|
||||||
|
metadata->pid = pid_vnr(event->tgid);
|
||||||
metadata->fd = create_fd(group, event);
|
metadata->fd = create_fd(group, event);
|
||||||
|
|
||||||
return metadata->fd;
|
return metadata->fd;
|
||||||
|
|
|
@ -93,6 +93,7 @@ void fsnotify_put_event(struct fsnotify_event *event)
|
||||||
BUG_ON(!list_empty(&event->private_data_list));
|
BUG_ON(!list_empty(&event->private_data_list));
|
||||||
|
|
||||||
kfree(event->file_name);
|
kfree(event->file_name);
|
||||||
|
put_pid(event->tgid);
|
||||||
kmem_cache_free(fsnotify_event_cachep, event);
|
kmem_cache_free(fsnotify_event_cachep, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,6 +347,7 @@ struct fsnotify_event *fsnotify_clone_event(struct fsnotify_event *old_event)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
event->tgid = get_pid(old_event->tgid);
|
||||||
if (event->data_type == FSNOTIFY_EVENT_PATH)
|
if (event->data_type == FSNOTIFY_EVENT_PATH)
|
||||||
path_get(&event->path);
|
path_get(&event->path);
|
||||||
|
|
||||||
|
@ -385,6 +387,7 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
||||||
event->name_len = strlen(event->file_name);
|
event->name_len = strlen(event->file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event->tgid = get_pid(task_tgid(current));
|
||||||
event->sync_cookie = cookie;
|
event->sync_cookie = cookie;
|
||||||
event->to_tell = to_tell;
|
event->to_tell = to_tell;
|
||||||
event->data_type = data_type;
|
event->data_type = data_type;
|
||||||
|
|
|
@ -62,6 +62,7 @@ struct fanotify_event_metadata {
|
||||||
__u32 vers;
|
__u32 vers;
|
||||||
__s32 fd;
|
__s32 fd;
|
||||||
__u64 mask;
|
__u64 mask;
|
||||||
|
__s64 pid;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Helper functions to deal with fanotify_event_metadata buffers */
|
/* Helper functions to deal with fanotify_event_metadata buffers */
|
||||||
|
|
|
@ -221,6 +221,7 @@ struct fsnotify_event {
|
||||||
u32 sync_cookie; /* used to corrolate events, namely inotify mv events */
|
u32 sync_cookie; /* used to corrolate events, namely inotify mv events */
|
||||||
char *file_name;
|
char *file_name;
|
||||||
size_t name_len;
|
size_t name_len;
|
||||||
|
struct pid *tgid;
|
||||||
|
|
||||||
struct list_head private_data_list; /* groups can store private data here */
|
struct list_head private_data_list; /* groups can store private data here */
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче