fshost_assembly_config/
lib.rs

1// Copyright 2025 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use serde::{Deserialize, Serialize};
6
7/// A mapping of a semantic label for a block device to board-specific identifiers for that block
8/// device. The identifiers are used by fshost to match block devices as they come in, which then
9/// are exported under the configured semantic label. Only the first block device that matches will
10/// be exported, any others will be ignored.
11#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
12pub struct BlockDeviceConfig {
13    /// The semantic label, or name for the block device to be routed by.
14    pub device: String,
15    /// The identifiers to match against. The block device must match both the label and the parent
16    /// identifiers to be selected for this label.
17    pub from: BlockDeviceIdentifiers,
18}
19
20/// A set of identifiers used to match block devices.
21#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
22pub struct BlockDeviceIdentifiers {
23    /// The expected partition label for the block device.
24    pub label: String,
25    /// The expected parent for the block device.
26    pub parent: BlockDeviceParent,
27}
28
29/// Possible parents for a block device.
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "lowercase")]
32pub enum BlockDeviceParent {
33    /// The device is expected to be a child of the main system gpt.
34    Gpt,
35    /// The device is expected to be a child of a driver.
36    Dev,
37}