[devcoordinator] stop handing out handle to /hub
On bringup builds pkgfs is never brought up which means the appmgr
component is never run which means the handle to /hub is never serviced,
which means that `ls /` hangs forever when it attempts to look in the
hub handle.
Devcoordinator should stop handing out the /hub handle to children until
the appmgr component doesn't exist on bringup builds.
Bug: 44748
Change-Id: Ifb0f52c5e42f4c87e1b69d3941f5237f2e4b1720
diff --git a/build/unification/images/BUILD.gn b/build/unification/images/BUILD.gn
index 11cf126..3d895b5 100644
--- a/build/unification/images/BUILD.gn
+++ b/build/unification/images/BUILD.gn
@@ -336,6 +336,7 @@
":test.sys.ddk-unittest-test",
":test.sys.default-stack-size-default-test",
":test.sys.default-stack-size-phdr-test",
+ ":test.sys.devcoordinator-namespace-test",
":test.sys.device-protocol-pci-test",
":test.sys.device-protocol-pdev-test",
":test.sys.disk-inspector-unit-test",
@@ -668,6 +669,7 @@
":test.sys.ddk-unittest-test",
":test.sys.default-stack-size-default-test",
":test.sys.default-stack-size-phdr-test",
+ ":test.sys.devcoordinator-namespace-test",
":test.sys.device-protocol-pci-test",
":test.sys.device-protocol-pdev-test",
":test.sys.disk-inspector-unit-test",
diff --git a/src/devices/driver_manager/fdio.cc b/src/devices/driver_manager/fdio.cc
index 3fa0fbe..136c5db 100644
--- a/src/devices/driver_manager/fdio.cc
+++ b/src/devices/driver_manager/fdio.cc
@@ -54,7 +54,9 @@
{ "/boot", "boot", FS_BOOT, FdioAction::CloneDir },
{ "/data", "data", FS_DATA, FdioAction::CloneDir },
{ "/dev", "dev", FS_DEV, FdioAction::AddNsEntry },
- { "/hub", "hub", FS_HUB, FdioAction::CloneDir },
+ // TODO(dgonyeo): add this path back in once the appmgr component doesn't
+ // exist on bringup builds
+ //{ "/hub", "hub", FS_HUB, FdioAction::CloneDir },
{ "/install", "install", FS_INSTALL, FdioAction::CloneDir },
{ "/pkgfs", "pkgfs", FS_PKGFS, FdioAction::CloneDir },
{ "/svc", "svc", FS_SVC, FdioAction::AddNsEntry },
diff --git a/zircon/system/utest/BUILD.gn b/zircon/system/utest/BUILD.gn
index fe1bd51..d436fa7 100644
--- a/zircon/system/utest/BUILD.gn
+++ b/zircon/system/utest/BUILD.gn
@@ -23,8 +23,8 @@
"$zx/system/core/devmgr/fshost:block-watcher-test",
"$zx/system/core/devmgr/fshost:fshost-metrics-test",
"$zx/system/core/devmgr/fshost:fshost-test",
- "$zx/system/core/netsvc:netsvc-test",
"$zx/system/core/netsvc:netsvc-stress-test",
+ "$zx/system/core/netsvc:netsvc-test",
"$zx/system/core/ptysvc:ptysvc-test",
"$zx/system/core/svchost:crashsvc-test",
"$zx/system/dev/audio/codecs/max98373:max98373-test",
@@ -121,6 +121,7 @@
"blobfs-bench",
"channel-fatal",
"core",
+ "devcoordinator-namespace",
"dlfcn",
"fidl",
"fidl-coding-tables",
diff --git a/zircon/system/utest/devcoordinator-namespace/BUILD.gn b/zircon/system/utest/devcoordinator-namespace/BUILD.gn
new file mode 100644
index 0000000..89bd3df
--- /dev/null
+++ b/zircon/system/utest/devcoordinator-namespace/BUILD.gn
@@ -0,0 +1,11 @@
+# Copyright 2020 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+zx_test("devcoordinator-namespace") {
+ sources = [ "namespace_test.cc" ]
+ deps = [
+ "$zx/system/ulib/fdio",
+ "$zx/system/ulib/zxtest",
+ ]
+}
diff --git a/zircon/system/utest/devcoordinator-namespace/namespace_test.cc b/zircon/system/utest/devcoordinator-namespace/namespace_test.cc
new file mode 100644
index 0000000..cdd7666
--- /dev/null
+++ b/zircon/system/utest/devcoordinator-namespace/namespace_test.cc
@@ -0,0 +1,40 @@
+// Copyright 2020 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <dirent.h>
+#include <lib/fdio/directory.h>
+
+#include <string>
+#include <vector>
+
+#include <fbl/string_printf.h>
+#include <zxtest/zxtest.h>
+
+std::vector<std::string> list_dir_contents(const char* name) {
+ std::vector<std::string> res;
+
+ DIR* dir;
+ struct dirent* ent;
+ if ((dir = opendir(name)) != NULL) {
+ /* print all the files and directories within directory */
+ while ((ent = readdir(dir)) != NULL) {
+ res.push_back(std::string(ent->d_name));
+ }
+ closedir(dir);
+ }
+
+ return res;
+}
+
+TEST(NamespaceTest, Test) {
+ // For each directory in the root directory, let's make sure that it actually
+ // goes somewhere. We're testing that the handle has something responding at
+ // the other side, not that it goes somewhere valid, so it's fine if we get an
+ // error while using it.
+ auto top_level_dir_names = list_dir_contents("/");
+ for (const auto& name : top_level_dir_names) {
+ fbl::String sub_dir_name = fbl::StringPrintf("/%s", name.c_str());
+ auto dir_contents = list_dir_contents(sub_dir_name.c_str());
+ }
+}