From: Eric Paris Date: Wed, 28 Jul 2010 14:18:37 +0000 (-0400) Subject: fsnotify: check to make sure all fsnotify bits are unique X-Git-Tag: v2.6.36-rc1~303^2~23 X-Git-Url: https://bbs.cooldavid.org/git/?a=commitdiff_plain;h=20dee624ca40db227aa70cb3f44d2d6cb4fdbab4;hp=44b350fc23e36e95c8e042b7ded66217ea2b9d72;p=net-next-2.6.git fsnotify: check to make sure all fsnotify bits are unique 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 --- diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 9810babb1a3..076c10e959d 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -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); diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 4b809fcd499..a46355db1e4 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -64,6 +64,15 @@ #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;