On Tue, Jul 12, 2005 at 02:18:20PM -0500, Timothy R. Chavez wrote:
Hi,
I've CCed some folks that I thought might be interested in this update and may
not be on linux-audit.
Unfortunatly linux-audit is a closed list, so this post will probably
bounce :(
Based on recent discussion on LKML and some IRC conversations, a
generic file
system notification framework is being written to merge common functionality
between the "auditfs" component of the audit framework and Inotify. This
framework will be mostly comprised of the watch logic implemented by the
"auditfs" component (I_AUDIT, hash table, update hook, helper functions, etc)
and the fsnotify hooks written by Robert Love. User's of this framework will
pass their own callback functions in when adding a watch via this framework
which will effectively be stored on the watch and called from the watch hook
that discovers it.
We introduce fs/watch.c and include/linux/watch.h
fswatch.h perhaps?
diff --exclude=.git -Nurp audit-2.6/include/linux/watch.h
audit-2.6.git-fsnotify/include/linux/watch.h
--- audit-2.6/include/linux/watch.h 1969-12-31 18:00:00.000000000 -0600
+++ audit-2.6.git-fsnotify/include/linux/watch.h 2005-07-11 01:33:45.000000000 -0500
@@ -0,0 +1,57 @@
+#ifndef _WATCH_H
+#define _WATCH_H
+
+struct watch {
+ atomic_t w_count;
Use a struct kref instead of rolling your own here.
+ struct hlist_node w_node; /* per-directory list */
+ struct hlist_node w_master; /* Master watch list */
+ struct hlist_node w_watched; /* Watches on inode */
+ dev_t w_dev; /* Superblock device */
+ __u32 w_perms; /* Permissions filtering */
+ char *w_name; /* Watch beneath parent */
+ char *w_path; /* Insertion path */
+ char *w_filterkey; /* An arbitrary filtering key */
+ void (*w_func); /* Callback function */
+};
+
+struct watch_inode_data {
+ int count;
same here.
+ struct watch_inode_data *next_hash; /* Watch data hash table
*/
formatting issue.
+ struct inode *inode; /* Inode to which it belongs */
+ struct hlist_head watches; /* List of watches on inode */
+ struct hlist_head watchlist; /* Watches for children */
+};
+
+/* User */
+extern int watch_add(struct watch *, struct inode *);
+extern int watch_rem(struct watch *, struct inode *);
+extern struct watch *watch_alloc(void);
+extern struct watch *watch_get(struct watch *);
+extern void watch_free(struct watch *);
+extern void watch_put(struct watch *);
Why a difference? The last watch_put should free the structure, right?
+
+/* Internals */
+
+extern int watch_init(void);
+extern void watch_inode_free(struct inode *);
+extern void watch_update(struct dentry *, int);
+
+/* Hooks */
+#ifdef CONFIG_FSWATCH
+extern const char *watch_notify_oldname_init(const char *);
+extern void watch_notify_oldname_free(const char *);
+extern void watch_notify_move(struct inode *, struct inode *, const char *, const char
*, int);
+extern void watch_notify_unlink(struct dentry *, struct inode *);
+extern void watch_notify_rmdir(struct dentry *, struct inode *, struct inode *);
+extern void watch_notify_create(struct inode *, const char *);
+extern void watch_notify_mkdir(struct inode *, const char *);
+extern void watch_notify_access(struct dentry *dentry);
+extern void watch_notify_modify(struct dentry *dentry);
+extern void watch_notify_open(struct dentry *dentry, int mask);
+extern void watch_notify_close(struct file *file);
+extern void watch_notify_xattr(struct dentry *dentry);
+extern void watch_notify_change(struct dentry *dentry, unsigned int ia_valid);
+#endif /* CONFIG_FSWATCH */
No static inlines if !CONFIG_FSWATCH?
thanks,
greg k-h