summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Geissler <andrewg@us.ibm.com>2017-03-28 15:44:18 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-05-03 21:36:16 +0000
commit07d0ed53767036267999c7a271b46a43bbae022c (patch)
treeb4937f3b4ac2a16d18e32579f96615032337fc3f
parenteeaccf844f50e6e666a981b0cd390017511c6c23 (diff)
downloadphosphor-state-manager-07d0ed53767036267999c7a271b46a43bbae022c.tar.gz
phosphor-state-manager-07d0ed53767036267999c7a271b46a43bbae022c.zip
Create file if host is running
This file is used by the host start services to know if they should actually run or not Change-Id: I62c5af0cd54a40ed272a59871dc26a3e125070a2 Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
-rw-r--r--configure.ac4
-rw-r--r--host_check_main.cpp16
2 files changed, 19 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index f2cb6ad..b6ee1da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,6 +48,10 @@ AC_ARG_VAR(BMC_OBJPATH, [The BMC state manager Dbus root])
AS_IF([test "x$BMC_OBJPATH" == "x"], [BMC_OBJPATH="/xyz/openbmc_project/state/bmc"])
AC_DEFINE_UNQUOTED([BMC_OBJPATH], ["$BMC_OBJPATH"], [The BMC state manager Dbus root])
+AC_ARG_VAR(HOST_RUNNING_FILE, [File to create if host is running])
+AS_IF([test "x$HOST_RUNNING_FILE" == "x"], [HOST_RUNNING_FILE="/run/openbmc/host@%u-on"])
+AC_DEFINE_UNQUOTED([HOST_RUNNING_FILE], ["$HOST_RUNNING_FILE"], [File to create if host is running])
+
# Check for header files.
AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd developement package required])])
AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])])
diff --git a/host_check_main.cpp b/host_check_main.cpp
index 3eab1e3..5645b8e 100644
--- a/host_check_main.cpp
+++ b/host_check_main.cpp
@@ -1,8 +1,12 @@
#include <cstdlib>
#include <unistd.h>
+#include <iostream>
+#include <fstream>
+#include <cstdio>
#include <sdbusplus/bus.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Control/Host/server.hpp>
+#include <config.h>
using namespace std::literals;
using namespace phosphor::logging;
@@ -122,8 +126,18 @@ int main(int argc, char *argv[])
// If host running then create file
if(hostRunning)
{
- // TODO - Add file creation
log<level::INFO>("Host is running!");
+ // Create file for host instance and create in filesystem to indicate
+ // to services that host is running
+ auto size = std::snprintf(nullptr,0,HOST_RUNNING_FILE,0);
+ std::unique_ptr<char[]> buf(new char[size+1]);
+ std::snprintf(buf.get(),size,HOST_RUNNING_FILE,0);
+ std::ofstream outfile(buf.get());
+ outfile.close();
+ }
+ else
+ {
+ log<level::INFO>("Host is not running!");
}
return 0;
OpenPOWER on IntegriCloud