mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robert Love <rml@novell.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: [patch] generic notification layer
Date: Mon, 31 Jan 2005 17:42:38 -0500	[thread overview]
Message-ID: <1107211358.4019.36.camel@betsy.boston.ximian.com> (raw)
In-Reply-To: <20050124121729.GA29392@infradead.org>

On Mon, 2005-01-24 at 12:17 +0000, Christoph Hellwig wrote:

> Haven't had time to look at the current implementation, but the in-kernel
> interface is still horrible as it duplicates the dnotify calls all over the
> place, using IN_FOO instead of DN_FOO.  Please add a layer of notify_foo
> wrappers that calls into both.

Hi, Christoph!

I went ahead and wrote a generic notification layer, wrapping inotify,
dnotify, and some related work behind nice, clean interfaces such as
"fsnotify_move()".

The patch is a net gain of -125 lines ignoring the new
<linux/fsnotify.h>, so it does remove a bit of code from fs/, which is
nice.

Compile tested, but not yet booted.  Find an interdiff below, so you can
get an idea of the interfaces, at least.

If this is really an issue for you, I think that this should be a step
in the right direction.

Best,

	Robert Love


Signed-off-by: Robert Love <rml@novell.com>

diff -u linux/fs/attr.c linux/fs/attr.c
--- linux/fs/attr.c	2005-01-18 16:11:08.000000000 -0500
+++ linux/fs/attr.c	2005-01-31 15:52:37.756482208 -0500
@@ -10,8 +10,7 @@
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/smp_lock.h>
-#include <linux/dnotify.h>
-#include <linux/inotify.h>
+#include <linux/fsnotify.h>
 #include <linux/fcntl.h>
 #include <linux/quotaops.h>
 #include <linux/security.h>
@@ -106,51 +105,6 @@
 }
 EXPORT_SYMBOL(inode_setattr);
 
-void setattr_mask (unsigned int ia_valid, int *dn_mask, u32 *in_mask)
-{
-	int dnmask;
-	u32 inmask;
-
-	inmask = 0;
-	dnmask = 0;
-
-	if (!dn_mask || !in_mask) {
-		return;
-	}
-        if (ia_valid & ATTR_UID) {
-                inmask |= IN_ATTRIB;
-		dnmask |= DN_ATTRIB;
-	}
-        if (ia_valid & ATTR_GID) {
-                inmask |= IN_ATTRIB;
-		dnmask |= DN_ATTRIB;
-	}
-        if (ia_valid & ATTR_SIZE) {
-                inmask |= IN_MODIFY;
-		dnmask |= DN_MODIFY;
-	}
-        /* both times implies a utime(s) call */
-        if ((ia_valid & (ATTR_ATIME|ATTR_MTIME)) == (ATTR_ATIME|ATTR_MTIME)) {
-                inmask |= IN_ATTRIB;
-		dnmask |= DN_ATTRIB;
-	}
-        else if (ia_valid & ATTR_ATIME) {
-                inmask |= IN_ACCESS;
-		dnmask |= DN_ACCESS;
-	}
-        else if (ia_valid & ATTR_MTIME) {
-                inmask |= IN_MODIFY;
-		dnmask |= DN_MODIFY;
-	}
-        if (ia_valid & ATTR_MODE) {
-                inmask |= IN_ATTRIB;
-		dnmask |= DN_ATTRIB;
-	}
-
-	*in_mask = inmask;
-	*dn_mask = dnmask;
-}
-
 int notify_change(struct dentry * dentry, struct iattr * attr)
 {
 	struct inode *inode = dentry->d_inode;
@@ -206,21 +160,10 @@
 				error = inode_setattr(inode, attr);
 		}
 	}
-	if (!error) {
-		int dn_mask;
-		u32 in_mask;
 
-		setattr_mask (ia_valid, &dn_mask, &in_mask);
+	if (!error)
+		fsnotify_change(dentry, ia_valid);
 
-		if (dn_mask)
-			dnotify_parent(dentry, dn_mask);
-		if (in_mask) {
-			inotify_inode_queue_event(dentry->d_inode, in_mask, 0,
-						  NULL);
-			inotify_dentry_parent_queue_event(dentry, in_mask, 0,
-							  dentry->d_name.name);
-		}
-	}
 	return error;
 }
 
diff -u linux/fs/file_table.c linux/fs/file_table.c
--- linux/fs/file_table.c	2005-01-18 16:11:08.000000000 -0500
+++ linux/fs/file_table.c	2005-01-31 15:46:49.248463480 -0500
@@ -16,7 +16,7 @@
 #include <linux/eventpoll.h>
 #include <linux/mount.h>
 #include <linux/cdev.h>
