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>
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 @@
     // 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;