blob: 899626394e7203ff0f10865bdefa1593fb899704 [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.
#include <memory>
#ifdef __Fuchsia__
#include <fidl/fuchsia.process.lifecycle/cpp/wire.h>
#include "src/lib/storage/vfs/cpp/managed_vfs.h"
#include "src/storage/minfs/bcache.h"
namespace minfs {
enum class Writability {
// Do not write to persistent storage under any circumstances whatsoever.
// Do not allow users of the filesystem to mutate filesystem state. This state allows the journal
// to replay while initializing writeback.
// Permit all operations.
struct MountOptions {
Writability writability = Writability::Writable;
bool verbose = false;
// Determines if the filesystem performs actions like replaying the journal, repairing the
// superblock, etc.
bool repair_filesystem = true;
// For testing only: if true, run fsck after every transaction.
bool fsck_after_every_transaction = false;
// Number of slices to preallocate for data when the filesystem is created.
uint32_t fvm_data_slices = 1;
// If true, don't log messages except for errors.
bool quiet = false;
#ifdef __Fuchsia__
struct CreateBcacheResult {
std::unique_ptr<minfs::Bcache> bcache;
bool is_read_only;
// Creates a Bcache using |device|.
// Returns the bcache and a boolean indicating if the underlying device is read-only.
zx::result<CreateBcacheResult> CreateBcache(std::unique_ptr<block_client::BlockDevice> device);
// Start the filesystem on the block device backed by |bcache|, and serve it on |root|. Blocks
// until the filesystem terminates.
zx::result<> Mount(std::unique_ptr<minfs::Bcache> bcache, const MountOptions& options,
fidl::ServerEnd<fuchsia_io::Directory> root);
zx::result<> StartComponent(fidl::ServerEnd<fuchsia_io::Directory> root,
fidl::ServerEnd<fuchsia_process_lifecycle::Lifecycle> lifecycle);
#endif // __Fuchsia__
} // namespace minfs