-#include <linux/inotify.h>
+#include <linux/fsnotify.h>
 
 /* sysctl tunables... */
 struct files_stat_struct files_stat = {
@@ -121,12 +121,9 @@
 	struct dentry *dentry = file->f_dentry;
 	struct vfsmount *mnt = file->f_vfsmnt;
 	struct inode *inode = dentry->d_inode;
-	u32 mask;
 
 
-	mask = (file->f_mode & FMODE_WRITE) ? IN_CLOSE_WRITE : IN_CLOSE_NOWRITE;
-	inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
-	inotify_inode_queue_event(inode, mask, 0, NULL);
+	fsnotify_close(dentry, inode, file->f_mode, dentry->d_name.name);
 
 	might_sleep();
 	/*
diff -u linux/fs/namei.c linux/fs/namei.c
--- linux/fs/namei.c	2005-01-20 15:32:24.000000000 -0500
+++ linux/fs/namei.c	2005-01-31 17:24:21.870729656 -0500
@@ -21,8 +21,7 @@
 #include <linux/namei.h>
 #include <linux/quotaops.h>
 #include <linux/pagemap.h>
-#include <linux/dnotify.h>
-#include <linux/inotify.h>
+#include <linux/fsnotify.h>
 #include <linux/smp_lock.h>
 #include <linux/personality.h>
 #include <linux/security.h>
@@ -1242,9 +1241,7 @@
 	DQUOT_INIT(dir);
 	error = dir->i_op->create(dir, dentry, mode, nd);
 	if (!error) {
-		inode_dir_notify(dir, DN_CREATE);
-		inotify_inode_queue_event(dir, IN_CREATE_FILE,
-				0, dentry->d_name.name);
+		fsnotify_create(dir, dentry->d_name.name);
 		security_inode_post_create(dir, dentry, mode);
 	}
 	return error;
@@ -1558,9 +1555,7 @@
 	DQUOT_INIT(dir);
 	error = dir->i_op->mknod(dir, dentry, mode, dev);
 	if (!error) {
-		inode_dir_notify(dir, DN_CREATE);
-		inotify_inode_queue_event(dir, IN_CREATE_FILE, 0,
-				dentry->d_name.name);
+		fsnotify_create(dir, dentry->d_name.name);
 		security_inode_post_mknod(dir, dentry, mode, dev);
 	}
 	return error;
@@ -1633,9 +1628,7 @@
 	DQUOT_INIT(dir);
 	error = dir->i_op->mkdir(dir, dentry, mode);
 	if (!error) {
-		inode_dir_notify(dir, DN_CREATE);
-		inotify_inode_queue_event(dir, IN_CREATE_SUBDIR, 0,
-				dentry->d_name.name);
+		fsnotify_mkdir(dir, dentry->d_name.name);
 		security_inode_post_mkdir(dir,dentry, mode);
 	}
 	return error;
@@ -1729,15 +1722,8 @@
 		}
 	}
 	up(&dentry->d_inode->i_sem);
-	if (!error) {
-		inode_dir_notify(dir, DN_DELETE);
-		inotify_inode_queue_event(dir, IN_DELETE_SUBDIR, 0,
-				dentry->d_name.name);
-		inotify_inode_queue_event(dentry->d_inode, IN_DELETE_SELF, 0,
-				NULL);
-		inotify_inode_is_dead (dentry->d_inode);
-		d_delete(dentry);
-	}
+	if (!error)
+		fsnotify_rmdir(dentry, dentry->d_inode, dir);
 	dput(dentry);
 
 	return error;
@@ -1807,15 +1793,9 @@
 	up(&dentry->d_inode->i_sem);
 
 	/* We don't d_delete() NFS sillyrenamed files--they still exist. */
-	if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
-		inode_dir_notify(dir, DN_DELETE);
-		inotify_inode_queue_event(dir, IN_DELETE_FILE, 0,
-				dentry->d_name.name);
-		inotify_inode_queue_event(dentry->d_inode, IN_DELETE_SELF, 0,
-				NULL);
-		inotify_inode_is_dead (dentry->d_inode);
-		d_delete(dentry);
-	}
+	if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED))
+		fsnotify_unlink(dentry->d_inode, dir, dentry);
+
 	return error;
 }
 
@@ -1889,9 +1869,7 @@
 	DQUOT_INIT(dir);
 	error = dir->i_op->symlink(dir, dentry, oldname);
 	if (!error) {
-		inode_dir_notify(dir, DN_CREATE);
-		inotify_inode_queue_event(dir, IN_CREATE_FILE, 0,
-				dentry->d_name.name);
+		fsnotify_create(dir, dentry->d_name.name);
 		security_inode_post_symlink(dir, dentry, oldname);
 	}
 	return error;
