fsnotify: check to make sure all fsnotify bits are unique
authorEric Paris <eparis@redhat.com>
Wed, 28 Jul 2010 14:18:37 +0000 (10:18 -0400)
committerEric Paris <eparis@redhat.com>
Wed, 28 Jul 2010 14:18:50 +0000 (10:18 -0400)
This patch adds a check to make sure that all fsnotify bits are unique and we
cannot accidentally use the same bit for 2 different fsnotify event types.

Signed-off-by: Eric Paris <eparis@redhat.com>
fs/notify/fsnotify.c
include/linux/fsnotify_backend.h

index 9810babb1a3be7fff5c3e90bd157f1b2dc0c07e7..076c10e959d506b2c41a22ca651c684a45a09b53 100644 (file)
@@ -275,6 +275,8 @@ EXPORT_SYMBOL_GPL(fsnotify);
 
 static __init int fsnotify_init(void)
 {
+       BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23);
+
        return init_srcu_struct(&fsnotify_grp_srcu);
 }
 subsys_initcall(fsnotify_init);
index 4b809fcd4996ebd50064d5310cdad9be38951862..a46355db1e47e5d111645ae97657b3aae1f38c9f 100644 (file)
 
 #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;