Enable user initiated dump child directory level file watch
Change-Id: I38b1f0a06e96a465526ea1ac497e49dc5f778dd8
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/dump_manager.cpp b/dump_manager.cpp
index 3b00119..3d8bdc2 100644
--- a/dump_manager.cpp
+++ b/dump_manager.cpp
@@ -117,13 +117,39 @@
{
for (const auto& i : fileInfo)
{
- // For any new dump file create dump entry object.
+ // For any new dump file create dump entry object
+ // and associated inotify watch.
if (IN_CLOSE_WRITE == i.second)
{
+ removeWatch(i.first);
+
createEntry(i.first);
}
+ // Start inotify watch on newly created directory.
+ else if ((IN_CREATE == i.second) && fs::is_directory(i.first))
+ {
+ auto watchObj = std::make_unique<Watch>(
+ eventLoop,
+ IN_NONBLOCK,
+ IN_CLOSE_WRITE,
+ EPOLLIN,
+ i.first,
+ std::bind(
+ std::mem_fn(
+ &phosphor::dump::Manager::watchCallback),
+ this, std::placeholders::_1));
+
+ childWatchMap.emplace(i.first, std::move(watchObj));
+ }
+
}
}
+void Manager::removeWatch(const fs::path& path)
+{
+ //Delete Watch entry from map.
+ childWatchMap.erase(path);
+}
+
} //namespace dump
} //namespace phosphor