1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 16:59:03 +03:00

sd-network: add support for only listening to some types of changes

This commit is contained in:
Tom Gundersen 2014-04-29 22:27:29 +02:00
parent ba9f11dc98
commit 7e141e498c
2 changed files with 12 additions and 2 deletions

View File

@ -166,7 +166,7 @@ _public_ int sd_network_monitor_new(const char *category, sd_network_monitor **m
if (fd < 0)
return -errno;
if (!category || streq(category, "netif")) {
if (!category || streq(category, "links")) {
k = inotify_add_watch(fd, "/run/systemd/network/links/", IN_MOVED_TO|IN_DELETE);
if (k < 0) {
safe_close(fd);
@ -176,6 +176,16 @@ _public_ int sd_network_monitor_new(const char *category, sd_network_monitor **m
good = true;
}
if (!category || streq(category, "leases")) {
k = inotify_add_watch(fd, "/run/systemd/network/leases/", IN_MOVED_TO|IN_DELETE);
if (k < 0) {
safe_close(fd);
return -errno;
}
good = true;
}
if (!good) {
close_nointr(fd);
return -EINVAL;

View File

@ -64,7 +64,7 @@ int sd_network_get_ifindices(unsigned **indices);
/* Monitor object */
typedef struct sd_network_monitor sd_network_monitor;
/* Create a new monitor. Category must be NULL. */
/* Create a new monitor. Category must be NULL, "links" or "leases". */
int sd_network_monitor_new(const char *category, sd_network_monitor** ret);
/* Destroys the passed monitor. Returns NULL. */