diff options
| author | Gunnar Mills <gmills@us.ibm.com> | 2017-04-19 15:42:47 -0500 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2017-05-11 02:10:53 +0000 |
| commit | e91d321a9671ea317a203d128b67e2b320def58f (patch) | |
| tree | 8b2ef98e4b652b455ef99ef03845b15c14e56066 | |
| parent | 368cfcbb4755f6b78f6f0c5976aece4ce823f4ec (diff) | |
| download | phosphor-bmc-code-mgmt-e91d321a9671ea317a203d128b67e2b320def58f.tar.gz phosphor-bmc-code-mgmt-e91d321a9671ea317a203d128b67e2b320def58f.zip | |
Call processImage from inotify
Change-Id: I0b748f93f8e34552cef67616317c28660284ac99
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
| -rwxr-xr-x | Makefile.am | 8 | ||||
| -rw-r--r-- | image_manager.cpp | 18 | ||||
| -rw-r--r-- | image_manager.hpp | 21 | ||||
| -rw-r--r-- | watch.cpp | 15 |
4 files changed, 55 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am index 9de41b4..fbc8cbf 100755 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,9 @@ AM_DEFAULT_SOURCE_EXT = .cpp 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 @@ sbin_PROGRAMS = \ 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 @@ -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 software namespace manager { +using namespace phosphor::logging; using namespace std::string_literals; Watch::Watch(sd_event* loop) @@ -86,11 +88,14 @@ int Watch::callback(sd_event_source* s, 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; |

