Merge "Fix unhandled exception when FUSE disabled" am: 20b1532b85

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2282933

Change-Id: Iaceb4670a0032ac31bfe330e3f879b06fa351050
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Utils.cpp b/Utils.cpp
index 9e77a9e..23e8867 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -1448,7 +1448,10 @@
 status_t AbortFuseConnections() {
     namespace fs = std::filesystem;
 
-    for (const auto& itEntry : fs::directory_iterator("/sys/fs/fuse/connections")) {
+    static constexpr const char* kFuseConnections = "/sys/fs/fuse/connections";
+
+    std::error_code ec;
+    for (const auto& itEntry : fs::directory_iterator(kFuseConnections, ec)) {
         std::string fsPath = itEntry.path().string() + "/filesystem";
         std::string fs;
 
@@ -1468,6 +1471,11 @@
         }
     }
 
+    if (ec) {
+        LOG(WARNING) << "Failed to iterate through " << kFuseConnections << ": "  << ec.message();
+        return -ec.value();
+    }
+
     return OK;
 }