blob: 10e2e24721bc51c428847c17cfe7ebcc6c2f1bca [file] [log] [blame]
// Copyright 2017 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 <lib/async-loop/default.h>
#include <lib/zx/channel.h>
#include <lib/zx/resource.h>
#include <blobfs/cache-policy.h>
#include <blobfs/compression-algorithm.h>
#include <block-client/cpp/block-device.h>
#include <fbl/function.h>
namespace blobfs {
using block_client::BlockDevice;
// Determines the kind of directory layout the filesystem server should expose to the outside world.
// TODO(fxb/34531): When all users migrate to the export directory, delete this enum, since only
// |kExportDirectory| would be used.
enum class ServeLayout {
// The root of the filesystem is exposed directly
// Expose a pseudo-directory with the filesystem root located at "/root".
// TODO(fxb/34531): Also expose an administration service under "/svc/fuchsia.fs.Admin".
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.
// Toggles that may be set on blobfs during initialization.
struct MountOptions {
Writability writability = Writability::Writable;
bool verbose = false;
bool metrics = false;
bool journal = false;
bool pager = false;
CachePolicy cache_policy = CachePolicy::EvictImmediately;
// Compression algorithm to use when storing blobs.
// Blobs that are already stored on disk using another compression algorithm from disk are not
// affected by this flag.
CompressionAlgorithm write_compression_algorithm = CompressionAlgorithm::CHUNKED;
// Begins serving requests to the filesystem by parsing the on-disk format using |device|. If
// |ServeLayout| is |kDataRootOnly|, |root| serves the root of the filesystem. If it's
// |kExportDirectory|, |root| serves an outgoing directory.
// blobfs relies on the zx_vmo_replace_as_executable syscall to be able to serve executable blobs.
// The caller must either pass a valid Resource handle of kind ZX_RSRC_KIND_VMEX (or _ROOT) for
// |vmex_resource|, or else the mounted filesystem will not support requesting VMOs for blobs with
// This function blocks until the filesystem terminates.
zx_status_t Mount(std::unique_ptr<BlockDevice> device, MountOptions* options, zx::channel root,
ServeLayout layout, zx::resource vmex_resource);
} // namespace blobfs
#endif // BLOBFS_MOUNT_H_