]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/fsnotify.h
Merge branch 'x86/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux...
[karo-tx-linux.git] / include / linux / fsnotify.h
index b8cf161f5a6de329acf3abac9a0a29e7f1d82234..59d0df43ff9d5ef649fd109228ded45f37579d84 100644 (file)
@@ -34,6 +34,27 @@ static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u
        __fsnotify_parent(path, dentry, mask);
 }
 
+/* simple call site for access decisions */
+static inline int fsnotify_perm(struct file *file, int mask)
+{
+       struct path *path = &file->f_path;
+       struct inode *inode = path->dentry->d_inode;
+       __u32 fsnotify_mask = 0;
+
+       if (file->f_mode & FMODE_NONOTIFY)
+               return 0;
+       if (!(mask & (MAY_READ | MAY_OPEN)))
+               return 0;
+       if (mask & MAY_OPEN)
+               fsnotify_mask = FS_OPEN_PERM;
+       else if (mask & MAY_READ)
+               fsnotify_mask = FS_ACCESS_PERM;
+       else
+               BUG();
+
+       return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
+}
+
 /*
  * fsnotify_d_move - dentry has been moved
  * Called with dcache_lock and dentry->d_lock held.