handler: Add check for file existence for BM mode

/tmp/BMReady.flag indicates that we are in BM mode.

Tested:
Verified both cases -
- Mar 21 11:17:52 ipmid[1130]: /tmp/BMReady.flag exists so we must be in BM mode
- Mar 21 10:37:04 ipmid[1076]: Unable to find /tmp/BMReady so we must not be in BM mode

Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: I9fa99b40afea7e48ce7e1f9c47e8f081b71b897f
diff --git a/handler.cpp b/handler.cpp
index 564eab8..bc8f9bd 100644
--- a/handler.cpp
+++ b/handler.cpp
@@ -72,6 +72,16 @@
 #if BARE_METAL
     return static_cast<uint8_t>(BmcMode::BM_MODE);
 #else
+    std::error_code ec;
+    if (fs::exists(BM_SIGNAL_PATH, ec))
+    {
+        std::fprintf(stderr, "%s exists so we must be in BM mode\n",
+                     BM_SIGNAL_PATH);
+        return static_cast<uint8_t>(BmcMode::BM_MODE);
+    }
+
+    std::fprintf(stderr, "Unable to find %s so we must not be in BM mode\n",
+                 BM_SIGNAL_PATH);
     return static_cast<uint8_t>(BmcMode::NON_BM_MODE);
 #endif
 }