| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include <sys/inotify.h> /* IWYU pragma: export */ |
| 5 |
#include <syslog.h> |
| 6 |
|
| 7 |
#include "basic-forward.h" |
| 8 |
|
| 9 |
#define INOTIFY_EVENT_MAX (offsetof(struct inotify_event, name) + NAME_MAX + 1) |
| 10 |
|
| 11 |
/* This evaluates arguments multiple times */ |
| 12 |
#define FOREACH_INOTIFY_EVENT_FULL(e, buffer, sz, log_level) \ |
| 13 |
for (struct inotify_event *e = NULL; \ |
| 14 |
inotify_event_next(&buffer, sz, &e, log_level); ) |
| 15 |
|
| 16 |
#define FOREACH_INOTIFY_EVENT(e, buffer, sz) \ |
| 17 |
FOREACH_INOTIFY_EVENT_FULL(e, buffer, sz, LOG_DEBUG) |
| 18 |
|
| 19 |
#define FOREACH_INOTIFY_EVENT_WARN(e, buffer, sz) \ |
| 20 |
FOREACH_INOTIFY_EVENT_FULL(e, buffer, sz, LOG_WARNING) |
| 21 |
|
| 22 |
union inotify_event_buffer { |
| 23 |
struct inotify_event ev; |
| 24 |
uint8_t raw[INOTIFY_EVENT_MAX]; |
| 25 |
}; |
| 26 |
|
| 27 |
bool inotify_event_next( |
| 28 |
union inotify_event_buffer *buffer, |
| 29 |
size_t size, |
| 30 |
struct inotify_event **iterator, |
| 31 |
int log_level); |
| 32 |
|
| 33 |
int inotify_add_watch_fd(int fd, int what, uint32_t mask); |
| 34 |
int inotify_add_watch_and_warn(int fd, const char *pathname, uint32_t mask); |