@@ -1964,9 +1942,7 @@
 	error = dir->i_op->link(old_dentry, dir, new_dentry);
 	up(&old_dentry->d_inode->i_sem);
 	if (!error) {
-		inode_dir_notify(dir, DN_CREATE);
-		inotify_inode_queue_event(dir, IN_CREATE_FILE, 0, 
-					new_dentry->d_name.name);
+		fsnotify_create(dir, new_dentry->d_name.name);
 		security_inode_post_link(old_dentry, dir, new_dentry);
 	}
 	return error;
@@ -2131,7 +2107,6 @@
 	int error;
 	int is_dir = S_ISDIR(old_dentry->d_inode->i_mode);
 	char *old_name;
-	u32 cookie;
 
 	if (old_dentry->d_inode == new_dentry->d_inode)
  		return 0;
@@ -2153,28 +2128,17 @@
 	DQUOT_INIT(old_dir);
 	DQUOT_INIT(new_dir);
 
-	old_name = inotify_oldname_init(old_dentry);
+	old_name = fsnotify_oldname_init(old_dentry);
 
 	if (is_dir)
 		error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);
 	else
 		error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
 	if (!error) {
-		if (old_dir == new_dir)
-			inode_dir_notify(old_dir, DN_RENAME);
-		else {
-			inode_dir_notify(old_dir, DN_DELETE);
-			inode_dir_notify(new_dir, DN_CREATE);
-		}
-
-		cookie = inotify_get_cookie();
-
-		inotify_inode_queue_event(old_dir, IN_MOVED_FROM, cookie,
-					  old_name);
-		inotify_inode_queue_event(new_dir, IN_MOVED_TO, cookie,
-					  old_dentry->d_name.name);
+		const char *new_name = old_dentry->d_name.name;
+		fsnotify_move(old_dir, new_dir, old_name, new_name);
 	}
-	inotify_oldname_free(old_name);
+	fsnotify_oldname_free(old_name);
 
 	return error;
 }
diff -u linux/fs/open.c linux/fs/open.c
--- linux/fs/open.c	2005-01-18 16:11:08.000000000 -0500
+++ linux/fs/open.c	2005-01-31 16:28:33.478762608 -0500
@@ -10,8 +10,7 @@
 #include <linux/file.h>
 #include <linux/smp_lock.h>
 #include <linux/quotaops.h>
-#include <linux/dnotify.h>
-#include <linux/inotify.h>
+#include <linux/fsnotify.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/tty.h>
@@ -954,13 +953,13 @@
 		fd = get_unused_fd();
 		if (fd >= 0) {
 			struct file *f = filp_open(tmp, flags, mode);
+			struct dentry *dentry = f->f_dentry;
+
 			error = PTR_ERR(f);
 			if (IS_ERR(f))
 				goto out_error;
-			inotify_inode_queue_event(f->f_dentry->d_inode,
-					IN_OPEN, 0, NULL);
-			inotify_dentry_parent_queue_event(f->f_dentry, IN_OPEN,
-					0, f->f_dentry->d_name.name);
+			fsnotify_open(dentry, dentry->d_inode,
+				      dentry->d_name.name);
 			fd_install(fd, f);
 		}
 out:
@@ -1012,7 +1011,7 @@
 			retval = err;
 	}
 
-	dnotify_flush(filp, id);
+	fsnotify_flush(filp, id);
 	locks_remove_posix(filp, id);
 	fput(filp);
 	return retval;
diff -u linux/fs/read_write.c linux/fs/read_write.c
--- linux/fs/read_write.c	2005-01-18 16:11:08.000000000 -0500
+++ linux/fs/read_write.c	2005-01-31 16:35:05.270201256 -0500
@@ -10,8 +10,7 @@
 #include <linux/file.h>
 #include <linux/uio.h>
 #include <linux/smp_lock.h>
-#include <linux/dnotify.h>
-#include <linux/inotify.h>
+#include <linux/fsnotify.h>
 #include <linux/security.h>
 #include <linux/module.h>
 #include <linux/syscalls.h>
@@ -219,11 +218,8 @@
 				ret = do_sync_read(file, buf, count, pos);
 			if (ret > 0) {
 				struct dentry *dentry = file->f_dentry;
-				dnotify_parent(dentry, DN_ACCESS);
-				inotify_dentry_parent_queue_event(dentry,
-						IN_ACCESS, 0, dentry->d_name.name);
-				inotify_inode_queue_event(inode, IN_ACCESS, 0,
-						NULL);
+				fsnotify_access(dentry, inode,
+						dentry->d_name.name);
 			}
 		}
 	}
