blob: fa3663f2c3a1ab695c47fb95d09a8396456af4bf [file] [log] [blame]
// Copyright 2022 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.
#ifdef __Fuchsia__
#include <lib/async-loop/cpp/loop.h>
#include "src/lib/storage/vfs/cpp/managed_vfs.h"
#include <lib/zx/result.h>
#include "src/storage/minfs/minfs_private.h"
#include "src/storage/minfs/mount.h"
namespace minfs {
// A wrapper class around a "Minfs" object which manages the external FIDL connections.
class Runner final : public PlatformVfs {
Runner(const Runner&) = delete;
Runner& operator=(const Runner&) = delete;
static zx::result<std::unique_ptr<Runner>> Create(FuchsiaDispatcher dispatcher,
std::unique_ptr<Bcache> bc,
const MountOptions& options);
static std::unique_ptr<Bcache> Destroy(std::unique_ptr<Runner> runner);
#ifdef __Fuchsia__
// ManagedVfs implementation.
void Shutdown(fs::FuchsiaVfs::ShutdownCallback cb) final;
zx::result<fs::FilesystemInfo> GetFilesystemInfo() final;
void OnNoConnections() final;
zx::result<> ServeRoot(fidl::ServerEnd<fuchsia_io::Directory> root);
void SetUnmountCallback(fit::closure on_unmount) { on_unmount_ = std::move(on_unmount); }
Minfs& minfs() { return *minfs_; }
explicit Runner(FuchsiaDispatcher dispatcher);
// Check if filesystem is readonly.
bool IsReadonly() const __TA_EXCLUDES(vfs_lock_);
#ifdef __Fuchsia__
async_dispatcher_t* dispatcher_;
std::unique_ptr<Minfs> minfs_;
fit::closure on_unmount_;
} // namespace minfs