summaryrefslogtreecommitdiffstats
path: root/watch.cpp
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-04-28 09:53:02 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-05-24 05:00:16 +0000
commit4e48fd582e86bd8246a5602dde4b5f644ae03d11 (patch)
treede8e88316377a42a74c12b850d71cf31086a5217 /watch.cpp
parent9b7c0b6da3e764cf51baf6b87ab4297a39ab782f (diff)
downloadphosphor-bmc-code-mgmt-4e48fd582e86bd8246a5602dde4b5f644ae03d11.tar.gz
phosphor-bmc-code-mgmt-4e48fd582e86bd8246a5602dde4b5f644ae03d11.zip
Check if image upload dir exists
The inotify doesn't work if the image upload dir doesn't exist. If the image dir doesn't exist log an error. Change-Id: I2b8c49182f2f19b8343587f4723575b6f6fc8781 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'watch.cpp')
-rw-r--r--watch.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/watch.cpp b/watch.cpp
index ae1e419..da1f967 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -4,6 +4,7 @@
#include <string>
#include <sys/inotify.h>
#include <unistd.h>
+#include <experimental/filesystem>
#include <phosphor-logging/log.hpp>
#include "config.h"
#include "watch.hpp"
@@ -18,9 +19,20 @@ namespace manager
using namespace phosphor::logging;
using namespace std::string_literals;
+namespace fs = std::experimental::filesystem;
Watch::Watch(sd_event* loop)
{
+ // Check if IMAGE DIR exists.
+ fs::path imgDirPath(IMG_UPLOAD_DIR);
+ if (!fs::is_directory(imgDirPath))
+ {
+ log<level::ERR>("ERROR No Image Dir",
+ entry("IMAGEDIR=%s", IMG_UPLOAD_DIR));
+ throw std::runtime_error(
+ "No Image Dir, IMAGEDIR=" + std::string{IMG_UPLOAD_DIR});
+ }
+
fd = inotify_init1(IN_NONBLOCK);
if (-1 == fd)
{
OpenPOWER on IntegriCloud