Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207669
b: refs/heads/master
c: 1c52906
h: refs/heads/master
i:
  207667: 4b3b20b
v: v3
  • Loading branch information
Eric Paris committed Jul 28, 2010
1 parent 251fe18 commit 6a92281
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ca9c726eea013394d1e846331b117effb21ead83
refs/heads/master: 1c529063a3e4c15eaae28db31326a7aaab7091b5
56 changes: 45 additions & 11 deletions trunk/fs/notify/fanotify/fanotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <linux/fsnotify_backend.h>
#include <linux/init.h>
#include <linux/kernel.h> /* UINT_MAX */
#include <linux/mount.h>
#include <linux/types.h>

#include "fanotify.h"
Expand Down Expand Up @@ -99,24 +100,35 @@ static int fanotify_handle_event(struct fsnotify_group *group, struct fsnotify_e
return ret;
}

static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *inode,
struct vfsmount *mnt, __u32 mask, void *data,
int data_type)
static bool should_send_vfsmount_event(struct fsnotify_group *group, struct vfsmount *mnt,
__u32 mask)
{
struct fsnotify_mark *fsn_mark;
bool send;

pr_debug("%s: group=%p inode=%p mask=%x data=%p data_type=%d\n",
__func__, group, inode, mask, data, data_type);
pr_debug("%s: group=%p vfsmount=%p mask=%x\n",
__func__, group, mnt, mask);

/* sorry, fanotify only gives a damn about files and dirs */
if (!S_ISREG(inode->i_mode) &&
!S_ISDIR(inode->i_mode))
fsn_mark = fsnotify_find_vfsmount_mark(group, mnt);
if (!fsn_mark)
return false;

/* if we don't have enough info to send an event to userspace say no */
if (data_type != FSNOTIFY_EVENT_PATH)
return false;
send = (mask & fsn_mark->mask);

/* find took a reference */
fsnotify_put_mark(fsn_mark);

return send;
}

static bool should_send_inode_event(struct fsnotify_group *group, struct inode *inode,
__u32 mask)
{
struct fsnotify_mark *fsn_mark;
bool send;

pr_debug("%s: group=%p inode=%p mask=%x\n",
__func__, group, inode, mask);

fsn_mark = fsnotify_find_inode_mark(group, inode);
if (!fsn_mark)
Expand All @@ -142,6 +154,28 @@ static bool fanotify_should_send_event(struct fsnotify_group *group, struct inod
return send;
}

static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
struct vfsmount *mnt, __u32 mask, void *data,
int data_type)
{
pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_type=%d\n",
__func__, group, to_tell, mnt, mask, data, data_type);

/* sorry, fanotify only gives a damn about files and dirs */
if (!S_ISREG(to_tell->i_mode) &&
!S_ISDIR(to_tell->i_mode))
return false;

/* if we don't have enough info to send an event to userspace say no */
if (data_type != FSNOTIFY_EVENT_PATH)
return false;

if (mnt)
return should_send_vfsmount_event(group, mnt, mask);
else
return should_send_inode_event(group, to_tell, mask);
}

const struct fsnotify_ops fanotify_fsnotify_ops = {
.handle_event = fanotify_handle_event,
.should_send_event = fanotify_should_send_event,
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/fsnotify_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ extern void fsnotify_recalc_inode_mask(struct inode *inode);
extern void fsnotify_init_mark(struct fsnotify_mark *mark, void (*free_mark)(struct fsnotify_mark *mark));
/* find (and take a reference) to a mark associated with group and inode */
extern struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group, struct inode *inode);
/* find (and take a reference) to a mark associated with group and vfsmount */
extern struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group, struct vfsmount *mnt);
/* copy the values from old into new */
extern void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old);
/* attach the mark to both the group and the inode */
Expand Down

0 comments on commit 6a92281

Please sign in to comment.