@@ -269,11 +265,8 @@
 				ret = do_sync_write(file, buf, count, pos);
 			if (ret > 0) {
 				struct dentry *dentry = file->f_dentry;
-				dnotify_parent(dentry, DN_MODIFY);
-				inotify_dentry_parent_queue_event(dentry,
-						IN_MODIFY, 0, dentry->d_name.name);
-				inotify_inode_queue_event(inode, IN_MODIFY, 0,
-						NULL);
+				fsnotify_modify(dentry, inode,
+						dentry->d_name.name);
 			}
 		}
 	}
@@ -508,12 +501,12 @@
 		kfree(iov);
 	if ((ret + (type == READ)) > 0) {
 		struct dentry *dentry = file->f_dentry;
-		dnotify_parent(dentry, (type == READ) ? DN_ACCESS : DN_MODIFY);
-		inotify_dentry_parent_queue_event(dentry,
-				(type == READ) ? IN_ACCESS : IN_MODIFY, 0,
-				dentry->d_name.name);
-		inotify_inode_queue_event (dentry->d_inode,
-				(type == READ) ? IN_ACCESS : IN_MODIFY, 0, NULL);
+		struct inode *inode = dentry->d_inode;
+
+		if (type == READ)
+			fsnotify_access(dentry, inode, dentry->d_name.name);
+		else
+			fsnotify_modify(dentry, inode, dentry->d_name.name);
 	}
 	return ret;
 }
diff -u linux/fs/super.c linux/fs/super.c
--- linux/fs/super.c	2005-01-18 16:11:08.000000000 -0500
+++ linux/fs/super.c	2005-01-31 14:53:38.828481040 -0500
@@ -37,9 +37,8 @@
 #include <linux/writeback.h>		/* for the emergency remount stuff */
 #include <linux/idr.h>
 #include <linux/kobject.h>
+#include <linux/fsnotify.h>
 #include <asm/uaccess.h>
-#include <linux/inotify.h>
-
 
 void get_filesystem(struct file_system_type *fs);
 void put_filesystem(struct file_system_type *fs);
@@ -228,7 +227,7 @@
 
 	if (root) {
 		sb->s_root = NULL;
-		inotify_super_block_umount(sb);
+		fsnotify_sb_umount(sb);
 		shrink_dcache_parent(root);
 		shrink_dcache_anon(&sb->s_anon);
 		dput(root);
diff -u linux/include/linux/inotify.h linux/include/linux/inotify.h
--- linux/include/linux/inotify.h	2005-01-18 16:11:12.000000000 -0500
+++ linux/include/linux/inotify.h	2005-01-31 17:22:43.129740568 -0500
@@ -84,23 +84,6 @@
 extern void inotify_super_block_umount(struct super_block *);
 extern void inotify_inode_is_dead(struct inode *);
 extern __u32 inotify_get_cookie(void);
-extern __u32 setattr_mask_inotify(unsigned int);
-
-/* this could be kstrdup if only we could add that to lib/string.c */
-static inline char * inotify_oldname_init(struct dentry *old_dentry)
-{
-	char *old_name;
-
-	old_name = kmalloc(strlen(old_dentry->d_name.name) + 1, GFP_KERNEL);
-	if (old_name)
-		strcpy(old_name, old_dentry->d_name.name);
-	return old_name;
-}
-
-static inline void inotify_oldname_free(const char *old_name)
-{
-	kfree(old_name);
-}
 
 #else
 
@@ -124,25 +107,11 @@
 {
 }
 
-static inline char * inotify_oldname_init(struct dentry *old_dentry)
-{
-	return NULL;
-}
-
 static inline __u32 inotify_get_cookie(void)
 {
 	return 0;
 }
 
-static inline void inotify_oldname_free(const char *old_name)
-{
-}
-
-static inline int setattr_mask_inotify(unsigned int ia_mask)
-{
-	return 0;
-}
-
 #endif	/* CONFIG_INOTIFY */
 
 #endif	/* __KERNEL __ */
only in patch2:
unchanged:
--- linux-2.6.10/fs/compat.c	2004-12-24 16:34:44.000000000 -0500
+++ linux/fs/compat.c	2005-01-31 17:08:03.561455272 -0500
@@ -1192,9 +1192,15 @@
 out:
 	if (iov != iovstack)
 		kfree(iov);
-	if ((ret + (type == READ)) > 0)
-		dnotify_parent(file->f_dentry,
-				(type == READ) ? DN_ACCESS : DN_MODIFY);
+	if ((ret + (type == READ)) > 0) {
+		struct dentry *dentry = file->f_dentry;
+		if (type == READ)
+			fsnotify_access(dentry, dentry->d_inode,
+					dentry->d_name.name);
+		else
+			fsnotify_modify(dentry, dentry->d_inode,
+					dentry->d_name.name);
+	}
 	return ret;
 }
 
