sync_watch: Handle IN_IGNORED

When the hostname is updated via systemd, it modifies the /etc/hostname
file in a way that triggers a IN_CLOSE_NOWRITE and IN_IGNORED signal.

 * When IN_IGNORED is received, re-subscribe the file, since it means
   that the inotify watch was removed.

 * A subsequent IN_CLOSE_WRITE signal is received after the re-subscribe
   which takes care of syncing the hostname file.

Tested: The hostname was synced when changed multiple times in a row
using the REST API.

Change-Id: I30abfcdc8b33f77adc6349d345cc957b07898018
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/sync_watch.hpp b/sync_watch.hpp
index 30ea5f7..3ad5afd 100644
--- a/sync_watch.hpp
+++ b/sync_watch.hpp
@@ -54,6 +54,12 @@
     static int callback(sd_event_source* s, int fd, uint32_t revents,
                         void* userdata);
 
+    /** @brief Adds an inotify watch to the specified file or directory path
+     *
+     *  @param[in] path - The path to the file or directory
+     */
+    void addInotifyWatch(const fs::path& path);
+
     /** @brief Map of file descriptors, watch descriptors, and file paths */
     using fd = int;
     using wd = int;
@@ -61,6 +67,9 @@
 
     /** @brief The callback function for processing the inotify event */
     std::function<int(int, fs::path&)> syncCallback;
+
+    /** @brief Persistent sd_event loop */
+    sd_event& loop;
 };
 
 } // namespace manager