diff options
| author | Amy Griffis <amy.griffis@hp.com> | 2006-06-01 16:10:59 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2006-06-20 05:25:17 -0400 |
| commit | 2d9048e201bfb67ba21f05e647b1286b8a4a5667 (patch) | |
| tree | 1df2ca6780d403f3209cf445f8b0b27f45098434 /include/linux | |
| parent | 90204e0b7b51e9f2a6905adca12dc331128602c7 (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')
| -rw-r--r-- | include/linux/inotify.h | 76 | ||||
| -rw-r--r-- | include/linux/sched.h | 2 |
2 files changed, 77 insertions, 1 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 | */ | ||
| 82 | struct 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 | |||
| 92 | struct 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 | |||
| 73 | extern void inotify_d_instantiate(struct dentry *, struct inode *); | 102 | extern void inotify_d_instantiate(struct dentry *, struct inode *); |
| 74 | extern void inotify_d_move(struct dentry *); | 103 | extern void inotify_d_move(struct dentry *); |
| 75 | extern void inotify_inode_queue_event(struct inode *, __u32, __u32, | 104 | extern void inotify_inode_queue_event(struct inode *, __u32, __u32, |
| @@ -80,6 +109,18 @@ extern void inotify_unmount_inodes(struct list_head *); | |||
| 80 | extern void inotify_inode_is_dead(struct inode *); | 109 | extern void inotify_inode_is_dead(struct inode *); |
| 81 | extern u32 inotify_get_cookie(void); | 110 | extern u32 inotify_get_cookie(void); |
| 82 | 111 | ||
| 112 | /* Kernel Consumer API */ | ||
| 113 | |||
| 114 | extern struct inotify_handle *inotify_init(const struct inotify_operations *); | ||
| 115 | extern void inotify_destroy(struct inotify_handle *); | ||
| 116 | extern __s32 inotify_find_update_watch(struct inotify_handle *, struct inode *, | ||
| 117 | u32); | ||
| 118 | extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *, | ||
| 119 | struct inode *, __u32); | ||
| 120 | extern int inotify_rm_wd(struct inotify_handle *, __u32); | ||
| 121 | extern void get_inotify_watch(struct inotify_watch *); | ||
| 122 | extern void put_inotify_watch(struct inotify_watch *); | ||
| 123 | |||
| 83 | #else | 124 | #else |
| 84 | 125 | ||
| 85 | static inline void inotify_d_instantiate(struct dentry *dentry, | 126 | static 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 | ||
| 160 | static inline struct inotify_handle *inotify_init(const struct inotify_operations *ops) | ||
| 161 | { | ||
| 162 | return ERR_PTR(-EOPNOTSUPP); | ||
| 163 | } | ||
| 164 | |||
| 165 | static inline void inotify_destroy(struct inotify_handle *ih) | ||
| 166 | { | ||
| 167 | } | ||
| 168 | |||
| 169 | static inline __s32 inotify_find_update_watch(struct inotify_handle *ih, | ||
| 170 | struct inode *inode, u32 mask) | ||
| 171 | { | ||
| 172 | return -EOPNOTSUPP; | ||
| 173 | } | ||
| 174 | |||
| 175 | static 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 | |||
| 182 | static inline int inotify_rm_wd(struct inotify_handle *ih, __u32 wd) | ||
| 183 | { | ||
| 184 | return -EOPNOTSUPP; | ||
| 185 | } | ||
| 186 | |||
| 187 | static inline void get_inotify_watch(struct inotify_watch *watch) | ||
| 188 | { | ||
| 189 | } | ||
| 190 | |||
| 191 | static 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 __ */ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 29b7d4f87d20..864e5a70ff65 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -494,7 +494,7 @@ struct user_struct { | |||
| 494 | atomic_t processes; /* How many processes does this user have? */ | 494 | atomic_t processes; /* How many processes does this user have? */ |
| 495 | atomic_t files; /* How many open files does this user have? */ | 495 | atomic_t files; /* How many open files does this user have? */ |
| 496 | atomic_t sigpending; /* How many pending signals does this user have? */ | 496 | atomic_t sigpending; /* How many pending signals does this user have? */ |
| 497 | #ifdef CONFIG_INOTIFY | 497 | #ifdef CONFIG_INOTIFY_USER |
| 498 | atomic_t inotify_watches; /* How many inotify watches does this user have? */ | 498 | atomic_t inotify_watches; /* How many inotify watches does this user have? */ |
| 499 | atomic_t inotify_devs; /* How many inotify devs does this user have opened? */ | 499 | atomic_t inotify_devs; /* How many inotify devs does this user have opened? */ |
| 500 | #endif | 500 | #endif |
