iv_inotify(3)

NAME
iv_inotify - an ivykis component for Linux inotify(7)

SYNOPSIS
#include <iv.h>
#include <iv_inotify.h>

int iv_inotify_init(struct iv_inotify *inotify);
void iv_inotify_destroy(struct iv_inotify *inotify);
int iv_inotify_add_watch(struct iv_inotify *inotify,
                         struct iv_inotify_watch *watch);
int iv_inotify_rm_watch(struct iv_inotify *inotify,
                        struct iv_inotify_watch *watch);

DESCRIPTION
The iv_inotify_init() function creates and initializes an iv_inotify instance. The inotify parameter is a pointer to an iv_inotify structure which will describe the instance once the function returns.

The iv_inotify_destroy() function destroys an iv_inotify instance. The inotify parameter is a pointer to the iv_inotify structure describing the instance to be destroyed.

The iv_inotify_add_watch() function adds a watch to an iv_inotify instance. The inotify parameter is a pointer to this instance, and the watch parameter is the iv_inotify_watch to add to this instance.

The iv_inotify_rm_watch() function removes a watch from an iv_inotify instance. The inotify parameter is a pointer to this instance, and the watch parameter is the iv_inotify_watch to remove from this instance.

A special iv_inotify NULL instance can be used which is created and destroyed transparantly, so that calls to iv_inotify_init() and iv_inotify_destroy() can be omitted when only one iv_inotify instance is needed. The iv_inotify_watch structure used in these functions is as follows:
struct iv_inotify_watch {
    const char       *pathname;
    uint32_t         mask;
    void             (*handler)(struct inotify_event *, void *);
    void             *cookie;
};
pathname and mask correspond to the members of struct inotify_watch as described in inotify(7). handler is the event handler called when this watch would trigger. The arguments to this handler function are an inotify_event structure as described in inotify(7) and the pointer stored in the cookie member of the iv_inotify_watch structure.

RETURN VALUE
iv_inotify_init(), iv_inotify_add_watch(), and iv_inotify_rm_watch() return zero on success. On error, -1 is returned, and errno is set appropriately.

ERRORS
iv_inotify will yield the errors generated by inotify_init(3), inotify_add_watch(3), and inotify_rm_watch(3). Additionally, when the NULL instance is used, iv_inotify will yield EINVAL when iv_inotify_rm_watch is called when the NULL instance has not yet been initialized (this happens when there are no watches associated with the NULL instance).

SEE ALSO
ivykis(3) inotify(7) inotify_init(3) inotify_add_watch(3) inotify_rm_watch(3)