tridentfb: convert is_blade and is_xp macros into functions
[safe/jmp/linux-2.6] / include / linux / fsnotify.h
index 11438ef..a895131 100644 (file)
@@ -11,8 +11,6 @@
  * (C) Copyright 2005 Robert Love
  */
 
-#ifdef __KERNEL__
-
 #include <linux/dnotify.h>
 #include <linux/inotify.h>
 #include <linux/audit.h>
@@ -41,8 +39,9 @@ static inline void fsnotify_d_move(struct dentry *entry)
  */
 static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
                                 const char *old_name, const char *new_name,
-                                int isdir, struct inode *target, struct inode *source)
+                                int isdir, struct inode *target, struct dentry *moved)
 {
+       struct inode *source = moved->d_inode;
        u32 cookie = inotify_get_cookie();
 
        if (old_dir == new_dir)
@@ -54,19 +53,20 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
 
        if (isdir)
                isdir = IN_ISDIR;
-       inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name);
-       inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name);
+       inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name,
+                                 source);
+       inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name,
+                                 source);
 
        if (target) {
-               inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL);
+               inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL, NULL);
                inotify_inode_is_dead(target);
        }
 
        if (source) {
-               inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL);
+               inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL);
        }
-       audit_inode_child(old_name, source, old_dir->i_ino);
-       audit_inode_child(new_name, target, new_dir->i_ino);
+       audit_inode_child(new_name, moved, new_dir);
 }
 
 /*
@@ -85,18 +85,41 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
  */
 static inline void fsnotify_inoderemove(struct inode *inode)
 {
-       inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL);
+       inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL, NULL);
        inotify_inode_is_dead(inode);
 }
 
 /*
+ * fsnotify_link_count - inode's link count changed
+ */
+static inline void fsnotify_link_count(struct inode *inode)
+{
+       inotify_inode_queue_event(inode, IN_ATTRIB, 0, NULL, NULL);
+}
+
+/*
  * fsnotify_create - 'name' was linked in
  */
 static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
 {
        inode_dir_notify(inode, DN_CREATE);
-       inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name);
-       audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino);
+       inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name,
+                                 dentry->d_inode);
+       audit_inode_child(dentry->d_name.name, dentry, inode);
+}
+
+/*
+ * fsnotify_link - new hardlink in 'inode' directory
+ * Note: We have to pass also the linked inode ptr as some filesystems leave
+ *   new_dentry->d_inode NULL and instantiate inode pointer later
+ */
+static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry)
+{
+       inode_dir_notify(dir, DN_CREATE);
+       inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name,
+                                 inode);
+       fsnotify_link_count(inode);
+       audit_inode_child(new_dentry->d_name.name, new_dentry, dir);
 }
 
 /*
@@ -106,8 +129,8 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
 {
        inode_dir_notify(inode, DN_CREATE);
        inotify_inode_queue_event(inode, IN_CREATE | IN_ISDIR, 0, 
-                                 dentry->d_name.name);
-       audit_inode_child(dentry->d_name.name, dentry->d_inode, inode->i_ino);
+                                 dentry->d_name.name, dentry->d_inode);
+       audit_inode_child(dentry->d_name.name, dentry, inode);
 }
 
 /*
@@ -123,7 +146,7 @@ static inline void fsnotify_access(struct dentry *dentry)
 
        dnotify_parent(dentry, DN_ACCESS);
        inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
-       inotify_inode_queue_event(inode, mask, 0, NULL);
+       inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
 }
 
 /*
@@ -139,7 +162,7 @@ static inline void fsnotify_modify(struct dentry *dentry)
 
        dnotify_parent(dentry, DN_MODIFY);
        inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
-       inotify_inode_queue_event(inode, mask, 0, NULL);
+       inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
 }
 
 /*
@@ -154,7 +177,7 @@ static inline void fsnotify_open(struct dentry *dentry)
                mask |= IN_ISDIR;
 
        inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
-       inotify_inode_queue_event(inode, mask, 0, NULL);        
+       inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
 }
 
 /*
@@ -162,7 +185,7 @@ static inline void fsnotify_open(struct dentry *dentry)
  */
 static inline void fsnotify_close(struct file *file)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        const char *name = dentry->d_name.name;
        mode_t mode = file->f_mode;
@@ -172,7 +195,7 @@ static inline void fsnotify_close(struct file *file)
                mask |= IN_ISDIR;
 
        inotify_dentry_parent_queue_event(dentry, mask, 0, name);
-       inotify_inode_queue_event(inode, mask, 0, NULL);
+       inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
 }
 
 /*
@@ -187,7 +210,7 @@ static inline void fsnotify_xattr(struct dentry *dentry)
                mask |= IN_ISDIR;
 
        inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
-       inotify_inode_queue_event(inode, mask, 0, NULL);
+       inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
 }
 
 /*
@@ -234,7 +257,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
        if (in_mask) {
                if (S_ISDIR(inode->i_mode))
                        in_mask |= IN_ISDIR;
-               inotify_inode_queue_event(inode, in_mask, 0, NULL);
+               inotify_inode_queue_event(inode, in_mask, 0, NULL, NULL);
                inotify_dentry_parent_queue_event(dentry, in_mask, 0,
                                                  dentry->d_name.name);
        }
@@ -271,6 +294,4 @@ static inline void fsnotify_oldname_free(const char *old_name)
 
 #endif /* ! CONFIG_INOTIFY */
 
-#endif /* __KERNEL__ */
-
 #endif /* _LINUX_FS_NOTIFY_H */