Fix the core dump by using filesystem error_code

The currently used filesystem method will cause an exception if the
file system is damaged for some reason, resulting in a core dump of
the process.
So the overloaded method with the error_code parameter should be used
here to ensure that the process core dump will not be caused after an
exception is thrown.

Fixes: openbmc/phosphor-bmc-code-mgmt#12

Tested: built phosphor-bmc-code-mgmt successfully and CI passes.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I329f78b481cb466e755bc1b78562583620f561c2
diff --git a/usb/usb_manager.cpp b/usb/usb_manager.cpp
index 196ab42..226a578 100644
--- a/usb/usb_manager.cpp
+++ b/usb/usb_manager.cpp
@@ -4,6 +4,8 @@
 
 #include <sys/mount.h>
 
+#include <system_error>
+
 namespace phosphor
 {
 namespace usb
@@ -11,8 +13,9 @@
 
 bool USBManager::run()
 {
+    std::error_code ec;
     fs::path dir(usbPath);
-    fs::create_directories(dir);
+    fs::create_directories(dir, ec);
 
     auto rc = mount(devicePath.c_str(), usbPath.c_str(), "vfat", 0, NULL);
     if (rc)
@@ -27,7 +30,7 @@
         if (p.path().extension() == ".tar")
         {
             fs::path dstPath{IMG_UPLOAD_DIR / p.path().filename()};
-            if (fs::exists(dstPath))
+            if (fs::exists(dstPath, ec))
             {
                 lg2::info(
                     "{DSTPATH} already exists in the /tmp/images directory, exit the upgrade",