Re: [RFC][PATCH] inotify 0.10.0

Andrew Morton
2004-09-30T01:25:37Z

John McCutchan <ttb@tentacle.dhs.org> wrote:
>
> > ~ ~
> >
> > As Chris points out, we still need a way to pass the name or path back
> > to userspace when an event occurs, which is the interface I was harping
> > on a few messages back.
> >
> > It seems we're trying to recreate a variant struct dirent for
> > communicating changes to userspace. Perhaps we can learn something from
> > already trodden ground? Just sayin'.
>
> Yes the current method of passing the name back to user space is
> definitely sub par. But I don't think passing a full path to user space
> is reasonable, as that would require walking the dirent tree for every
> event. Really the best we can provide user space is the filename/dirname
> (relative to the directory you are currently watching).

Userspace requests that the kernel start monitoring an fd. The kernel
returns an integer cookie which corresponds to that monitor.

When an event occurs, the kernel returns the event identifier and the
cookie to userspace.

Userspace then does a lookup to work out what pathname corresponds to the
cookie.

Or is it the case that you expect a single monitor on /etc will return
"/etc/passwd" if someone modified that file, or "/etc/hosts" if someone
modified that file? If so, perhaps we should take that feature away and
require that userspace rescan the directory?

Because passing pathnames into and back from the kernel from this manner is
really not a nice design.

A halfway point might be to return {cookie-of-/etc,EVENT_MODIFY,"hosts"} to
a monitor on the /etc directory.