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