btrfs_diskformat/core/
dev_item.rs

1use crate::UuidBytes;
2use static_assertions::const_assert_eq;
3use zerocopy::little_endian::{U32 as U32LE, U64 as U64LE};
4use zerocopy_derive::*;
5
6/// Represents a complete block device.
7#[derive(Copy, Clone, Debug, Hash, IntoBytes, FromBytes, Unaligned, KnownLayout, Immutable)]
8#[repr(C, packed)]
9pub struct DevItem {
10    /// The internal btrfs device ID.
11    ///
12    /// This should match the devid found in the filesystem's list of devices.
13    pub devid: U64LE,
14
15    /// The size of the device.
16    pub total_bytes: U64LE,
17
18    /// The bytes in use by the filesystem on the device.
19    pub bytes_used: U64LE,
20
21    /// The optimal I/O alignment for this device.
22    pub io_align: U32LE,
23
24    /// The optimal I/O width for this device.
25    pub io_width: U32LE,
26
27    /// The minimum I/O size for this device.
28    pub sector_size: U32LE,
29
30    /// The type and info for this device.
31    pub dev_type: U64LE,
32
33    /// The expected generation for this device.
34    pub generation: U64LE,
35
36    /// The starting byte of this partition on the device, to allow for stripe
37    /// alignment.
38    pub start_offset: U64LE,
39
40    /// Grouping information for allocation decisions.
41    pub dev_group: U32LE,
42
43    /// The seek speed of the device on a scale from 0 to 100, where 100 is the
44    /// fastest.
45    pub seek_speed: u8,
46
47    /// The bandwidth of the device on a scale from 0 to 100, where 100 is the
48    /// fastest.
49    pub bandwith: u8,
50
51    /// The generated UUID for this device.
52    pub uuid: UuidBytes,
53
54    /// The UUID of the filesystem that owns this device.
55    pub fsid: UuidBytes,
56}
57const_assert_eq!(core::mem::size_of::<DevItem>(), 98);