aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/inotify.h
diff options
context:
space:
mode:
authorAmy Griffis <amy.griffis@hp.com>2006-06-01 16:10:59 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2006-06-20 05:25:17 -0400
commit2d9048e201bfb67ba21f05e647b1286b8a4a5667 (patch)
tree1df2ca6780d403f3209cf445f8b0b27f45098434 /include/linux/inotify.h
parent90204e0b7b51e9f2a6905adca12dc331128602c7 (diff)
[PATCH] inotify (1/5): split kernel API from userspace support
The following series of patches introduces a kernel API for inotify, making it possible for kernel modules to benefit from inotify's mechanism for watching inodes. With these patches, inotify will maintain for each caller a list of watches (via an embedded struct inotify_watch), where each inotify_watch is associated with a corresponding struct inode. The caller registers an event handler and specifies for which filesystem events their event handler should be called per inotify_watch. 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>
Diffstat (limited to 'include/linux/inotify.h')
-rw-r--r--include/linux/inotify.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index 71aa1553ef38..68b6e0127de4 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -68,8 +68,37 @@ struct inotify_event {
68#include <linux/dcache.h> 68#include <linux/dcache.h>
69#include <linux/fs.h> 69#include <linux/fs.h>
70 70
71/*
72 * struct inotify_watch - represents a watch request on a specific inode
73 *
74 * h_list is protected by ih->mutex of the associated inotify_handle.
75 * i_list, mask are protected by inode->inotify_mutex of the associated inode.
76 * ih, inode, and wd are never written to once the watch is created.
77 *
78 * Callers must use the established inotify interfaces to access inotify_watch
79 * contents. The content of this structure is private to the inotify
80 * implementation.
81 */
82struct inotify_watch {
83 struct list_head h_list; /* entry in inotify_handle's list */
84 struct list_head i_list; /* entry in inode's list */
85 atomic_t count; /* reference count */
86 struct inotify_handle *ih; /* associated inotify handle */
87 struct inode *inode; /* associated inode */
88 __s32 wd; /* watch descriptor */
89 __u32 mask; /* event mask for this watch */
90};
91
92struct inotify_operations {
93 void (*handle_event)(struct inotify_watch *, u32, u32, u32,
94 const char *);
95 void (*destroy_watch)(struct inotify_watch *);
96};
97
71#ifdef CONFIG_INOTIFY 98#ifdef CONFIG_INOTIFY
72 99
100/* Kernel API for producing events */
101
73extern void inotify_d_instantiate(struct dentry *, struct inode *); 102extern void inotify_d_instantiate(struct dentry *, struct inode *);
74extern void inotify_d_move(struct dentry *); 103extern void inotify_d_move(struct dentry *);
75extern void inotify_inode_queue_event(struct inode *, __u32, __u32, 104extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
@@ -80,6 +109,18 @@ extern void inotify_unmount_inodes(struct list_head *);
80extern void inotify_inode_is_dead(struct inode *); 109extern void inotify_inode_is_dead(struct inode *);
81extern u32 inotify_get_cookie(void); 110extern u32 inotify_get_cookie(void);
82 111
112/* Kernel Consumer API */
113
114extern struct inotify_handle *inotify_init(const struct inotify_operations *);
115extern void inotify_destroy(struct inotify_handle *);
116extern __s32 inotify_find_update_watch(struct inotify_handle *, struct inode *,
117 u32);
118extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *,
119 struct inode *, __u32);
120extern int inotify_rm_wd(struct inotify_handle *, __u32);
121extern void get_inotify_watch(struct inotify_watch *);
122extern void put_inotify_watch(struct inotify_watch *);
123
83#else 124#else
84 125
85static inline void inotify_d_instantiate(struct dentry *dentry, 126static inline void inotify_d_instantiate(struct dentry *dentry,
@@ -116,6 +157,41 @@ static inline u32 inotify_get_cookie(void)
116 return 0; 157 return 0;
117} 158}
118 159
160static inline struct inotify_handle *inotify_init(const struct inotify_operations *ops)
161{
162 return ERR_PTR(-EOPNOTSUPP);
163}
164
165static inline void inotify_destroy(struct inotify_handle *ih)
166{
167}
168
169static inline __s32 inotify_find_update_watch(struct inotify_handle *ih,
170 struct inode *inode, u32 mask)
171{
172 return -EOPNOTSUPP;
173}
174
175static inline __s32 inotify_add_watch(struct inotify_handle *ih,
176 struct inotify_watch *watch,
177 struct inode *inode, __u32 mask)
178{
179 return -EOPNOTSUPP;
180}
181
182static inline int inotify_rm_wd(struct inotify_handle *ih, __u32 wd)
183{
184 return -EOPNOTSUPP;
185}
186
187static inline void get_inotify_watch(struct inotify_watch *watch)
188{
189}
190
191static inline void put_inotify_watch(struct inotify_watch *watch)
192{
193}
194
119#endif /* CONFIG_INOTIFY */ 195#endif /* CONFIG_INOTIFY */
120 196
121#endif /* __KERNEL __ */ 197#endif /* __KERNEL __ */