btrfs_diskformat/core/root_item.rs
1use {
2 crate::{InodeItem, Key, Time, UuidBytes},
3 byteorder::LE,
4 static_assertions::const_assert_eq,
5 zerocopy::{AsBytes, FromBytes, Unaligned, U32, U64},
6};
7
8/// Defines the location and parameters of the root of a b-tree.
9#[derive(Copy, Clone, Debug, AsBytes, FromBytes, Unaligned)]
10#[repr(C, packed)]
11pub struct RootItem {
12 pub inode: InodeItem,
13
14 pub generation: U64<LE>,
15
16 pub root_dirid: U64<LE>,
17
18 pub bytenr: U64<LE>,
19
20 /// Currently unused. Always 0.
21 pub byte_limit: U64<LE>,
22
23 /// Currently unused.
24 pub bytes_used: U64<LE>,
25
26 /// The transaction ID of the last transaction that created a snapshot of this root.
27 pub last_snapshot: U64<LE>,
28
29 pub flags: U64<LE>,
30
31 /// Only 0 or 1. Historically contained a reference count.
32 pub refs: U32<LE>,
33
34 /// Contains the key of the last dropped item during subvolume removal or relocation.
35 ///
36 /// Value will be zeroed out otherwise.
37 pub drop_progress: Key,
38
39 /// The tree level of the node referenced in [drop_progress](RootItem::drop_progress).
40 pub drop_level: u8,
41
42 /// The height of this root's tree.
43 pub level: u8,
44
45 /// Value to help determine whether this root has been modified by an older btrfs
46 /// implementation.
47 ///
48 /// If the value is equal to [generation], the fields below are valid. Otherwise, this indicates
49 /// the fields are invalid but recoverable.
50 ///
51 /// [generation]: RootItem::generation
52 pub generation_v2: U64<LE>,
53
54 /// The subvolume's UUID.
55 pub uuid: UuidBytes,
56
57 /// The parent's subvolume UUID.
58 ///
59 /// This is used during send/receive.
60 pub parent_uuid: UuidBytes,
61
62 /// The received UUID.
63 ///
64 /// This is used during send/receive.
65 pub received_uuid: UuidBytes,
66
67 /// The transaction ID of the last transaction that modified the tree.
68 ///
69 /// Note: some operations like internal caches or relocation will not update this value.
70 pub ctransid: U64<LE>,
71
72 /// The transaction ID of the transaction that created the tree.
73 pub otransid: U64<LE>,
74
75 /// The transaction ID for the transaction that sent this subvolume.
76 ///
77 /// This value is non-zero for a received subvolume.
78 pub stransid: U64<LE>,
79
80 /// The transaction ID for the transaction that received this subvolume.
81 ///
82 /// This value is non-zero for a received subvolume.
83 pub rtransid: U64<LE>,
84
85 /// The timestamp of the [`ctransid`](RootItem::ctransid).
86 pub ctime: Time,
87
88 /// The timestamp of the [`otransid`](RootItem::otransid).
89 pub otime: Time,
90
91 /// The timestamp of the [`stransid`](RootItem::stransid).
92 pub stime: Time,
93
94 /// The timestamp of the [`rtransid`](RootItem::rtransid).
95 pub rtime: Time,
96
97 /// Currently unused. Reserved for future use.
98 pub _unused: [u64; 8],
99}
100const_assert_eq!(core::mem::size_of::<RootItem>(), 439);