[fshost] Remove dead code

Bug: 39588
Change-Id: I46e8ae74bfbfcd80d30d4f7057039a712aadfd70
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/675043
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Tamir Duberstein <tamird@google.com>
Reviewed-by: Stephen Demos <sdemos@google.com>
diff --git a/src/storage/fshost/BUILD.gn b/src/storage/fshost/BUILD.gn
index a88c28c..7b982b6 100644
--- a/src/storage/fshost/BUILD.gn
+++ b/src/storage/fshost/BUILD.gn
@@ -262,7 +262,6 @@
 
 test("fshost_test") {
   sources = [
-    "delayed-outdir-test.cc",
     "fshost-boot-args-test.cc",
     "fshost-test.cc",
   ]
diff --git a/src/storage/fshost/block-watcher.cc b/src/storage/fshost/block-watcher.cc
index ebf168b..a05f310 100644
--- a/src/storage/fshost/block-watcher.cc
+++ b/src/storage/fshost/block-watcher.cc
@@ -19,6 +19,7 @@
 #include <lib/fdio/watcher.h>
 #include <lib/fidl-async/cpp/bind.h>
 #include <lib/fzl/time.h>
+#include <lib/syslog/cpp/macros.h>
 #include <lib/zx/channel.h>
 #include <lib/zx/process.h>
 #include <lib/zx/time.h>
diff --git a/src/storage/fshost/delayed-outdir-test.cc b/src/storage/fshost/delayed-outdir-test.cc
deleted file mode 100644
index 7b5cb6845..0000000
--- a/src/storage/fshost/delayed-outdir-test.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2019 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 "delayed-outdir.h"
-
-#include <lib/fdio/directory.h>
-#include <lib/fpromise/bridge.h>
-#include <lib/fpromise/result.h>
-#include <lib/fpromise/single_threaded_executor.h>
-#include <zircon/assert.h>
-#include <zircon/types.h>
-
-#include <gtest/gtest.h>
-
-#include "src/lib/storage/vfs/cpp/managed_vfs.h"
-
-namespace fshost {
-namespace {
-
-// TODO(fxbug.dev/39588): delete this
-TEST(DelayedOutdirTest, MessagesWaitForStart) {
-  // Create a new DelayedOutdir, and initialize it with a new channel
-  auto delayed_outdir = DelayedOutdir();
-
-  auto delayed = fidl::CreateEndpoints<fuchsia_io::Directory>();
-  ASSERT_EQ(delayed.status_value(), ZX_OK);
-
-  auto remote_dir = delayed_outdir.Initialize(std::move(delayed->client));
-
-  // Put the remote_dir we received from DelayedOutDir in a vfs and run it
-
-  auto root = fidl::CreateEndpoints<fuchsia_io::Directory>();
-  ASSERT_EQ(root.status_value(), ZX_OK);
-
-  auto loop = async::Loop(&kAsyncLoopConfigNoAttachToCurrentThread);
-  auto vfs = fs::ManagedVfs(loop.dispatcher());
-  vfs.ServeDirectory(remote_dir, std::move(root->server));
-  loop.StartThread("delayed_outgoing_dir_test");
-
-  // Attempt to open "fs/foo" in our vfs, which will forward an open request for
-  // "foo" into the channel we provided above.
-
-  auto foo = fidl::CreateEndpoints<fuchsia_io::Directory>();
-  ASSERT_EQ(foo.status_value(), ZX_OK);
-  zx_status_t status =
-      fdio_open_at(root->client.channel().get(), "fs/foo",
-                   static_cast<uint32_t>(fuchsia_io::wire::OpenFlags::kRightReadable),
-                   foo->server.channel().release());
-  ASSERT_EQ(status, ZX_OK);
-
-  // If we attempt to read from the channel behind DelayedOutdir, we should see
-  // ZX_ERR_SHOULD_WAIT because the DelayedOutdir isn't running yet, and thus
-  // the open we just made hasn't been handled yet.
-
-  uint8_t read_buffer[1024];
-  zx_handle_t handle_buffer[16];
-  uint32_t actual_bytes = 0;
-  uint32_t actual_handles = 0;
-  status = delayed->server.channel().read(0, read_buffer, handle_buffer, sizeof(read_buffer),
-                                          sizeof(handle_buffer), &actual_bytes, &actual_handles);
-  ASSERT_EQ(ZX_ERR_SHOULD_WAIT, status);
-
-  // Now let's start the DelayedOutdir, and wait for the channel to become
-  // readable. Once it's readable, that means our open request from above made
-  // it through.
-
-  delayed_outdir.Start();
-  zx_signals_t observed;
-  status = delayed->server.channel().wait_one(ZX_CHANNEL_READABLE, zx::deadline_after(zx::sec(10)),
-                                              &observed);
-  ASSERT_EQ(status, ZX_OK);
-  ASSERT_TRUE(observed & ZX_CHANNEL_READABLE);
-
-  // Shut down the managed VFS to get it to close active connections, otherwise
-  // the deconstructor will crash.
-
-  fpromise::bridge<zx_status_t> bridge;
-  vfs.Shutdown(bridge.completer.bind());
-  auto promise_shutdown = bridge.consumer.promise_or(::fpromise::error());
-
-  fpromise::result<zx_status_t, void> result =
-      fpromise::run_single_threaded(std::move(promise_shutdown));
-  ASSERT_TRUE(result.is_ok());
-  ASSERT_EQ(result.value(), ZX_OK);
-}
-
-}  // namespace
-}  // namespace fshost
diff --git a/src/storage/fshost/delayed-outdir.h b/src/storage/fshost/delayed-outdir.h
deleted file mode 100644
index 0ae5ce60..0000000
--- a/src/storage/fshost/delayed-outdir.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2019 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.
-
-#ifndef SRC_STORAGE_FSHOST_DELAYED_OUTDIR_H_
-#define SRC_STORAGE_FSHOST_DELAYED_OUTDIR_H_
-
-#include <lib/async-loop/cpp/loop.h>
-#include <lib/async-loop/default.h>
-#include <lib/fpromise/bridge.h>
-#include <lib/fpromise/result.h>
-#include <lib/fpromise/single_threaded_executor.h>
-#include <lib/syslog/cpp/macros.h>
-#include <lib/zx/channel.h>
-#include <zircon/status.h>
-#include <zircon/types.h>
-
-#include "src/lib/storage/vfs/cpp/managed_vfs.h"
-#include "src/lib/storage/vfs/cpp/pseudo_dir.h"
-#include "src/lib/storage/vfs/cpp/remote_dir.h"
-#include "src/lib/storage/vfs/cpp/vfs.h"
-#include "src/lib/storage/vfs/cpp/vfs_types.h"
-
-namespace fshost {
-
-// TODO(fxbug.dev/39588): This class is used to create a new RemoteDir that doesn't
-// respond to any messages until `.Start()` is called. This is important for
-// signaling to devcoordinator and component manager when they can start
-// accessing data from pkgfs. This solution is fairly hacky, and will hopefully
-// not be very long lived. Ideally the filesystems will properly pipeline
-// requests, wherein each filesystem would not respond to requests until it was
-// initialized.
-class DelayedOutdir {
- public:
-  DelayedOutdir()
-      : outgoing_dir_delayed_loop_(new async::Loop(&kAsyncLoopConfigNoAttachToCurrentThread)),
-        delayed_vfs_(fs::ManagedVfs(outgoing_dir_delayed_loop_->dispatcher())) {}
-
-  ~DelayedOutdir() {
-    if (!started_) {
-      // if we haven't actually started the async loop yet, we need to so we can tear down any
-      // connections that got created in the mean time.
-      outgoing_dir_delayed_loop_->StartThread("delayed_outgoing_dir");
-    }
-    fpromise::bridge<zx_status_t> bridge;
-    delayed_vfs_.Shutdown(bridge.completer.bind());
-    auto promise_shutdown = bridge.consumer.promise_or(::fpromise::error());
-
-    fpromise::result<zx_status_t, void> result =
-        fpromise::run_single_threaded(std::move(promise_shutdown));
-    if (!result.is_ok()) {
-      FX_LOGS(ERROR) << "error running fpromise executor to shutdown delayed outdir vfs";
-    } else if (result.value() != ZX_OK) {
-      FX_LOGS(ERROR) << "error shutting down delayed outdir vfs: "
-                     << zx_status_get_string(result.value());
-    }
-  }
-
-  fbl::RefPtr<fs::RemoteDir> Initialize(fidl::ClientEnd<fuchsia_io::Directory> filesystems_client) {
-    auto delayed_dir = fbl::MakeRefCounted<fs::PseudoDir>();
-    delayed_dir->AddEntry("fs", fbl::MakeRefCounted<fs::RemoteDir>(std::move(filesystems_client)));
-
-    // Add the delayed vfs to the main one under /delayed
-    auto delayed = fidl::CreateEndpoints<fuchsia_io::Directory>();
-    if (!delayed.is_ok()) {
-      FX_LOGS(ERROR) << "delayed outdir failed to create channel";
-      return fbl::RefPtr<fs::RemoteDir>();
-    }
-    delayed_vfs_.ServeDirectory(delayed_dir, std::move(delayed->server));
-
-    return fbl::MakeRefCounted<fs::RemoteDir>(std::move(delayed->client));
-  }
-
-  void Start() {
-    outgoing_dir_delayed_loop_->StartThread("delayed_outgoing_dir");
-    started_ = true;
-  }
-
- private:
-  std::unique_ptr<async::Loop> outgoing_dir_delayed_loop_;
-  fs::ManagedVfs delayed_vfs_;
-  bool started_ = false;
-};
-
-}  // namespace fshost
-
-#endif  // SRC_STORAGE_FSHOST_DELAYED_OUTDIR_H_
diff --git a/src/storage/fshost/fs-manager.h b/src/storage/fshost/fs-manager.h
index df7dfb3..682c29e 100644
--- a/src/storage/fshost/fs-manager.h
+++ b/src/storage/fshost/fs-manager.h
@@ -22,7 +22,6 @@
 #include <fshost_config/config.h>
 
 #include "src/lib/storage/vfs/cpp/vfs.h"
-#include "src/storage/fshost/delayed-outdir.h"
 #include "src/storage/fshost/fdio.h"
 #include "src/storage/fshost/fshost-boot-args.h"
 #include "src/storage/fshost/inspect-manager.h"