aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmy Griffis <amy.griffis@hp.com>2006-06-01 16:11:01 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2006-06-20 05:25:18 -0400
commit7c29772288b7026504cfe75bfd90d40fbd1574bf (patch)
treedfc0cfef97c4c5fdbd87bbd9abdbf44bcd21c906
parent2d9048e201bfb67ba21f05e647b1286b8a4a5667 (diff)
[PATCH] inotify (2/5): add name's inode to event handler
When an inotify event includes a dentry name, also include the inode associated with that name. Signed-off-by: Amy Griffis <amy.griffis@hp.com> Acked-by: Robert Love <rml@novell.com> Acked-by: John McCutchan <john@johnmccutchan.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/inotify.c13
-rw-r--r--fs/inotify_user.c3
-rw-r--r--include/linux/fsnotify.h29
-rw-r--r--include/linux/inotify.h7
4 files changed, 30 insertions, 22 deletions
diff --git a/fs/inotify.c b/fs/inotify.c
index a1bedf3975ca..f25c21801fdc 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -232,7 +232,7 @@ static void remove_watch_no_event(struct inotify_watch *watch,
232static void remove_watch(struct inotify_watch *watch, struct inotify_handle *ih) 232static void remove_watch(struct inotify_watch *watch, struct inotify_handle *ih)
233{ 233{
234 remove_watch_no_event(watch, ih); 234 remove_watch_no_event(watch, ih);
235 ih->in_ops->handle_event(watch, watch->wd, IN_IGNORED, 0, NULL); 235 ih->in_ops->handle_event(watch, watch->wd, IN_IGNORED, 0, NULL, NULL);
236} 236}
237 237
238/* Kernel API for producing events */ 238/* Kernel API for producing events */
@@ -275,9 +275,10 @@ void inotify_d_move(struct dentry *entry)
275 * @mask: event mask describing this event 275 * @mask: event mask describing this event
276 * @cookie: cookie for synchronization, or zero 276 * @cookie: cookie for synchronization, or zero
277 * @name: filename, if any 277 * @name: filename, if any
278 * @n_inode: inode associated with name
278 */ 279 */
279void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie, 280void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
280 const char *name) 281 const char *name, struct inode *n_inode)
281{ 282{
282 struct inotify_watch *watch, *next; 283 struct inotify_watch *watch, *next;
283 284
@@ -292,7 +293,8 @@ void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
292 mutex_lock(&ih->mutex); 293 mutex_lock(&ih->mutex);
293 if (watch_mask & IN_ONESHOT) 294 if (watch_mask & IN_ONESHOT)
294 remove_watch_no_event(watch, ih); 295 remove_watch_no_event(watch, ih);
295 ih->in_ops->handle_event(watch, watch->wd, mask, cookie, name); 296 ih->in_ops->handle_event(watch, watch->wd, mask, cookie,
297 name, n_inode);
296 mutex_unlock(&ih->mutex); 298 mutex_unlock(&ih->mutex);
297 } 299 }
298 } 300 }
@@ -323,7 +325,8 @@ void inotify_dentry_parent_queue_event(struct dentry *dentry, u32 mask,
323 if (inotify_inode_watched(inode)) { 325 if (inotify_inode_watched(inode)) {
324 dget(parent); 326 dget(parent);
325 spin_unlock(&dentry->d_lock); 327 spin_unlock(&dentry->d_lock);
326 inotify_inode_queue_event(inode, mask, cookie, name); 328 inotify_inode_queue_event(inode, mask, cookie, name,
329 dentry->d_inode);
327 dput(parent); 330 dput(parent);
328 } else 331 } else
329 spin_unlock(&dentry->d_lock); 332 spin_unlock(&dentry->d_lock);
@@ -407,7 +410,7 @@ void inotify_unmount_inodes(struct list_head *list)
407 struct inotify_handle *ih= watch->ih; 410 struct inotify_handle *ih= watch->ih;
408 mutex_lock(&ih->mutex); 411 mutex_lock(&ih->mutex);
409 ih->in_ops->handle_event(watch, watch->wd, IN_UNMOUNT, 0, 412 ih->in_ops->handle_event(watch, watch->wd, IN_UNMOUNT, 0,
410 NULL); 413 NULL, NULL);
411 remove_watch(watch, ih); 414 remove_watch(watch, ih);
412 mutex_unlock(&ih->mutex); 415 mutex_unlock(&ih->mutex);
413 } 416 }
diff --git a/fs/inotify_user.c b/fs/inotify_user.c
index 845dc79a4e9c..8b83c7190067 100644
--- a/fs/inotify_user.c
+++ b/fs/inotify_user.c
@@ -253,7 +253,8 @@ inotify_dev_get_event(struct inotify_device *dev)
253 * Can sleep (calls kernel_event()). 253 * Can sleep (calls kernel_event()).
254 */ 254 */
255static void inotify_dev_queue_event(struct inotify_watch *w, u32 wd, u32 mask, 255static void inotify_dev_queue_event(struct inotify_watch *w, u32 wd, u32 mask,
256 u32 cookie, const char *name) 256 u32 cookie, const char *name,
257 struct inode *ignored)
257{ 258{
258 struct inotify_user_watch *watch; 259 struct inotify_user_watch *watch;
259 struct inotify_device *dev; 260 struct inotify_device *dev;
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 11438eff4d44..a9d30442448f 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -54,16 +54,18 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
54 54
55 if (isdir) 55 if (isdir)
56 isdir = IN_ISDIR; 56 isdir = IN_ISDIR;
57 inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name); 57 inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name,
58 inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name); 58 source);
59 inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name,
60 source);
59 61
60 if (target) { 62 if (target) {
61 inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL); 63 inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL, NULL);
62 inotify_inode_is_dead(target); 64 inotify_inode_is_dead(target);
63 } 65 }
64 66
65 if (source) { 67 if (source) {
66 inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL); 68 inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL);
67 } 69 }
68 audit_inode_child(old_name, source, old_dir->i_ino); 70 audit_inode_child(old_name, source, old_dir->i_ino);
69 audit_inode_child(new_name, target, new_dir->i_ino); 71 audit_inode_child(new_name, target, new_dir->i_ino);
@@ -85,7 +87,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
85 */ 87 */
86static inline void fsnotify_inoderemove(struct inode *inode) 88static inline void fsnotify_inoderemove(struct inode *inode)
87{ 89{
88 inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL); 90 inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL, NULL);
89 inotify_inode_is_dead(inode); 91 inotify_inode_is_dead(inode);
90} 92}
91 93
@@ -95,7 +97,8 @@ static inline void fsnotify_inoderemove(struct inode *inode)
95static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) 97static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
96{ 98{
97 inode_dir_notify(inode, DN_CREATE); 99 inode_dir_notify(inode, DN_CREATE);
98 inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name); 100 inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name,
101 dentry->d_inode);
99 audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino); 102 audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino);
100} 103}
101 104
@@ -106,7 +109,7 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
106{ 109{
107 inode_dir_notify(inode, DN_CREATE); 110 inode_dir_notify(inode, DN_CREATE);
108 inotify_inode_queue_event(inode, IN_CREATE | IN_ISDIR, 0, 111 inotify_inode_queue_event(inode, IN_CREATE | IN_ISDIR, 0,
109 dentry->d_name.name); 112 dentry->d_name.name, dentry->d_inode);
110 audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino); 113 audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino);
111} 114}
112 115
@@ -123,7 +126,7 @@ static inline void fsnotify_access(struct dentry *dentry)
123 126
124 dnotify_parent(dentry, DN_ACCESS); 127 dnotify_parent(dentry, DN_ACCESS);
125 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); 128 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
126 inotify_inode_queue_event(inode, mask, 0, NULL); 129 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
127} 130}
128 131
129/* 132/*
@@ -139,7 +142,7 @@ static inline void fsnotify_modify(struct dentry *dentry)
139 142
140 dnotify_parent(dentry, DN_MODIFY); 143 dnotify_parent(dentry, DN_MODIFY);
141 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); 144 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
142 inotify_inode_queue_event(inode, mask, 0, NULL); 145 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
143} 146}
144 147
145/* 148/*
@@ -154,7 +157,7 @@ static inline void fsnotify_open(struct dentry *dentry)
154 mask |= IN_ISDIR; 157 mask |= IN_ISDIR;
155 158
156 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); 159 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
157 inotify_inode_queue_event(inode, mask, 0, NULL); 160 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
158} 161}
159 162
160/* 163/*
@@ -172,7 +175,7 @@ static inline void fsnotify_close(struct file *file)
172 mask |= IN_ISDIR; 175 mask |= IN_ISDIR;
173 176
174 inotify_dentry_parent_queue_event(dentry, mask, 0, name); 177 inotify_dentry_parent_queue_event(dentry, mask, 0, name);
175 inotify_inode_queue_event(inode, mask, 0, NULL); 178 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
176} 179}
177 180
178/* 181/*
@@ -187,7 +190,7 @@ static inline void fsnotify_xattr(struct dentry *dentry)
187 mask |= IN_ISDIR; 190 mask |= IN_ISDIR;
188 191
189 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); 192 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
190 inotify_inode_queue_event(inode, mask, 0, NULL); 193 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
191} 194}
192 195
193/* 196/*
@@ -234,7 +237,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
234 if (in_mask) { 237 if (in_mask) {
235 if (S_ISDIR(inode->i_mode)) 238 if (S_ISDIR(inode->i_mode))
236 in_mask |= IN_ISDIR; 239 in_mask |= IN_ISDIR;
237 inotify_inode_queue_event(inode, in_mask, 0, NULL); 240 inotify_inode_queue_event(inode, in_mask, 0, NULL, NULL);
238 inotify_dentry_parent_queue_event(dentry, in_mask, 0, 241 inotify_dentry_parent_queue_event(dentry, in_mask, 0,
239 dentry->d_name.name); 242 dentry->d_name.name);
240 } 243 }
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index 68b6e0127de4..e7899e7d83ad 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -91,7 +91,7 @@ struct inotify_watch {
91 91
92struct inotify_operations { 92struct inotify_operations {
93 void (*handle_event)(struct inotify_watch *, u32, u32, u32, 93 void (*handle_event)(struct inotify_watch *, u32, u32, u32,
94 const char *); 94 const char *, struct inode *);
95 void (*destroy_watch)(struct inotify_watch *); 95 void (*destroy_watch)(struct inotify_watch *);
96}; 96};
97 97
@@ -102,7 +102,7 @@ struct inotify_operations {
102extern void inotify_d_instantiate(struct dentry *, struct inode *); 102extern void inotify_d_instantiate(struct dentry *, struct inode *);
103extern void inotify_d_move(struct dentry *); 103extern void inotify_d_move(struct dentry *);
104extern void inotify_inode_queue_event(struct inode *, __u32, __u32, 104extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
105 const char *); 105 const char *, struct inode *);
106extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32, 106extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
107 const char *); 107 const char *);
108extern void inotify_unmount_inodes(struct list_head *); 108extern void inotify_unmount_inodes(struct list_head *);
@@ -134,7 +134,8 @@ static inline void inotify_d_move(struct dentry *dentry)
134 134
135static inline void inotify_inode_queue_event(struct inode *inode, 135static inline void inotify_inode_queue_event(struct inode *inode,
136 __u32 mask, __u32 cookie, 136 __u32 mask, __u32 cookie,
137 const char *filename) 137 const char *filename,
138 struct inode *n_inode)
138{ 139{
139} 140}
140 141