Re: [RFC][PATCH] inotify 0.10.0

Robert Love
2004-09-27T20:11:29Z

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

On Sun, 2004-09-26 at 22:02 -0400, John McCutchan wrote:

> Announcing the release of inotify 0.10.0.
> Attached is a patch to 2.6.8.1.

John,

find_inode() can just return an inode directly, so we don't need the
second argument and the double indirection.

FYI, errors can be encoded in pointers via ERR_PTR(), checked via IS_ERR
(), and retrieved via PTR_ERR().

Patch is on top of your patch and all of my previous patches.

Robert Love

[-- Attachment #2: inotify-rml-redo-fix_inode-1.patch --]
[-- Type: text/x-patch, Size: 1561 bytes --]

fix_inode() bits

Signed-Off-By: Robert Love <rml@novell.com>

drivers/char/inotify.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)

diff -urN linux-inotify/drivers/char/inotify.c linux/drivers/char/inotify.c
--- linux-inotify/drivers/char/inotify.c 2004-09-27 16:04:21.899344440 -0400
+++ linux/drivers/char/inotify.c 2004-09-27 16:03:20.388695480 -0400
@@ -98,24 +98,29 @@
};
#define list_to_inotify_kernel_event(pos) list_entry((pos), struct inotify_kernel_event, list)

-static int find_inode(const char __user *dirname, struct inode **inode)
+/*
+ * find_inode - resolve a user-given path to a specific inode and iget() it
+ */
+static struct inode * find_inode(const char __user *dirname)
{
+ struct inode *inode;
struct nameidata nd;
int error;

error = __user_walk(dirname, LOOKUP_FOLLOW, &nd);
if (error) {
iprintk(INOTIFY_DEBUG_INODE, "could not find inode\n");
+ inode = ERR_PTR(error);
goto out;
}

- *inode = nd.dentry->d_inode;
- __iget(*inode);
+ inode = nd.dentry->d_inode;
+ __iget(inode);
iprintk(INOTIFY_DEBUG_INODE, "ref'd inode\n");
inode_ref_count++;
path_release(&nd);
out:
- return error;
+ return inode;
}

static void unref_inode(struct inode *inode)
@@ -841,9 +846,11 @@
struct inotify_watcher *watcher;
err = 0;

- err = find_inode(request->dirname, &inode);
- if (err)
+ inode = find_inode(request->dirname);
+ if (IS_ERR(inode)) {
+ err = PTR_ERR(inode);
goto exit;
+ }

if (!S_ISDIR(inode->i_mode))
iprintk(INOTIFY_DEBUG_ERRORS, "watching file\n");