]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
fanotify: Add pids to events
authorAndreas Gruenbacher <agruen@suse.de>
Fri, 18 Dec 2009 02:24:27 +0000 (21:24 -0500)
committerEric Paris <eparis@redhat.com>
Wed, 28 Jul 2010 13:58:56 +0000 (09:58 -0400)
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>
fs/notify/fanotify/fanotify.c
fs/notify/fanotify/fanotify_user.c
fs/notify/notification.c
include/linux/fanotify.h
include/linux/fsnotify_backend.h

index 5b0b6b485a9cb8b5aeee89f36e54989bbdde1ef6..881067dc79237bcc3cf28921cf1a4f8920ca7423 100644 (file)
@@ -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);
 
-       if ((old->to_tell == new->to_tell) &&
-           (old->data_type == new->data_type)) {
+       if (old->to_tell == new->to_tell &&
+           old->data_type == new->data_type &&
+           old->tgid == new->tgid) {
                switch (old->data_type) {
                case (FSNOTIFY_EVENT_PATH):
                        if ((old->path.mnt == new->path.mnt) &&
index cf9c3000982534b3f382b08ff966f9b3a594367c..66e38fc052b27abc8f1f0ee02d2799c8f5be9c08 100644 (file)
@@ -103,6 +103,7 @@ static ssize_t fill_event_metadata(struct fsnotify_group *group,
        metadata->event_len = FAN_EVENT_METADATA_LEN;
        metadata->vers = FANOTIFY_METADATA_VERSION;
        metadata->mask = fanotify_outgoing_mask(event->mask);
+       metadata->pid = pid_vnr(event->tgid);
        metadata->fd = create_fd(group, event);
 
        return metadata->fd;
index 066f1f988bacc001f44ba8b4d93a858dfc3567c2..7fc8d004084c3a4280591d9c2a76d7f79b9adadf 100644 (file)
@@ -93,6 +93,7 @@ void fsnotify_put_event(struct fsnotify_event *event)
                BUG_ON(!list_empty(&event->private_data_list));
 
                kfree(event->file_name);
+               put_pid(event->tgid);
                kmem_cache_free(fsnotify_event_cachep, event);
        }
 }
@@ -346,6 +347,7 @@ struct fsnotify_event *fsnotify_clone_event(struct fsnotify_event *old_event)
                        return NULL;
                }
        }
+       event->tgid = get_pid(old_event->tgid);
        if (event->data_type == FSNOTIFY_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->tgid = get_pid(task_tgid(current));
        event->sync_cookie = cookie;
        event->to_tell = to_tell;
        event->data_type = data_type;
index c1c66162a46cec6539ebc0d1e56a78accc306bf6..5f633af4d1b0d751ab271c049da9d66473fdb01e 100644 (file)
@@ -62,6 +62,7 @@ struct fanotify_event_metadata {
        __u32 vers;
        __s32 fd;
        __u64 mask;
+       __s64 pid;
 } __attribute__ ((packed));
 
 /* Helper functions to deal with fanotify_event_metadata buffers */
index ff654c1932f277b3eccd4d6cfccceb844b0772ba..7d93572ec5687625ab45aa74eaa499cad718e1e6 100644 (file)
@@ -221,6 +221,7 @@ struct fsnotify_event {
        u32 sync_cookie;        /* used to corrolate events, namely inotify mv events */
        char *file_name;
        size_t name_len;
+       struct pid *tgid;
 
        struct list_head private_data_list;     /* groups can store private data here */
 };