diff options
author | Eric Paris <eparis@redhat.com> | 2010-07-28 10:18:37 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2010-07-28 10:18:49 -0400 |
commit | f874e1ac21d7708464dc656a10312542c54719f1 (patch) | |
tree | be47a1f5333208647e016f1861eaf21fb963478b | |
parent | 8c1934c8d70b22ca8333b216aec6c7d09fdbd6a6 (diff) |
inotify: force inotify and fsnotify use same bits
inotify uses bits called IN_* and fsnotify uses bits called FS_*. These
need to line up. This patch adds build time checks to make sure noone can
change these bits so they are not the same.
Signed-off-by: Eric Paris <eparis@redhat.com>
-rw-r--r-- | fs/notify/inotify/inotify_user.c | 21 | ||||
-rw-r--r-- | include/linux/inotify.h | 9 |
2 files changed, 30 insertions, 0 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index dfc80f70e517..c8203ce28ab7 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -839,6 +839,27 @@ out: | |||
839 | */ | 839 | */ |
840 | static int __init inotify_user_setup(void) | 840 | static int __init inotify_user_setup(void) |
841 | { | 841 | { |
842 | BUILD_BUG_ON(IN_ACCESS != FS_ACCESS); | ||
843 | BUILD_BUG_ON(IN_MODIFY != FS_MODIFY); | ||
844 | BUILD_BUG_ON(IN_ATTRIB != FS_ATTRIB); | ||
845 | BUILD_BUG_ON(IN_CLOSE_WRITE != FS_CLOSE_WRITE); | ||
846 | BUILD_BUG_ON(IN_CLOSE_NOWRITE != FS_CLOSE_NOWRITE); | ||
847 | BUILD_BUG_ON(IN_OPEN != FS_OPEN); | ||
848 | BUILD_BUG_ON(IN_MOVED_FROM != FS_MOVED_FROM); | ||
849 | BUILD_BUG_ON(IN_MOVED_TO != FS_MOVED_TO); | ||
850 | BUILD_BUG_ON(IN_CREATE != FS_CREATE); | ||
851 | BUILD_BUG_ON(IN_DELETE != FS_DELETE); | ||
852 | BUILD_BUG_ON(IN_DELETE_SELF != FS_DELETE_SELF); | ||
853 | BUILD_BUG_ON(IN_MOVE_SELF != FS_MOVE_SELF); | ||
854 | BUILD_BUG_ON(IN_UNMOUNT != FS_UNMOUNT); | ||
855 | BUILD_BUG_ON(IN_Q_OVERFLOW != FS_Q_OVERFLOW); | ||
856 | BUILD_BUG_ON(IN_IGNORED != FS_IN_IGNORED); | ||
857 | BUILD_BUG_ON(IN_EXCL_UNLINK != FS_EXCL_UNLINK); | ||
858 | BUILD_BUG_ON(IN_ISDIR != FS_IN_ISDIR); | ||
859 | BUILD_BUG_ON(IN_ONESHOT != FS_IN_ONESHOT); | ||
860 | |||
861 | BUG_ON(hweight32(ALL_INOTIFY_BITS) != 21); | ||
862 | |||
842 | inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark, SLAB_PANIC); | 863 | inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark, SLAB_PANIC); |
843 | event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC); | 864 | event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC); |
844 | 865 | ||
diff --git a/include/linux/inotify.h b/include/linux/inotify.h index b74f2ef2c368..d33041e2a42a 100644 --- a/include/linux/inotify.h +++ b/include/linux/inotify.h | |||
@@ -73,6 +73,15 @@ struct inotify_event { | |||
73 | #ifdef __KERNEL__ | 73 | #ifdef __KERNEL__ |
74 | #include <linux/sysctl.h> | 74 | #include <linux/sysctl.h> |
75 | extern struct ctl_table inotify_table[]; /* for sysctl */ | 75 | extern struct ctl_table inotify_table[]; /* for sysctl */ |
76 | |||
77 | #define ALL_INOTIFY_BITS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ | ||
78 | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ | ||
79 | IN_MOVED_TO | IN_CREATE | IN_DELETE | \ | ||
80 | IN_DELETE_SELF | IN_MOVE_SELF | IN_UNMOUNT | \ | ||
81 | IN_Q_OVERFLOW | IN_IGNORED | IN_ONLYDIR | \ | ||
82 | IN_DONT_FOLLOW | IN_EXCL_UNLINK | IN_MASK_ADD | \ | ||
83 | IN_ISDIR | IN_ONESHOT) | ||
84 | |||
76 | #endif | 85 | #endif |
77 | 86 | ||
78 | #endif /* _LINUX_INOTIFY_H */ | 87 | #endif /* _LINUX_INOTIFY_H */ |