only in patch2:
unchanged:
--- linux-2.6.10/include/linux/fsnotify.h	1969-12-31 19:00:00.000000000 -0500
+++ linux/include/linux/fsnotify.h	2005-01-31 17:24:54.486771264 -0500
@@ -0,0 +1,225 @@
+#ifndef _LINUX_FS_NOTIFY_H
+#define _LINUX_FS_NOTIFY_H
+
+/*
+ * include/linux/fs_notify.h - generic hooks for filesystem notification, to
+ * reduce in-source duplication from both dnotify and inotify.
+ *
+ * We don't compile any of this away in some complicated menagerie of ifdefs.
+ * Instead, we rely on the code inside to optimize away as needed.
+ *
+ * (C) Copyright 2005 Robert Love
+ */
+
+#ifdef __KERNEL__
+
+#include <linux/dnotify.h>
+#include <linux/inotify.h>
+
+/*
+ * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir
+ */
+static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
+				 const char *old_name, const char *new_name)
+{
+	u32 cookie;
+
+	if (old_dir == new_dir)
+		inode_dir_notify(old_dir, DN_RENAME);
+	else {
+		inode_dir_notify(old_dir, DN_DELETE);
+		inode_dir_notify(new_dir, DN_CREATE);
+	}
+
+	cookie = inotify_get_cookie();
+
+	inotify_inode_queue_event(old_dir, IN_MOVED_FROM, cookie, old_name);
+	inotify_inode_queue_event(new_dir, IN_MOVED_TO, cookie, new_name);
+}
+
+/*
+ * fsnotify_unlink - file was unlinked
+ */
+static inline void fsnotify_unlink(struct inode *inode, struct inode *dir,
+				   struct dentry *dentry)
+{
+	inode_dir_notify(dir, DN_DELETE);
+	inotify_inode_queue_event(dir, IN_DELETE_FILE, 0, dentry->d_name.name);
+	inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL);
+
+	inotify_inode_is_dead(inode);
+	d_delete(dentry);
+}
+
+/*
+ * fsnotify_rmdir - directory was removed
+ */
+static inline void fsnotify_rmdir(struct dentry *dentry, struct inode *inode,
+				  struct inode *dir)
+{
+	inode_dir_notify(dir, DN_DELETE);
+	inotify_inode_queue_event(dir, IN_DELETE_SUBDIR,0,dentry->d_name.name);
+	inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL);
+
+	inotify_inode_is_dead(inode);
+	d_delete(dentry);
+}
+
+/*
+ * fsnotify_create - filename was linked in
+ */
+static inline void fsnotify_create(struct inode *inode, const char *filename)
+{
+	inode_dir_notify(inode, DN_CREATE);
+	inotify_inode_queue_event(inode, IN_CREATE_FILE, 0, filename);
+}
+
+/*
+ * fsnotify_mkdir - directory 'name' was created
+ */
+static inline void fsnotify_mkdir(struct inode *inode, const char *name)
+{
+	inode_dir_notify(inode, DN_CREATE);
+	inotify_inode_queue_event(inode, IN_CREATE_SUBDIR, 0, name);
+}
+
+/*
+ * fsnotify_access - file was read
+ */
+static inline void fsnotify_access(struct dentry *dentry, struct inode *inode,
+				   const char *filename)
+{
+	dnotify_parent(dentry, DN_ACCESS);
+	inotify_dentry_parent_queue_event(dentry, IN_ACCESS, 0,
+					  dentry->d_name.name);
+	inotify_inode_queue_event(inode, IN_ACCESS, 0, NULL);
+}
+
+/*
+ * fsnotify_modify - file was modified
+ */
+static inline void fsnotify_modify(struct dentry *dentry, struct inode *inode,
+				   const char *filename)
+{
+	dnotify_parent(dentry, DN_MODIFY);
+	inotify_dentry_parent_queue_event(dentry, IN_MODIFY, 0, filename);
+	inotify_inode_queue_event(inode, IN_MODIFY, 0, NULL);
+}
+
+/*
+ * fsnotify_open - file was opened
+ */
+static inline void fsnotify_open(struct dentry *dentry, struct inode *inode,
+				 const char *filename)
+{
+	inotify_inode_queue_event(inode, IN_OPEN, 0, NULL);
+	inotify_dentry_parent_queue_event(dentry, IN_OPEN, 0, filename);
+}
+
+/*
+ * fsnotify_close - file was closed
+ */
+static inline void fsnotify_close(struct dentry *dentry, struct inode *inode,
+				  mode_t mode, const char *filename)
+{
+	u32 mask;
+
+	mask = (mode & FMODE_WRITE) ? IN_CLOSE_WRITE : IN_CLOSE_NOWRITE;
+	inotify_dentry_parent_queue_event(dentry, mask, 0, filename);
+	inotify_inode_queue_event(inode, mask, 0, NULL);
+}
+
+/*
+ * fsnotify_change - notify_change event.  file was modified and/or metadata
+ * was changed.
+ */
+static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
+{
+	int dn_mask = 0;
+	u32 in_mask = 0;
+
+        if (ia_valid & ATTR_UID) {
+                in_mask |= IN_ATTRIB;
+		dn_mask |= DN_ATTRIB;
+	}
+        if (ia_valid & ATTR_GID) {
+                in_mask |= IN_ATTRIB;
+		dn_mask |= DN_ATTRIB;
+	}
+        if (ia_valid & ATTR_SIZE) {
+                in_mask |= IN_MODIFY;
+		dn_mask |= DN_MODIFY;
+	}
+        /* both times implies a utime(s) call */
+        if ((ia_valid & (ATTR_ATIME|ATTR_MTIME)) == (ATTR_ATIME|ATTR_MTIME)) {
+                in_mask |= IN_ATTRIB;
+		dn_mask |= DN_ATTRIB;
+	}
+        else if (ia_valid & ATTR_ATIME) {
+                in_mask |= IN_ACCESS;
+		dn_mask |= DN_ACCESS;
+	}
+        else if (ia_valid & ATTR_MTIME) {
+                in_mask |= IN_MODIFY;
+		dn_mask |= DN_MODIFY;
+	}
+        if (ia_valid & ATTR_MODE) {
+                in_mask |= IN_ATTRIB;
+		dn_mask |= DN_ATTRIB;
+	}
+
+	if (dn_mask)
+		dnotify_parent(dentry, dn_mask);
+	if (in_mask) {
+		inotify_inode_queue_event(dentry->d_inode, in_mask, 0, NULL);
+		inotify_dentry_parent_queue_event(dentry, in_mask, 0,
+						  dentry->d_name.name);
+	}
+}
+
+/*
+ * fsnotify_sb_umount - filesystem unmount
+ */
+static inline void fsnotify_sb_umount(struct super_block *sb)
+{
+	inotify_super_block_umount(sb);
+}
+
+/*
+ * fsnotify_flush - flush time!
+ */
+static inline void fsnotify_flush(struct file *filp, fl_owner_t id)
+{
+	dnotify_flush(filp, id);
+}
+
+#ifdef CONFIG_INOTIFY	/* inotify helpers */
+
+/*
+ * fsnotify_oldname_init - save off the old filename before we change it
+ *
+ * this could be kstrdup if only we could add that to lib/string.c
+ */
+static inline char * fsnotify_oldname_init(struct dentry *old_dentry)
+{
+	char *old_name;
+
+	old_name = kmalloc(strlen(old_dentry->d_name.name) + 1, GFP_KERNEL);
+	if (old_name)
+		strcpy(old_name, old_dentry->d_name.name);
+	return old_name;
+}
+
+/*
+ * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init
+ */
+static inline void fsnotify_oldname_free(const char *old_name)
+{
+	kfree(old_name);
+}
+
+#endif	/* CONFIG_INOTIFY */
+
+#endif	/* __KERNEL__ */
+
+#endif	/* _LINUX_FS_NOTIFY_H */



  reply	other threads:[~2005-01-31 22:49 UTC|newest]

