[RFC] inotify implementation

David Zeuthen david at fubar.dk
Wed Jan 31 14:56:54 PST 2007


Hi,

Sorry for the lag; been traveling!

On Tue, 2007-01-16 at 13:01 +0300, Sergey Lapin wrote:
> Hi,
> As I understand inotify API first appeared in glibc-2.4.
> As it is well known, many ARM machines still use glibc-2.3.5
> (probably for good reason), so have no such implementation.
> 
> So, in this situation I'm just scratching my head about
> how to implement check for inotify existence.
> 
> 1. Just stupidly check for existence of header sys/inotify.h
> and functions in library, use hese in case if it exists,
> perform runtime check with inotify_init(), and use it on
> success, otherwise on failure.
> 
> 2. As with 1. alongside with adding configure option for
> kernel headers and check there in case there's no API
> in libc, create own header with direct API calls like these:
> 
> static inline int inotify_init (void)
> {
>          return syscall (__NR_inotify_init);
> }
> 
> static inline int inotify_add_watch (int fd, const char *name, __u32 mask)
> {
>          return syscall (__NR_inotify_add_watch, fd, name, mask);
> }
> 
> static inline int inotify_rm_watch (int fd, __u32 wd)
> {
>          return syscall (__NR_inotify_rm_watch, fd, wd);
> }
> 
> (taken from inotail Debian package).
> 
> or #define them (same effect but less type checking).
> 
> 3. As with 2 but never use libc's headers, just use kernel
> headers or inotail's approach (#define __NR_... ourselves).
> 

I'd probably go for 2.

> Also, should we fall back to dnotyfy in case intoify is
> not found?

On Linux, we already require kernel revisions where inotify is
guaranteed to be available. Have you looked at what D-Bus is doing; it
might be worth lifting / porting that code / abstraction since it works
on FreeBSD and Solaris too IIRC. Thanks.

       David




More information about the hal mailing list