---
name: "iv_inotify_watch_register"
section: "3"
platform: "linux"
package: "libivykis-dev"
version: "0.43.2-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/iv_inotify"
---

# iv\_inotify\_watch\_register(3)

ivykis inotify(7) wrapper

Part of [iv\_inotify(3)](/iv_inotify/3.md).

## NAME

IV\_INOTIFY\_INIT, iv\_inotify\_register, iv\_inotify\_unregister, IV\_INOTIFY\_WATCH\_INIT, iv\_inotify\_watch\_register, iv\_inotify\_watch\_unregister - ivykis [**inotify**(7)](/inotify/7.md) wrapper

## SYNOPSIS

```
#include <iv_inotify.h>

struct iv_inotify {
};
```

**void IV\_INOTIFY\_INIT(struct iv\_inotify \****inotify***);**\
 **int iv\_inotify\_register(struct iv\_inotify \****inotify***);**\
 **void iv\_inotify\_unregister(struct iv\_inotify \****inotify***);**\

```

struct iv_inotify_watch {
        struct iv_inotify       *inotify;
        const char              *pathname;
        uint32_t                mask;
        void                    *cookie;
        void                    (*handler)(void *, struct inotify_event *);
};
```

**void IV\_INOTIFY\_WATCH\_INIT(struct iv\_inotify\_watch \****watch***);**\
 **int iv\_inotify\_watch\_register(struct iv\_inotify\_watch \****watch***);**\
 **int iv\_inotify\_watch\_unregister(struct iv\_inotify\_watch \****watch***);**\

## DESCRIPTION

The **iv\_inotify\_register** function registers an **iv\_inotify** instance with the [**iv\_inotify**(3)](/iv_inotify/3.md) module.  The **inotify** parameter is a pointer to the **iv\_inotify** structure to be registered.

The **iv\_inotify\_unregister** function unregisters an **iv\_inotify** instance from the [**iv\_inotify**(3)](/iv_inotify/3.md) module.  The **inotify** parameter is a pointer to the **iv\_inotify** structure to be unregistered.

The **iv\_inotify\_watch\_register** function adds a watch to the registered **iv\_inotify** instance specified by the **-\>inotify** member.

The **iv\_inotify\_watch\_unregister** function removes a watch from the **iv\_inotify** instance specified by the **-\>inotify** member.

In the **iv\_inotify\_watch** structure used in these functions, the **-\>pathname** and **-\>mask** members correspond to the members of struct inotify\_watch as described in [**inotify**(7)](/inotify/7.md). **-\>handler** is the event handler called when this watch triggers.  The arguments to this handler function are the pointer stored in the **-\>cookie** member of the **iv\_inotify\_watch** structure and a pointer to an inotify\_event structure as described in [**inotify**(7)](/inotify/7.md).

## RETURN VALUE

**iv\_inotify\_register** and **iv\_inotify\_watch\_register** return zero on success.  On error, -1 is returned, and errno is set appropriately.

## ERRORS

iv\_inotify will return errors returned by **inotify\_init**(3) and **inotify\_add\_watch**(3).

## SEE ALSO

[**ivykis**(3)](/ivykis/3.md), [**inotify**(7)](/inotify/7.md), **inotify\_init**(3), **inotify\_add\_watch**(3), **inotify\_rm\_watch**(3)
