summaryrefslogtreecommitdiffstats
path: root/dump_manager.cpp
diff options
context:
space:
mode:
authorJayanth Othayoth <ojayanth@in.ibm.com>2017-07-12 19:14:02 -0500
committerJayanth Othayoth <ojayanth@in.ibm.com>2017-07-26 03:49:52 -0500
commit764d1b2255b4f66ba9bf80024ff425fe983d3528 (patch)
tree8a281cca00fb853cee8c0c6f4b6f7009a9e3442d /dump_manager.cpp
parent2dccfe43411868444783d2def5d7f80a1d964b4c (diff)
downloadphosphor-debug-collector-764d1b2255b4f66ba9bf80024ff425fe983d3528.tar.gz
phosphor-debug-collector-764d1b2255b4f66ba9bf80024ff425fe983d3528.zip
Enable user initiated dump child directory level file watch
Change-Id: I38b1f0a06e96a465526ea1ac497e49dc5f778dd8 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Diffstat (limited to 'dump_manager.cpp')
-rw-r--r--dump_manager.cpp28
1 files changed, 27 insertions, 1 deletions
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 @@ void Manager::watchCallback(const UserMap& fileInfo)
{
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
OpenPOWER on IntegriCloud