blob: 2ac23af0b0957d6fd1d8131583814bc7851a1cb7 [file] [log] [blame]
// Copyright 2021 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.
library fuchsia.fs.startup;
using fuchsia.fxfs;
using fuchsia.hardware.block;
using fuchsia.io;
using zx;
/// Compression algorithm specifier.
type CompressionAlgorithm = flexible enum {
ZSTD_CHUNKED = 0;
UNCOMPRESSED = 1;
};
/// An optional eviction policy override for pager-backed blobs for blobfs.
type EvictionPolicyOverride = flexible enum {
/// Don't override the default cache policy.
NONE = 0;
/// Override the default cache policy for pager-backed blobs with kNeverEvict.
NEVER_EVICT = 1;
/// Override the default cache policy for pager-backed blobs with kEvictImmediately.
EVICT_IMMEDIATELY = 2;
};
/// Options for starting a filesystem.
type StartOptions = resource struct {
/// Start the filesystem in read-only mode.
@allow_deprecated_struct_defaults
read_only bool = false;
/// Enable verbose logging.
@allow_deprecated_struct_defaults
verbose bool = false;
/// If true, decompression is run in a sandbox component (if the filesystem supports it).
@allow_deprecated_struct_defaults
sandbox_decompression bool = false;
/// If true, run fsck after every transaction. This is for testing purposes only - it's very
/// slow to run a filesystem like this.
fsck_after_every_transaction bool;
/// A compression algorithm specifier for the filesystem to use when storing files (if the
/// filesystem supports it). Defaults to ZSTD_CHUNKED.
write_compression_algorithm CompressionAlgorithm;
/// An optional compression level for the filesystem to use when storing files (if the
/// filesystem and the configured |write_compression_algorithm| supports it). Setting to < 0
/// indicates no value (the filesystem chooses a default if necessary).
@allow_deprecated_struct_defaults
write_compression_level int32 = -1;
/// An optional eviction policy specifier for the filesystem to use for in-memory structures
/// (if the filesystem supports it), specifically for pager-backed files.
cache_eviction_policy_override EvictionPolicyOverride;
/// An optional connection to a crypt client (for encrypted filesystems).
crypt client_end:<fuchsia.fxfs.Crypt, optional>;
// If set, provides the caller with the opportunity to migrate data before the mount is
// finalised. The mount will be blocked until the channel is closed.
migrate_root server_end:<fuchsia.io.Directory, optional>;
};
/// Options for how to format filesystems.
type FormatOptions = resource struct {
/// Enable verbose logging.
@allow_deprecated_struct_defaults
verbose bool = false;
/// If true, use the deprecated padded merkle tree blobfs format.
@allow_deprecated_struct_defaults
deprecated_padded_blobfs_format bool = false;
/// The initial number of inodes to allocate space for. If zero, a default is used. Only
/// supported for blobfs.
@allow_deprecated_struct_defaults
num_inodes uint64 = 0;
/// The number of fvm slices to preallocate for data when the filesystem is created.
fvm_data_slices uint32;
/// An optional connection to a crypt client (for encrypted filesystems).
crypt client_end:<fuchsia.fxfs.Crypt, optional>;
};
/// Options for running consistency checks on filesystems.
type CheckOptions = resource struct {
/// An optional connection to a crypt client (for encrypted filesystems).
crypt client_end:<fuchsia.fxfs.Crypt, optional>;
};
// TODO(fxbug.dev/90702): Figure out a more flexible configuration option strategy.
@discoverable
protocol Startup {
/// Start this filesystem, using the provided block device and Start options. When start is
/// called, the filesystem will populate it's outgoing directory and then return.
Start(resource struct {
device client_end:fuchsia.hardware.block.Block;
options StartOptions;
}) -> (struct {}) error zx.status;
/// Format the provided block device with this filesystem.
Format(resource struct {
device client_end:fuchsia.hardware.block.Block;
options FormatOptions;
}) -> (struct {}) error zx.status;
/// Check the provided block device for filesystem consistency.
Check(resource struct {
device client_end:fuchsia.hardware.block.Block;
options CheckOptions;
}) -> (struct {}) error zx.status;
};