Thread overview: 152+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-18  7:21 [PATCH] Some fixes for compat ioctl Andi Kleen
2005-01-18 10:34 ` Michael S. Tsirkin
2005-01-18 10:45   ` [PATCH 1/5] compat_ioctl call seems to miss a security hook Michael S. Tsirkin
2005-01-18 19:22     ` Chris Wright
2005-01-20  0:28       ` Michael S. Tsirkin
2005-01-20  0:43         ` Chris Wright
2005-01-20  1:06           ` Michael S. Tsirkin
2005-01-20  1:16             ` Chris Wright
2005-01-20  1:42               ` Michael S. Tsirkin
2005-01-18 10:48 ` [PATCH 2/5] socket ioctl fix (from Andi) Michael S. Tsirkin
2005-01-18 10:55   ` Christoph Hellwig
2005-01-18 11:01     ` Andi Kleen
2005-01-18 10:52 ` [PATCH 3/5] make common ioctls apply for compat Michael S. Tsirkin
2005-01-18 10:57 ` [PATCH 4/5] reminder comment about register_ioctl32_conversion Michael S. Tsirkin
2005-01-18 11:04 ` [PATCH 5/5] symmetry between compat_ioctl and unlocked_ioctl Michael S. Tsirkin
2005-01-24 10:15   ` 2.6.11-rc2-mm1 Andrew Morton
2005-01-24 10:36     ` 2.6.11-rc2-mm1 Adrian Bunk
2005-01-24 11:17     ` 2.6.11-rc2-mm1: v4l-saa7134-module compile error Adrian Bunk
2005-01-24 13:57       ` Gerd Knorr
2005-01-24 17:45         ` Adrian Bunk
2005-01-25 10:15           ` Gerd Knorr
2005-01-25 10:38             ` Adrian Bunk
2005-01-24 11:56     ` 2.6.11-rc2-mm1 Brice Goglin
2005-01-24 13:41       ` 2.6.11-rc2-mm1 Brice Goglin
2005-01-24 14:35         ` 2.6.11-rc2-mm1 Florian Bohrer
2005-01-24 18:52       ` 2.6.11-rc2-mm1 Dave Jones
2005-01-24 20:44         ` 2.6.11-rc2-mm1 Dave Jones
2005-01-24 21:31           ` 2.6.11-rc2-mm1 Brice Goglin
2005-01-25 19:38             ` 2.6.11-rc2-mm1 Dave Jones
2005-01-25 19:58               ` 2.6.11-rc2-mm1 Brice Goglin
2005-01-25 20:29                 ` 2.6.11-rc2-mm1 Dave Jones
2005-01-24 12:12     ` 2.6.11-rc2-mm1 Christoph Hellwig
2005-01-24 20:36       ` 2.6.11-rc2-mm1 Karsten Keil
2005-01-24 23:26         ` 2.6.11-rc2-mm1 Christoph Hellwig
2005-01-25  0:35           ` 2.6.11-rc2-mm1 Karsten Keil
2005-01-24 23:32         ` 2.6.11-rc2-mm1 Bartlomiej Zolnierkiewicz
2005-01-24 21:03       ` 2.6.11-rc2-mm1 Andrew Morton
2005-01-24 12:17     ` 2.6.11-rc2-mm1 Christoph Hellwig
2005-01-31 22:42       ` Robert Love [this message]
2005-02-07 11:57       ` 2.6.11-rc2-mm1 Ingo Molnar
2005-02-07 17:30         ` 2.6.11-rc2-mm1 Robert Love
2005-02-07 21:02           ` 2.6.11-rc2-mm1 John McCutchan
2005-01-24 12:25     ` [-mm patch] fix SuperIO compilation Adrian Bunk
2005-01-24 12:34       ` Christoph Hellwig
2005-01-24 13:04         ` Evgeniy Polyakov
2005-01-24 13:56           ` Evgeniy Polyakov
2005-01-24 14:14             ` [1/1] superio: remove unneded exports and make some functions static Evgeniy Polyakov
2005-01-25  6:19               ` Greg KH
2005-01-24 12:48     ` 2.6.11-rc2-mm1: DVB compile error Adrian Bunk
2005-01-24 23:56       ` [linux-dvb-maintainer] " Johannes Stezenbach
2005-01-24 13:52     ` 2.6.11-rc2-mm1 Roman Zippel
2005-01-24 14:24     ` 2.6.11-rc2-mm1 Christoph Hellwig
2005-01-24 14:58     ` 2.6.11-rc2-mm1 Benoit Boissinot
2005-01-24 15:11     ` 2.6.11-rc2-mm1 [compile fix] Benoit Boissinot
2005-01-24 17:25       ` Adrian Bunk
2005-01-24 17:54     ` 2.6.11-rc2-mm1: SuperIO scx200 breakage Adrian Bunk
2005-01-24 18:43       ` Evgeniy Polyakov
2005-01-24 18:29         ` Adrian Bunk
2005-01-24 19:19           ` Evgeniy Polyakov
2005-01-24 19:03             ` Adrian Bunk
2005-01-24 19:46               ` Evgeniy Polyakov
2005-01-24 18:41         ` Jurriaan
2005-01-24 19:23           ` Evgeniy Polyakov
2005-01-24 19:05             ` Adrian Bunk
2005-01-24 19:39               ` Evgeniy Polyakov
2005-01-24 19:32                 ` Dmitry Torokhov
2005-01-24 20:28                   ` Evgeniy Polyakov
2005-01-27 15:19         ` Bill Davidsen
2005-01-27 16:21           ` Evgeniy Polyakov
2005-01-27 23:12             ` Bill Davidsen
2005-01-24 20:33       ` Christoph Hellwig
2005-01-24 21:10         ` Evgeniy Polyakov
2005-01-24 21:34       ` Greg KH
2005-01-24 21:47         ` Christoph Hellwig
2005-01-25  6:02           ` Greg KH
2005-01-25  7:11             ` Christoph Hellwig
2005-01-25 18:59             ` Jean Delvare
2005-01-25 21:39               ` Evgeniy Polyakov
2005-01-25 21:40                 ` Jean Delvare
2005-01-25 22:35                   ` Evgeniy Polyakov
2005-01-26  9:55                     ` Jean Delvare
2005-01-26 10:55                       ` Evgeniy Polyakov
2005-01-26 14:34                         ` Jean Delvare
2005-01-26 16:10                           ` Evgeniy Polyakov
2005-01-26 19:20                             ` Jean Delvare
2005-01-26 20:21                               ` Evgeniy Polyakov
2005-01-26 10:14                     ` Christoph Hellwig
2005-01-26 10:59                       ` Evgeniy Polyakov
2005-01-26 14:00                         ` Dmitry Torokhov
2005-01-26 16:38                           ` Evgeniy Polyakov
2005-01-26 18:19                             ` Adrian Bunk
2005-01-26 19:27                               ` Evgeniy Polyakov
2005-01-27 10:20                                 ` Adrian Bunk
2005-01-27 11:53                                   ` Evgeniy Polyakov
2005-01-26 18:06                         ` Adrian Bunk
2005-01-26 13:12                       ` Russell King
2005-01-26 20:01                         ` Christoph Hellwig
2005-01-24 18:58     ` 2.6.11-rc2-mm1 Benoit Boissinot
2005-01-24 19:09       ` 2.6.11-rc2-mm1 Adrian Bunk
2005-01-24 19:44     ` 2.6.11-rc2-mm1 - fix a typo in nfs3proc.c Benoit Boissinot
2005-01-24 20:24     ` 2.6.11-rc2-mm1 - compile fix Benoit Boissinot
2005-01-24 20:26     ` [PATCH] move common compat ioctls to hash Michael S. Tsirkin
2005-01-25  6:17       ` Andi Kleen
2005-01-26  8:40         ` Michael S. Tsirkin
2005-01-25  0:03     ` 2.6.11-rc2-mm1: fuse patch needs new libs Sytse Wielinga
2005-01-25  7:31       ` Miklos Szeredi
2005-01-27 15:45       ` Bill Davidsen
2005-01-27 15:56         ` Sytse Wielinga
2005-01-27 16:11           ` Miklos Szeredi
2005-01-27 18:09       ` Christoph Hellwig
2005-01-25  1:01     ` 2.6.11-rc2-mm1 Brice Goglin
2005-01-25  1:30       ` 2.6.11-rc2-mm1 (AE_AML_NO_OPERAND) Len Brown
2005-01-25 18:41       ` 2.6.11-rc2-mm1 Pavel Machek
2005-01-25 19:10         ` 2.6.11-rc2-mm1 Espen Fjellvær Olsen
2005-01-25 12:53     ` 2.6.11-rc2-mm1 Christoph Hellwig
2005-01-25 14:11       ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-25 14:23         ` 2.6.11-rc2-mm1 Christoph Hellwig
2005-01-25 15:24           ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-25 15:34             ` 2.6.11-rc2-mm1 Bartlomiej Zolnierkiewicz
2005-01-25 16:04               ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-25 18:21                 ` 2.6.11-rc2-mm1 Jörn Engel
2005-01-25 21:17                   ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26  2:20                     ` 2.6.11-rc2-mm1 Jörn Engel
2005-01-25 15:36             ` 2.6.11-rc2-mm1 Paulo Marques
2005-01-25 21:08               ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-25 16:11             ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-25 21:14               ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26  4:57                 ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-26  8:25                   ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26 13:46                     ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-26 14:59                       ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26 15:26                         ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-26 15:54                           ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26 16:25                             ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-26 16:46                               ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26 16:55                                 ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-26 17:39                                   ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26 18:26                                     ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-26 20:07                                       ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26 20:22                                         ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-27 17:33                                           ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-25 22:42             ` 2.6.11-rc2-mm1 Christoph Hellwig
2005-01-26  8:31               ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-26 13:32                 ` 2.6.11-rc2-mm1 Dmitry Torokhov
2005-01-26 14:44                   ` 2.6.11-rc2-mm1 Evgeniy Polyakov
2005-01-25 19:35       ` 2.6.11-rc2-mm1 Pavel Machek
2005-01-25 19:12     ` 2.6.11-rc2-mm1 Marcos D. Marado Torres
2005-01-25 23:07       ` 2.6.11-rc2-mm1 Barry K. Nathan
2005-01-26  2:40     ` 2.6.11-rc2-mm1 William Lee Irwin III
2005-01-26  4:44     ` [PATCH] ppc64: fix use kref for device_node refcounting Nathan Lynch
2005-01-27  6:18     ` 2.6.11-rc2-mm1 William Lee Irwin III
2005-01-27  9:14       ` 2.6.11-rc2-mm1 William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1107211358.4019.36.camel@betsy.boston.ximian.com \
    --to=rml@novell.com \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®