aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/fs.h5
-rw-r--r--include/linux/fsnotify.h50
-rw-r--r--include/linux/inotify.h174
3 files changed, 3 insertions, 226 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 68ca1b0491af..e5598d2f99b9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -771,11 +771,6 @@ struct inode {
771 struct hlist_head i_fsnotify_mark_entries; /* fsnotify mark entries */ 771 struct hlist_head i_fsnotify_mark_entries; /* fsnotify mark entries */
772#endif 772#endif
773 773
774#ifdef CONFIG_INOTIFY
775 struct list_head inotify_watches; /* watches on this inode */
776 struct mutex inotify_mutex; /* protects the watches list */
777#endif
778
779 unsigned long i_state; 774 unsigned long i_state;
780 unsigned long dirtied_when; /* jiffies of first dirtying */ 775 unsigned long dirtied_when; /* jiffies of first dirtying */
781 776
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 01755909ce81..f958e93feb97 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -11,8 +11,6 @@
11 * (C) Copyright 2005 Robert Love 11 * (C) Copyright 2005 Robert Love
12 */ 12 */
13 13
14#include <linux/dnotify.h>
15#include <linux/inotify.h>
16#include <linux/fsnotify_backend.h> 14#include <linux/fsnotify_backend.h>
17#include <linux/audit.h> 15#include <linux/audit.h>
18#include <linux/slab.h> 16#include <linux/slab.h>
@@ -25,16 +23,12 @@ static inline void fsnotify_d_instantiate(struct dentry *entry,
25 struct inode *inode) 23 struct inode *inode)
26{ 24{
27 __fsnotify_d_instantiate(entry, inode); 25 __fsnotify_d_instantiate(entry, inode);
28
29 inotify_d_instantiate(entry, inode);
30} 26}
31 27
32/* Notify this dentry's parent about a child's events. */ 28/* Notify this dentry's parent about a child's events. */
33static inline void fsnotify_parent(struct dentry *dentry, __u32 mask) 29static inline void fsnotify_parent(struct dentry *dentry, __u32 mask)
34{ 30{
35 __fsnotify_parent(dentry, mask); 31 __fsnotify_parent(dentry, mask);
36
37 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
38} 32}
39 33
40/* 34/*
@@ -48,8 +42,6 @@ static inline void fsnotify_d_move(struct dentry *entry)
48 * cares about events from this entry. 42 * cares about events from this entry.
49 */ 43 */
50 __fsnotify_update_dcache_flags(entry); 44 __fsnotify_update_dcache_flags(entry);
51
52 inotify_d_move(entry);
53} 45}
54 46
55/* 47/*
@@ -57,8 +49,6 @@ static inline void fsnotify_d_move(struct dentry *entry)
57 */ 49 */
58static inline void fsnotify_link_count(struct inode *inode) 50static inline void fsnotify_link_count(struct inode *inode)
59{ 51{
60 inotify_inode_queue_event(inode, IN_ATTRIB, 0, NULL, NULL);
61
62 fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 52 fsnotify(inode, FS_ATTRIB, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
63} 53}
64 54
@@ -70,7 +60,6 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
70 int isdir, struct inode *target, struct dentry *moved) 60 int isdir, struct inode *target, struct dentry *moved)
71{ 61{
72 struct inode *source = moved->d_inode; 62 struct inode *source = moved->d_inode;
73 u32 in_cookie = inotify_get_cookie();
74 u32 fs_cookie = fsnotify_get_cookie(); 63 u32 fs_cookie = fsnotify_get_cookie();
75 __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM); 64 __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM);
76 __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO); 65 __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO);
@@ -80,31 +69,18 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
80 old_dir_mask |= FS_DN_RENAME; 69 old_dir_mask |= FS_DN_RENAME;
81 70
82 if (isdir) { 71 if (isdir) {
83 isdir = IN_ISDIR;
84 old_dir_mask |= FS_IN_ISDIR; 72 old_dir_mask |= FS_IN_ISDIR;
85 new_dir_mask |= FS_IN_ISDIR; 73 new_dir_mask |= FS_IN_ISDIR;
86 } 74 }
87 75
88 inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir, in_cookie, old_name,
89 source);
90 inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, in_cookie, new_name,
91 source);
92
93 fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); 76 fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie);
94 fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE, new_name, fs_cookie); 77 fsnotify(new_dir, new_dir_mask, new_dir, FSNOTIFY_EVENT_INODE, new_name, fs_cookie);
95 78
96 if (target) { 79 if (target)
97 inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL, NULL);
98 inotify_inode_is_dead(target);
99
100 /* this is really a link_count change not a removal */
101 fsnotify_link_count(target); 80 fsnotify_link_count(target);
102 }
103 81
104 if (source) { 82 if (source)
105 inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL);
106 fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); 83 fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0);
107 }
108 audit_inode_child(moved, new_dir); 84 audit_inode_child(moved, new_dir);
109} 85}
110 86
@@ -134,9 +110,6 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
134 */ 110 */
135static inline void fsnotify_inoderemove(struct inode *inode) 111static inline void fsnotify_inoderemove(struct inode *inode)
136{ 112{
137 inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL, NULL);
138 inotify_inode_is_dead(inode);
139
140 fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 113 fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
141 __fsnotify_inode_delete(inode); 114 __fsnotify_inode_delete(inode);
142} 115}
@@ -146,8 +119,6 @@ static inline void fsnotify_inoderemove(struct inode *inode)
146 */ 119 */
147static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) 120static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
148{ 121{
149 inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name,
150 dentry->d_inode);
151 audit_inode_child(dentry, inode); 122 audit_inode_child(dentry, inode);
152 123
153 fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); 124 fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0);
@@ -160,8 +131,6 @@ static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
160 */ 131 */
161static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry) 132static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry)
162{ 133{
163 inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name,
164 inode);
165 fsnotify_link_count(inode); 134 fsnotify_link_count(inode);
166 audit_inode_child(new_dentry, dir); 135 audit_inode_child(new_dentry, dir);
167 136
@@ -176,7 +145,6 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
176 __u32 mask = (FS_CREATE | FS_IN_ISDIR); 145 __u32 mask = (FS_CREATE | FS_IN_ISDIR);
177 struct inode *d_inode = dentry->d_inode; 146 struct inode *d_inode = dentry->d_inode;
178 147
179 inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode);
180 audit_inode_child(dentry, inode); 148 audit_inode_child(dentry, inode);
181 149
182 fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); 150 fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0);
@@ -193,8 +161,6 @@ static inline void fsnotify_access(struct dentry *dentry)
193 if (S_ISDIR(inode->i_mode)) 161 if (S_ISDIR(inode->i_mode))
194 mask |= FS_IN_ISDIR; 162 mask |= FS_IN_ISDIR;
195 163
196 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
197
198 fsnotify_parent(dentry, mask); 164 fsnotify_parent(dentry, mask);
199 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 165 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
200} 166}
@@ -210,8 +176,6 @@ static inline void fsnotify_modify(struct dentry *dentry)
210 if (S_ISDIR(inode->i_mode)) 176 if (S_ISDIR(inode->i_mode))
211 mask |= FS_IN_ISDIR; 177 mask |= FS_IN_ISDIR;
212 178
213 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
214
215 fsnotify_parent(dentry, mask); 179 fsnotify_parent(dentry, mask);
216 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 180 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
217} 181}
@@ -227,8 +191,6 @@ static inline void fsnotify_open(struct dentry *dentry)
227 if (S_ISDIR(inode->i_mode)) 191 if (S_ISDIR(inode->i_mode))
228 mask |= FS_IN_ISDIR; 192 mask |= FS_IN_ISDIR;
229 193
230 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
231
232 fsnotify_parent(dentry, mask); 194 fsnotify_parent(dentry, mask);
233 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 195 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
234} 196}
@@ -246,8 +208,6 @@ static inline void fsnotify_close(struct file *file)
246 if (S_ISDIR(inode->i_mode)) 208 if (S_ISDIR(inode->i_mode))
247 mask |= FS_IN_ISDIR; 209 mask |= FS_IN_ISDIR;
248 210
249 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
250
251 fsnotify_parent(dentry, mask); 211 fsnotify_parent(dentry, mask);
252 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); 212 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
253} 213}
@@ -263,8 +223,6 @@ static inline void fsnotify_xattr(struct dentry *dentry)
263 if (S_ISDIR(inode->i_mode)) 223 if (S_ISDIR(inode->i_mode))
264 mask |= FS_IN_ISDIR; 224 mask |= FS_IN_ISDIR;
265 225
266 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
267
268 fsnotify_parent(dentry, mask); 226 fsnotify_parent(dentry, mask);
269 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 227 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
270} 228}
@@ -299,14 +257,12 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
299 if (mask) { 257 if (mask) {
300 if (S_ISDIR(inode->i_mode)) 258 if (S_ISDIR(inode->i_mode))
301 mask |= FS_IN_ISDIR; 259 mask |= FS_IN_ISDIR;
302 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
303
304 fsnotify_parent(dentry, mask); 260 fsnotify_parent(dentry, mask);
305 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 261 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
306 } 262 }
307} 263}
308 264
309#if defined(CONFIG_INOTIFY) || defined(CONFIG_FSNOTIFY) /* notify helpers */ 265#if defined(CONFIG_FSNOTIFY) /* notify helpers */
310 266
311/* 267/*
312 * fsnotify_oldname_init - save off the old filename before we change it 268 * fsnotify_oldname_init - save off the old filename before we change it
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index 37ea2894b3c0..959a38b8f75d 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -69,178 +69,4 @@ struct inotify_event {
69#define IN_CLOEXEC O_CLOEXEC 69#define IN_CLOEXEC O_CLOEXEC
70#define IN_NONBLOCK O_NONBLOCK 70#define IN_NONBLOCK O_NONBLOCK
71 71
72#ifdef __KERNEL__
73
74#include <linux/dcache.h>
75#include <linux/fs.h>
76
77/*
78 * struct inotify_watch - represents a watch request on a specific inode
79 *
80 * h_list is protected by ih->mutex of the associated inotify_handle.
81 * i_list, mask are protected by inode->inotify_mutex of the associated inode.
82 * ih, inode, and wd are never written to once the watch is created.
83 *
84 * Callers must use the established inotify interfaces to access inotify_watch
85 * contents. The content of this structure is private to the inotify
86 * implementation.
87 */
88struct inotify_watch {
89 struct list_head h_list; /* entry in inotify_handle's list */
90 struct list_head i_list; /* entry in inode's list */
91 atomic_t count; /* reference count */
92 struct inotify_handle *ih; /* associated inotify handle */
93 struct inode *inode; /* associated inode */
94 __s32 wd; /* watch descriptor */
95 __u32 mask; /* event mask for this watch */
96};
97
98struct inotify_operations {
99 void (*handle_event)(struct inotify_watch *, u32, u32, u32,
100 const char *, struct inode *);
101 void (*destroy_watch)(struct inotify_watch *);
102};
103
104#ifdef CONFIG_INOTIFY
105
106/* Kernel API for producing events */
107
108extern void inotify_d_instantiate(struct dentry *, struct inode *);
109extern void inotify_d_move(struct dentry *);
110extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
111 const char *, struct inode *);
112extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
113 const char *);
114extern void inotify_unmount_inodes(struct list_head *);
115extern void inotify_inode_is_dead(struct inode *);
116extern u32 inotify_get_cookie(void);
117
118/* Kernel Consumer API */
119
120extern struct inotify_handle *inotify_init(const struct inotify_operations *);
121extern void inotify_init_watch(struct inotify_watch *);
122extern void inotify_destroy(struct inotify_handle *);
123extern __s32 inotify_find_watch(struct inotify_handle *, struct inode *,
124 struct inotify_watch **);
125extern __s32 inotify_find_update_watch(struct inotify_handle *, struct inode *,
126 u32);
127extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *,
128 struct inode *, __u32);
129extern __s32 inotify_clone_watch(struct inotify_watch *, struct inotify_watch *);
130extern void inotify_evict_watch(struct inotify_watch *);
131extern int inotify_rm_watch(struct inotify_handle *, struct inotify_watch *);
132extern int inotify_rm_wd(struct inotify_handle *, __u32);
133extern void inotify_remove_watch_locked(struct inotify_handle *,
134 struct inotify_watch *);
135extern void get_inotify_watch(struct inotify_watch *);
136extern void put_inotify_watch(struct inotify_watch *);
137extern int pin_inotify_watch(struct inotify_watch *);
138extern void unpin_inotify_watch(struct inotify_watch *);
139
140#else
141
142static inline void inotify_d_instantiate(struct dentry *dentry,
143 struct inode *inode)
144{
145}
146
147static inline void inotify_d_move(struct dentry *dentry)
148{
149}
150
151static inline void inotify_inode_queue_event(struct inode *inode,
152 __u32 mask, __u32 cookie,
153 const char *filename,
154 struct inode *n_inode)
155{
156}
157
158static inline void inotify_dentry_parent_queue_event(struct dentry *dentry,
159 __u32 mask, __u32 cookie,
160 const char *filename)
161{
162}
163
164static inline void inotify_unmount_inodes(struct list_head *list)
165{
166}
167
168static inline void inotify_inode_is_dead(struct inode *inode)
169{
170}
171
172static inline u32 inotify_get_cookie(void)
173{
174 return 0;
175}
176
177static inline struct inotify_handle *inotify_init(const struct inotify_operations *ops)
178{
179 return ERR_PTR(-EOPNOTSUPP);
180}
181
182static inline void inotify_init_watch(struct inotify_watch *watch)
183{
184}
185
186static inline void inotify_destroy(struct inotify_handle *ih)
187{
188}
189
190static inline __s32 inotify_find_watch(struct inotify_handle *ih, struct inode *inode,
191 struct inotify_watch **watchp)
192{
193 return -EOPNOTSUPP;
194}
195
196static inline __s32 inotify_find_update_watch(struct inotify_handle *ih,
197 struct inode *inode, u32 mask)
198{
199 return -EOPNOTSUPP;
200}
201
202static inline __s32 inotify_add_watch(struct inotify_handle *ih,
203 struct inotify_watch *watch,
204 struct inode *inode, __u32 mask)
205{
206 return -EOPNOTSUPP;
207}
208
209static inline int inotify_rm_watch(struct inotify_handle *ih,
210 struct inotify_watch *watch)
211{
212 return -EOPNOTSUPP;
213}
214
215static inline int inotify_rm_wd(struct inotify_handle *ih, __u32 wd)
216{
217 return -EOPNOTSUPP;
218}
219
220static inline void inotify_remove_watch_locked(struct inotify_handle *ih,
221 struct inotify_watch *watch)
222{
223}
224
225static inline void get_inotify_watch(struct inotify_watch *watch)
226{
227}
228
229static inline void put_inotify_watch(struct inotify_watch *watch)
230{
231}
232
233extern inline int pin_inotify_watch(struct inotify_watch *watch)
234{
235 return 0;
236}
237
238extern inline void unpin_inotify_watch(struct inotify_watch *watch)
239{
240}
241
242#endif /* CONFIG_INOTIFY */
243
244#endif /* __KERNEL __ */
245
246#endif /* _LINUX_INOTIFY_H */ 72#endif /* _LINUX_INOTIFY_H */