aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-05-21 17:01:33 -0400
committerEric Paris <eparis@redhat.com>2009-06-11 14:57:53 -0400
commit3c5119c05d624f95f4967d16b38c9624b816bdb9 (patch)
tree0b5f66106aea38e52adf62958762b0a975607322 /include/linux
parentc28f7e56e9d95fb531dc3be8df2e7f52bee76d21 (diff)
dnotify: reimplement dnotify using fsnotify
Reimplement dnotify using fsnotify. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Al Viro <viro@zeniv.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/dnotify.h29
-rw-r--r--include/linux/fs.h5
-rw-r--r--include/linux/fsnotify.h68
-rw-r--r--include/linux/fsnotify_backend.h3
4 files changed, 32 insertions, 73 deletions
diff --git a/include/linux/dnotify.h b/include/linux/dnotify.h
index 102a902b4396..ecc06286226d 100644
--- a/include/linux/dnotify.h
+++ b/include/linux/dnotify.h
@@ -10,7 +10,7 @@
10 10
11struct dnotify_struct { 11struct dnotify_struct {
12 struct dnotify_struct * dn_next; 12 struct dnotify_struct * dn_next;
13 unsigned long dn_mask; 13 __u32 dn_mask;
14 int dn_fd; 14 int dn_fd;
15 struct file * dn_filp; 15 struct file * dn_filp;
16 fl_owner_t dn_owner; 16 fl_owner_t dn_owner;
@@ -21,23 +21,18 @@ struct dnotify_struct {
21 21
22#ifdef CONFIG_DNOTIFY 22#ifdef CONFIG_DNOTIFY
23 23
24extern void __inode_dir_notify(struct inode *, unsigned long); 24#define DNOTIFY_ALL_EVENTS (FS_DELETE | FS_DELETE_CHILD |\
25 FS_MODIFY | FS_MODIFY_CHILD |\
26 FS_ACCESS | FS_ACCESS_CHILD |\
27 FS_ATTRIB | FS_ATTRIB_CHILD |\
28 FS_CREATE | FS_DN_RENAME |\
29 FS_MOVED_FROM | FS_MOVED_TO)
30
25extern void dnotify_flush(struct file *, fl_owner_t); 31extern void dnotify_flush(struct file *, fl_owner_t);
26extern int fcntl_dirnotify(int, struct file *, unsigned long); 32extern int fcntl_dirnotify(int, struct file *, unsigned long);
27extern void dnotify_parent(struct dentry *, unsigned long);
28
29static inline void inode_dir_notify(struct inode *inode, unsigned long event)
30{
31 if (inode->i_dnotify_mask & (event))
32 __inode_dir_notify(inode, event);
33}
34 33
35#else 34#else
36 35
37static inline void __inode_dir_notify(struct inode *inode, unsigned long event)
38{
39}
40
41static inline void dnotify_flush(struct file *filp, fl_owner_t id) 36static inline void dnotify_flush(struct file *filp, fl_owner_t id)
42{ 37{
43} 38}
@@ -47,14 +42,6 @@ static inline int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
47 return -EINVAL; 42 return -EINVAL;
48} 43}
49 44
50static inline void dnotify_parent(struct dentry *dentry, unsigned long event)
51{
52}
53
54static inline void inode_dir_notify(struct inode *inode, unsigned long event)
55{
56}
57
58#endif /* CONFIG_DNOTIFY */ 45#endif /* CONFIG_DNOTIFY */
59 46
60#endif /* __KERNEL __ */ 47#endif /* __KERNEL __ */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 275b0860044c..323b5ce474c1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -760,11 +760,6 @@ struct inode {
760 struct hlist_head i_fsnotify_mark_entries; /* fsnotify mark entries */ 760 struct hlist_head i_fsnotify_mark_entries; /* fsnotify mark entries */
761#endif 761#endif
762 762
763#ifdef CONFIG_DNOTIFY
764 unsigned long i_dnotify_mask; /* Directory notify events */
765 struct dnotify_struct *i_dnotify; /* for directory notifications */
766#endif
767
768#ifdef CONFIG_INOTIFY 763#ifdef CONFIG_INOTIFY
769 struct list_head inotify_watches; /* watches on this inode */ 764 struct list_head inotify_watches; /* watches on this inode */
770 struct mutex inotify_mutex; /* protects the watches list */ 765 struct mutex inotify_mutex; /* protects the watches list */
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 6a662ed0bc8a..db12d9de3526 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -74,13 +74,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
74 __u32 new_dir_mask = 0; 74 __u32 new_dir_mask = 0;
75 75
76 if (old_dir == new_dir) { 76 if (old_dir == new_dir) {
77 inode_dir_notify(old_dir, DN_RENAME);
78 old_dir_mask = FS_DN_RENAME; 77 old_dir_mask = FS_DN_RENAME;
79 } else {
80 inode_dir_notify(old_dir, DN_DELETE);
81 old_dir_mask = FS_DELETE;
82 inode_dir_notify(new_dir, DN_CREATE);
83 new_dir_mask = FS_CREATE;
84 } 78 }
85 79
86 if (isdir) { 80 if (isdir) {
@@ -132,7 +126,6 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
132 126
133 if (isdir) 127 if (isdir)
134 mask |= FS_IN_ISDIR; 128 mask |= FS_IN_ISDIR;
135 dnotify_parent(dentry, DN_DELETE);
136 129
137 fsnotify_parent(dentry, mask); 130 fsnotify_parent(dentry, mask);
138} 131}
@@ -154,7 +147,6 @@ static inline void fsnotify_inoderemove(struct inode *inode)
154 */ 147 */
155static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) 148static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
156{ 149{
157 inode_dir_notify(inode, DN_CREATE);
158 inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name, 150 inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name,
159 dentry->d_inode); 151 dentry->d_inode);
160 audit_inode_child(dentry->d_name.name, dentry, inode); 152 audit_inode_child(dentry->d_name.name, dentry, inode);
@@ -169,7 +161,6 @@ static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
169 */ 161 */
170static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry) 162static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry)
171{ 163{
172 inode_dir_notify(dir, DN_CREATE);
173 inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name, 164 inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name,
174 inode); 165 inode);
175 fsnotify_link_count(inode); 166 fsnotify_link_count(inode);
@@ -186,7 +177,6 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
186 __u32 mask = (FS_CREATE | FS_IN_ISDIR); 177 __u32 mask = (FS_CREATE | FS_IN_ISDIR);
187 struct inode *d_inode = dentry->d_inode; 178 struct inode *d_inode = dentry->d_inode;
188 179
189 inode_dir_notify(inode, DN_CREATE);
190 inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode); 180 inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode);
191 audit_inode_child(dentry->d_name.name, dentry, inode); 181 audit_inode_child(dentry->d_name.name, dentry, inode);
192 182
@@ -204,7 +194,6 @@ static inline void fsnotify_access(struct dentry *dentry)
204 if (S_ISDIR(inode->i_mode)) 194 if (S_ISDIR(inode->i_mode))
205 mask |= FS_IN_ISDIR; 195 mask |= FS_IN_ISDIR;
206 196
207 dnotify_parent(dentry, DN_ACCESS);
208 inotify_inode_queue_event(inode, mask, 0, NULL, NULL); 197 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
209 198
210 fsnotify_parent(dentry, mask); 199 fsnotify_parent(dentry, mask);
@@ -222,7 +211,6 @@ static inline void fsnotify_modify(struct dentry *dentry)
222 if (S_ISDIR(inode->i_mode)) 211 if (S_ISDIR(inode->i_mode))
223 mask |= FS_IN_ISDIR; 212 mask |= FS_IN_ISDIR;
224 213
225 dnotify_parent(dentry, DN_MODIFY);
226 inotify_inode_queue_event(inode, mask, 0, NULL, NULL); 214 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
227 215
228 fsnotify_parent(dentry, mask); 216 fsnotify_parent(dentry, mask);
@@ -289,47 +277,33 @@ static inline void fsnotify_xattr(struct dentry *dentry)
289static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid) 277static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
290{ 278{
291 struct inode *inode = dentry->d_inode; 279 struct inode *inode = dentry->d_inode;
292 int dn_mask = 0; 280 __u32 mask = 0;
293 __u32 in_mask = 0; 281
282 if (ia_valid & ATTR_UID)
283 mask |= FS_ATTRIB;
284 if (ia_valid & ATTR_GID)
285 mask |= FS_ATTRIB;
286 if (ia_valid & ATTR_SIZE)
287 mask |= FS_MODIFY;
294 288
295 if (ia_valid & ATTR_UID) {
296 in_mask |= FS_ATTRIB;
297 dn_mask |= DN_ATTRIB;
298 }
299 if (ia_valid & ATTR_GID) {
300 in_mask |= FS_ATTRIB;
301 dn_mask |= DN_ATTRIB;
302 }
303 if (ia_valid & ATTR_SIZE) {
304 in_mask |= FS_MODIFY;
305 dn_mask |= DN_MODIFY;
306 }
307 /* both times implies a utime(s) call */ 289 /* both times implies a utime(s) call */
308 if ((ia_valid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME)) 290 if ((ia_valid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME))
309 { 291 mask |= FS_ATTRIB;
310 in_mask |= FS_ATTRIB; 292 else if (ia_valid & ATTR_ATIME)
311 dn_mask |= DN_ATTRIB; 293 mask |= FS_ACCESS;
312 } else if (ia_valid & ATTR_ATIME) { 294 else if (ia_valid & ATTR_MTIME)
313 in_mask |= FS_ACCESS; 295 mask |= FS_MODIFY;
314 dn_mask |= DN_ACCESS; 296
315 } else if (ia_valid & ATTR_MTIME) { 297 if (ia_valid & ATTR_MODE)
316 in_mask |= FS_MODIFY; 298 mask |= FS_ATTRIB;
317 dn_mask |= DN_MODIFY;
318 }
319 if (ia_valid & ATTR_MODE) {
320 in_mask |= FS_ATTRIB;
321 dn_mask |= DN_ATTRIB;
322 }
323 299
324 if (dn_mask) 300 if (mask) {
325 dnotify_parent(dentry, dn_mask);
326 if (in_mask) {
327 if (S_ISDIR(inode->i_mode)) 301 if (S_ISDIR(inode->i_mode))
328 in_mask |= FS_IN_ISDIR; 302 mask |= FS_IN_ISDIR;
329 inotify_inode_queue_event(inode, in_mask, 0, NULL, NULL); 303 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
330 304
331 fsnotify_parent(dentry, in_mask); 305 fsnotify_parent(dentry, mask);
332 fsnotify(inode, in_mask, inode, FSNOTIFY_EVENT_INODE); 306 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
333 } 307 }
334} 308}
335 309
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 13d2dd570049..9ea800e840f1 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -57,6 +57,9 @@
57 FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE |\ 57 FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE |\
58 FS_DELETE) 58 FS_DELETE)
59 59
60/* listeners that hard code group numbers near the top */
61#define DNOTIFY_GROUP_NUM UINT_MAX
62
60struct fsnotify_group; 63struct fsnotify_group;
61struct fsnotify_event; 64struct fsnotify_event;
62struct fsnotify_mark_entry; 65struct fsnotify_mark_entry;