fsnotify: store struct file not struct path
[sfrench/cifs-2.6.git] / include / linux / fsnotify_backend.h
index be4a36ed2008331fc6d4a20b0e55789c7f5c5b5d..3410d388163ebbd848b180a0f8dc9003d87fad09 100644 (file)
 #define FS_Q_OVERFLOW          0x00004000      /* Event queued overflowed */
 #define FS_IN_IGNORED          0x00008000      /* last inotify event here */
 
+#define FS_OPEN_PERM           0x00010000      /* open event in an permission hook */
+#define FS_ACCESS_PERM         0x00020000      /* access event in a permissions hook */
+
+#define FS_EXCL_UNLINK         0x04000000      /* do not send events if object is unlinked */
 #define FS_IN_ISDIR            0x40000000      /* event occurred against dir */
 #define FS_IN_ONESHOT          0x80000000      /* only send event once */
 
 
 #define FS_MOVE                        (FS_MOVED_FROM | FS_MOVED_TO)
 
+#define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \
+                            FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \
+                            FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \
+                            FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \
+                            FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \
+                            FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \
+                            FS_IN_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \
+                            FS_DN_MULTISHOT | FS_EVENT_ON_CHILD)
+
 struct fsnotify_group;
 struct fsnotify_event;
 struct fsnotify_mark;
@@ -156,6 +169,17 @@ struct fsnotify_group {
                        struct user_struct      *user;
                } inotify_data;
 #endif
+#ifdef CONFIG_FANOTIFY
+               struct fanotify_group_private_data {
+#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
+                       /* allows a group to block waiting for a userspace response */
+                       struct mutex access_mutex;
+                       struct list_head access_list;
+                       wait_queue_head_t access_waitq;
+#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */
+                       int f_flags;
+               } fanotify_data;
+#endif /* CONFIG_FANOTIFY */
        };
 };
 
@@ -199,30 +223,34 @@ struct fsnotify_event {
        /* to_tell may ONLY be dereferenced during handle_event(). */
        struct inode *to_tell;  /* either the inode the event happened to or its parent */
        /*
-        * depending on the event type we should have either a path or inode
-        * We hold a reference on path, but NOT on inode.  Since we have the ref on
-        * the path, it may be dereferenced at any point during this object's
+        * depending on the event type we should have either a file or inode
+        * We hold a reference on file, but NOT on inode.  Since we have the ref on
+        * the file, it may be dereferenced at any point during this object's
         * lifetime.  That reference is dropped when this object's refcnt hits
-        * 0.  If this event contains an inode instead of a path, the inode may
+        * 0.  If this event contains an inode instead of a file, the inode may
         * ONLY be used during handle_event().
         */
        union {
-               struct path path;
+               struct file *file;
                struct inode *inode;
        };
 /* when calling fsnotify tell it if the data is a path or inode */
 #define FSNOTIFY_EVENT_NONE    0
-#define FSNOTIFY_EVENT_PATH    1
+#define FSNOTIFY_EVENT_FILE    1
 #define FSNOTIFY_EVENT_INODE   2
        int data_type;          /* which of the above union we have */
        atomic_t refcnt;        /* how many groups still are using/need to send this event */
        __u32 mask;             /* the type of access, bitwise OR for FS_* event types */
 
        u32 sync_cookie;        /* used to corrolate events, namely inotify mv events */
-       char *file_name;
+       const unsigned char *file_name;
        size_t name_len;
        struct pid *tgid;
 
+#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
+       __u32 response; /* userspace answer to question */
+#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */
+
        struct list_head private_data_list;     /* groups can store private data here */
 };
 
@@ -281,9 +309,9 @@ struct fsnotify_mark {
 /* called from the vfs helpers */
 
 /* main fsnotify call to send events */
-extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
-                    const char *name, u32 cookie);
-extern void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask);
+extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
+                   const unsigned char *name, u32 cookie);
+extern void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask);
 extern void __fsnotify_inode_delete(struct inode *inode);
 extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
 extern u32 fsnotify_get_cookie(void);
@@ -351,10 +379,11 @@ extern struct fsnotify_event_private_data *fsnotify_remove_priv_from_event(struc
                                                                           struct fsnotify_event *event);
 
 /* attach the event to the group notification queue */
-extern int fsnotify_add_notify_event(struct fsnotify_group *group,
-                                    struct fsnotify_event *event,
-                                    struct fsnotify_event_private_data *priv,
-                                    int (*merge)(struct list_head *, struct fsnotify_event *));
+extern struct fsnotify_event *fsnotify_add_notify_event(struct fsnotify_group *group,
+                                                       struct fsnotify_event *event,
+                                                       struct fsnotify_event_private_data *priv,
+                                                       struct fsnotify_event *(*merge)(struct list_head *,
+                                                                                       struct fsnotify_event *));
 /* true if the group notification queue is empty */
 extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group);
 /* return, but do not dequeue the first event on the notification queue */
@@ -398,7 +427,8 @@ extern void fsnotify_unmount_inodes(struct list_head *list);
 
 /* put here because inotify does some weird stuff when destroying watches */
 extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
-                                                   void *data, int data_is, const char *name,
+                                                   void *data, int data_is,
+                                                   const unsigned char *name,
                                                    u32 cookie, gfp_t gfp);
 
 /* fanotify likes to change events after they are on lists... */
@@ -408,11 +438,13 @@ extern int fsnotify_replace_event(struct fsnotify_event_holder *old_holder,
 
 #else
 
-static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
-                           const char *name, u32 cookie)
-{}
+static inline int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
+                          const unsigned char *name, u32 cookie)
+{
+       return 0;
+}
 
-static inline void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
+static inline void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
 {}
 
 static inline void __fsnotify_inode_delete(struct inode *inode)