Check if mount point already exists

Typically, we create the mount point directory when we mount the
filesystem, and then we remove the directory when we unmount. Currently,
we aren't accounting for the case where the directory already exists,
e.g. if the BMC reboots while the filesystem is mounted.

This commit adds a check to see if the directory is already present. If
so, it won't try to create the directory again.

Tested:
1. Formatted an eMMC using the FormatLuks method, which also creates the
   mount point and mounts the filesystem.
2. Rebooted the BMC
3. Ran the Unlock method to unlock the LUKS device and mount the
   filesystem.

Signed-off-by: John Wedig <johnwedig@google.com>
Change-Id: I3e279c653b21f570b97e4d530a19e5ae30bf8719
diff --git a/src/estoraged.cpp b/src/estoraged.cpp
index 777232a..55a08a4 100644
--- a/src/estoraged.cpp
+++ b/src/estoraged.cpp
@@ -250,14 +250,22 @@
 
 void eStoraged::mountFilesystem()
 {
-    /* Create directory for the filesystem. */
-    bool success = fsIface->createDirectory(std::filesystem::path(mountPoint));
-    if (!success)
+    /*
+     * Create directory for the filesystem, if it's not already present. It
+     * might already exist if, for example, the BMC reboots after creating the
+     * directory.
+     */
+    if (!fsIface->directoryExists(std::filesystem::path(mountPoint)))
     {
-        lg2::error("Failed to create mount point: {DIR}", "DIR", mountPoint,
-                   "REDFISH_MESSAGE_ID",
-                   std::string("OpenBMC.0.1.MountFilesystemFail"));
-        throw InternalFailure();
+        bool success =
+            fsIface->createDirectory(std::filesystem::path(mountPoint));
+        if (!success)
+        {
+            lg2::error("Failed to create mount point: {DIR}", "DIR", mountPoint,
+                       "REDFISH_MESSAGE_ID",
+                       std::string("OpenBMC.0.1.MountFilesystemFail"));
+            throw InternalFailure();
+        }
     }
 
     /* Run the command to mount the filesystem. */