Call processImage from inotify
Change-Id: I0b748f93f8e34552cef67616317c28660284ac99
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 9de41b4..fbc8cbf 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,9 @@
noinst_HEADERS = \
version_software_manager.hpp \
download_manager.hpp \
- watch.hpp
+ watch.hpp \
+ version.hpp \
+ image_manager.hpp
sbin_PROGRAMS = \
phosphor-version-software-manager \
@@ -13,7 +15,9 @@
phosphor_version_software_manager_SOURCES = \
version_software_manager.cpp \
image_manager_main.cpp \
- watch.cpp
+ watch.cpp \
+ version.cpp \
+ image_manager.cpp
phosphor_download_manager_SOURCES = \
download_manager.cpp \
diff --git a/image_manager.cpp b/image_manager.cpp
new file mode 100644
index 0000000..25b08ba
--- /dev/null
+++ b/image_manager.cpp
@@ -0,0 +1,18 @@
+#include <string>
+#include "image_manager.hpp"
+
+namespace phosphor
+{
+namespace software
+{
+namespace manager
+{
+
+int processImage(const std::string& tarFilePath)
+{
+ return 0;
+}
+
+} // namespace manager
+} // namespace software
+} // namepsace phosphor
diff --git a/image_manager.hpp b/image_manager.hpp
new file mode 100644
index 0000000..e57599f
--- /dev/null
+++ b/image_manager.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+namespace phosphor
+{
+namespace software
+{
+namespace manager
+{
+
+/**
+ * @brief Verify and untar the tarball. Verify the manifest file.
+ * Create and populate the version and filepath interfaces.
+ *
+ * @param[in] tarballFilePath - Tarball path.
+ * @param[out] result - 0 if successful.
+ */
+int processImage(const std::string& tarballFilePath);
+
+} // namespace manager
+} // namespace software
+} // namespace phosphor
diff --git a/watch.cpp b/watch.cpp
index a690c57..ae1e419 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -7,6 +7,7 @@
#include <phosphor-logging/log.hpp>
#include "config.h"
#include "watch.hpp"
+#include "image_manager.hpp"
namespace phosphor
{
@@ -15,6 +16,7 @@
namespace manager
{
+using namespace phosphor::logging;
using namespace std::string_literals;
Watch::Watch(sd_event* loop)
@@ -86,11 +88,14 @@
auto event = reinterpret_cast<inotify_event*>(&buffer[offset]);
if ((event->mask & IN_CLOSE_WRITE) && !(event->mask & IN_ISDIR))
{
- // TODO: openbmc/openbmc#1352 - invoke method (which takes uploaded
- // filepath) to construct software version d-bus objects.
- // For now, log the image filename.
- using namespace phosphor::logging;
- log<level::INFO>(event->name);
+ auto rc = processImage(std::string{IMG_UPLOAD_DIR} +
+ '/' + event->name);
+ if (rc < 0)
+ {
+ log<level::ERR>("Error processing image",
+ entry("IMAGE=%s", std::string{event->name}));
+ }
+
}
offset += offsetof(inotify_event, name) + event->len;