Re: [RFC][PATCH] inotify 0.10.0

Ray Lee
2004-10-04T20:58:42Z

On Thu, 2004-09-30 at 21:09 -0700, Paul Jackson wrote:
> If file "foo" goes away, and if the kernel only reports that inode
> 314159 was unlinked from a given directory, unless some user code
> previously remembered that inode 314159 was accessible from the
> directory entry named "foo", you can't tell the user that "foo"
> disappeared.

Right. Follow the same argument for renames, as well. ("Well, what did
it *used* be to named?") Short of caching the entire contents, there's
no way to know if all that's returned is an inode.

> Do you have the same problem with directories, if some cookie, not the
> full pathname, is passed back after an 'rmdir(2)' event? Or is it just
> that it's less onerous to track all the directories, because there's
> fewer of them?

In the case of a directory that's being monitored going away, userspace
has already asked for tracking events for that directory explicitly, and
has to keep track of the cookie ("watch descriptor") to directory name
mapping (or some context, at least) already. That's the only way it
knows the correct context for the events.

For example, I ask for monitoring of two different directories on my
system, both with a final path component of "etc". Since the kernel
can't pass back the full path (cf. mount --bind, or consider an
watch/chdir/watch sequence, if you believe the kernel should cache the
full path passed to it from userspace), it instead needs to pass back
something unique for that directory. The name isn't, and the full
pathname isn't available to the kernel. So, the watch descriptor, being
an arbitrary but unique cookie, steps in.

> > You're saying pass the inode number, as it's smaller and makes for an
> > easier and higher speed interface to get changes to userspace (if I
> > understand you correctly).
>
> That was the idea, yes. Most of it anyway. That and striving to keep
> the API the kernel presents to the user minimal and orthogonal.

<Nod> That's actually a stronger argument with me than the micro-
optimization. Orthogonal interfaces allow for more uses. However, I can
find no way to clean up the interface any more than what's been
suggested so far.

> If there is a way, any way, for user code to get something from the
> kernel, then I don't mind dragging my feet on providing other ways,
> until I see a good reason.

Fair enough.

> It's always worth a bit of effort to keep
> kernel API's minimal and orthogonal.

Agreed.

> Your "delete and rename" point above seems now like a good reason.

It would bring inotify almost down to the level of usefulness of
dnotify, which would be painful.

Ray