Skip to content

Commit

Permalink
sd-network: add support for only listening to some types of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
teg committed Apr 29, 2014
1 parent ba9f11d commit 7e141e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/network/sd-network.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/systemd/sd-network.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 7e141e4

Please sign in to comment.