blob: 18f1ddc75f266dc8ed4520dad0382216429631d1 [file] [log] [blame]
// Copyright 2020 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_LIB_PAVER_SHERLOCK_H_
#define SRC_STORAGE_LIB_PAVER_SHERLOCK_H_
#include "src/storage/lib/paver/abr-client.h"
#include "src/storage/lib/paver/device-partitioner.h"
#include "src/storage/lib/paver/gpt.h"
#include "src/storage/lib/paver/partition-client.h"
namespace paver {
class SherlockPartitioner : public DevicePartitioner {
public:
static zx::result<std::unique_ptr<DevicePartitioner>> Initialize(
const BlockDevices& devices, fidl::UnownedClientEnd<fuchsia_io::Directory> svc_root,
const PaverConfig& config, fidl::ClientEnd<fuchsia_device::Controller> block_device);
zx::result<std::unique_ptr<abr::Client>> CreateAbrClient() const override;
const paver::BlockDevices& Devices() const override;
fidl::UnownedClientEnd<fuchsia_io::Directory> SvcRoot() const override;
bool IsFvmWithinFtl() const override { return false; }
bool SupportsPartition(const PartitionSpec& spec) const override;
zx::result<std::unique_ptr<PartitionClient>> FindPartition(
const PartitionSpec& spec) const override;
zx::result<> WipeFvm() const override;
zx::result<> ResetPartitionTables() const override;
zx::result<> ValidatePayload(const PartitionSpec& spec,
std::span<const uint8_t> data) const override;
zx::result<> Flush() const override { return zx::ok(); }
zx::result<> OnStop() const override { return zx::ok(); }
private:
SherlockPartitioner(std::unique_ptr<GptDevicePartitioner> gpt, BlockDevices non_gpt_devices)
: gpt_(std::move(gpt)), non_gpt_devices_(std::move(non_gpt_devices)) {}
std::unique_ptr<GptDevicePartitioner> gpt_;
BlockDevices non_gpt_devices_;
};
class SherlockPartitionerFactory : public DevicePartitionerFactory {
public:
zx::result<std::unique_ptr<DevicePartitioner>> New(
const BlockDevices& devices, fidl::UnownedClientEnd<fuchsia_io::Directory> svc_root,
const PaverConfig& config, std::shared_ptr<Context> context,
fidl::ClientEnd<fuchsia_device::Controller> block_device) final;
};
} // namespace paver
#endif // SRC_STORAGE_LIB_PAVER_SHERLOCK_H_