extend inotify to support file descriptors in addition to paths

From: Giuseppe Scrivano
Date: Tue Sep 08 2009 - 20:21:25 EST


Hello,

at the moment inotify permits to add new files to be watched using their
path. There are situations where the file path is not know but a
descriptor is available. It would be desiderable to have the
possibility to use the inotify system even in these (rare) cases.

A concrete example of application that can take advantage of this
possibility is GNU tail. GNU tail, since version 7.5, is using inotify
to watch changes on files. This command will make `tail' sleeps until
some events are catched:

tail -qf foo bar baz

Inotify can't be used when stdin is watched too:

tail -qf boo bar - < baz

While the user gets the same result, internally it is a completely
different thing because polling is done on stdin instead of graciously
sleep until something is ready.
I don't know if it is possible to obtain the former result when the fd
is know but the path isn't.


My proposal is to extend inotify adding a new syscall:

long sys_inotify_add_watch_fd(int wd, int fd, u32 mask);

in this way the same mechanism can be used indifferently either a
descriptor or on a path is provided.

What do you think about this idea? Is there another way to get the same
result?

Regards,
Giuseppe


P.S.
In the attached patch I changed the syscalls table only for x86.