]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/notify/inotify/inotify_user.c
inotify: force inotify and fsnotify use same bits
[net-next-2.6.git] / fs / notify / inotify / inotify_user.c
index ad5a1ea7827e48457271b66a702e80f7db127d77..c8203ce28ab7cd035da377c8ec6a248e0d9a5d57 100644 (file)
@@ -46,7 +46,7 @@
 /* these are configurable via /proc/sys/fs/inotify/ */
 static int inotify_max_user_instances __read_mostly;
 static int inotify_max_queued_events __read_mostly;
-int inotify_max_user_watches __read_mostly;
+static int inotify_max_user_watches __read_mostly;
 
 static struct kmem_cache *inotify_inode_mark_cachep __read_mostly;
 struct kmem_cache *event_priv_cachep __read_mostly;
@@ -90,11 +90,14 @@ static inline __u32 inotify_arg_to_mask(u32 arg)
 {
        __u32 mask;
 
-       /* everything should accept their own ignored and cares about children */
-       mask = (FS_IN_IGNORED | FS_EVENT_ON_CHILD);
+       /*
+        * everything should accept their own ignored, cares about children,
+        * and should receive events when the inode is unmounted
+        */
+       mask = (FS_IN_IGNORED | FS_EVENT_ON_CHILD | FS_UNMOUNT);
 
        /* mask off the flags used to open the fd */
-       mask |= (arg & (IN_ALL_EVENTS | IN_ONESHOT));
+       mask |= (arg & (IN_ALL_EVENTS | IN_ONESHOT | IN_EXCL_UNLINK));
 
        return mask;
 }
@@ -525,7 +528,7 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
        fsn_event_priv->group = group;
        event_priv->wd = i_mark->wd;
 
-       ret = fsnotify_add_notify_event(group, ignored_event, fsn_event_priv, NULL);
+       ret = fsnotify_add_notify_event(group, ignored_event, fsn_event_priv, NULL, NULL);
        if (ret)
                inotify_free_event_priv(fsn_event_priv);
 
@@ -566,7 +569,7 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
        if (unlikely(!mask))
                return -EINVAL;
 
-       fsn_mark = fsnotify_find_mark(group, inode);
+       fsn_mark = fsnotify_find_inode_mark(group, inode);
        if (!fsn_mark)
                return -ENOENT;
 
@@ -575,13 +578,11 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
        spin_lock(&fsn_mark->lock);
 
        old_mask = fsn_mark->mask;
-       if (add) {
-               fsn_mark->mask |= mask;
-               new_mask = fsn_mark->mask;
-       } else {
-               fsn_mark->mask = mask;
-               new_mask = fsn_mark->mask;
-       }
+       if (add)
+               fsnotify_set_mark_mask_locked(fsn_mark, (fsn_mark->mask | mask));
+       else
+               fsnotify_set_mark_mask_locked(fsn_mark, mask);
+       new_mask = fsn_mark->mask;
 
        spin_unlock(&fsn_mark->lock);
 
@@ -644,7 +645,7 @@ static int inotify_new_watch(struct fsnotify_group *group,
                goto out_err;
 
        /* we are on the idr, now get on the inode */
-       ret = fsnotify_add_mark(&tmp_i_mark->fsn_mark, group, inode, 0);
+       ret = fsnotify_add_mark(&tmp_i_mark->fsn_mark, group, inode, NULL, 0);
        if (ret) {
                /* we failed to get on the inode, get off the idr */
                inotify_remove_from_idr(group, tmp_i_mark);
@@ -838,6 +839,27 @@ out:
  */
 static int __init inotify_user_setup(void)
 {
+       BUILD_BUG_ON(IN_ACCESS != FS_ACCESS);
+       BUILD_BUG_ON(IN_MODIFY != FS_MODIFY);
+       BUILD_BUG_ON(IN_ATTRIB != FS_ATTRIB);
+       BUILD_BUG_ON(IN_CLOSE_WRITE != FS_CLOSE_WRITE);
+       BUILD_BUG_ON(IN_CLOSE_NOWRITE != FS_CLOSE_NOWRITE);
+       BUILD_BUG_ON(IN_OPEN != FS_OPEN);
+       BUILD_BUG_ON(IN_MOVED_FROM != FS_MOVED_FROM);
+       BUILD_BUG_ON(IN_MOVED_TO != FS_MOVED_TO);
+       BUILD_BUG_ON(IN_CREATE != FS_CREATE);
+       BUILD_BUG_ON(IN_DELETE != FS_DELETE);
+       BUILD_BUG_ON(IN_DELETE_SELF != FS_DELETE_SELF);
+       BUILD_BUG_ON(IN_MOVE_SELF != FS_MOVE_SELF);
+       BUILD_BUG_ON(IN_UNMOUNT != FS_UNMOUNT);
+       BUILD_BUG_ON(IN_Q_OVERFLOW != FS_Q_OVERFLOW);
+       BUILD_BUG_ON(IN_IGNORED != FS_IN_IGNORED);
+       BUILD_BUG_ON(IN_EXCL_UNLINK != FS_EXCL_UNLINK);
+       BUILD_BUG_ON(IN_ISDIR != FS_IN_ISDIR);
+       BUILD_BUG_ON(IN_ONESHOT != FS_IN_ONESHOT);
+
+       BUG_ON(hweight32(ALL_INOTIFY_BITS) != 21);
+
        inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark, SLAB_PANIC);
        event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC);