chiark / gitweb /
sd-network: add support for only listening to some types of changes
authorTom Gundersen <teg@jklm.no>
Tue, 29 Apr 2014 20:27:29 +0000 (22:27 +0200)
committerTom Gundersen <teg@jklm.no>
Tue, 29 Apr 2014 22:05:28 +0000 (00:05 +0200)
src/network/sd-network.c
src/systemd/sd-network.h

index 3b541a2764e85db2b9c5f349cf42865cfbb3743f..1dfb282a0a3e6dfa24e521581c638eaf7dd9dabe 100644 (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;
index 71a83ec526b41a6e1a0e631e7dfd4c93fa7fa987..9562b78feba12a732680ab1384f198caed56416c 100644 (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. */