Skip to main content

RootItem

Struct RootItem 

Source
pub struct RootItem {
Show 24 fields pub inode_data: Vec<u8>, pub generation: u64, pub root_dirid: u64, pub bytenr: u64, pub byte_limit: u64, pub bytes_used: u64, pub last_snapshot: u64, pub flags: RootItemFlags, pub refs: u32, pub drop_progress: DiskKey, pub drop_level: u8, pub level: u8, pub generation_v2: u64, pub uuid: Uuid, pub parent_uuid: Uuid, pub received_uuid: Uuid, pub ctransid: u64, pub otransid: u64, pub stransid: u64, pub rtransid: u64, pub ctime: Timespec, pub otime: Timespec, pub stime: Timespec, pub rtime: Timespec,
}
Expand description

Root item describing a tree (subvolume, snapshot, or internal tree).

Stored in the root tree with key (tree_objectid, ROOT_ITEM, 0). Contains the root block pointer, subvolume UUIDs, and transaction timestamps needed for snapshot management and send/receive.

Fields§

§inode_data: Vec<u8>

Raw bytes of the embedded btrfs_inode_item (160 bytes).

The on-disk ROOT_ITEM starts with an embedded inode describing the root directory of the subvolume. This is preserved as raw bytes to avoid losing data during parse/serialize round-trips, since the embedded inode fields are not otherwise tracked by this struct.

§generation: u64

Generation when this root was last modified.

§root_dirid: u64

Objectid of the root directory inode (always 256 for FS trees).

§bytenr: u64

Logical bytenr of this tree’s root block.

§byte_limit: u64

Quota byte limit (0 = unlimited).

§bytes_used: u64

Bytes used by this tree.

§last_snapshot: u64

Generation of the last snapshot taken from this subvolume.

§flags: RootItemFlags

Root flags (RDONLY for read-only snapshots).

§refs: u32

Reference count.

§drop_progress: DiskKey

Progress key for in-progress drop operations.

§drop_level: u8

Tree level of the drop progress.

§level: u8

B-tree level of this tree’s root block.

§generation_v2: u64

Extended generation (v2 root items, matches generation in practice).

§uuid: Uuid

UUID of this subvolume.

§parent_uuid: Uuid

UUID of the parent subvolume (for snapshots).

§received_uuid: Uuid

UUID of the subvolume this was received from (for send/receive).

§ctransid: u64

Transaction ID of the last change to this subvolume.

§otransid: u64

Transaction ID when this subvolume was created.

§stransid: u64

Transaction ID when this subvolume was sent.

§rtransid: u64

Transaction ID when this subvolume was received.

§ctime: Timespec

Time of the last change.

§otime: Timespec

Creation time.

§stime: Timespec

Time when sent.

§rtime: Timespec

Time when received.

Implementations§

Source§

impl RootItem

Source

pub fn parse(data: &[u8]) -> Option<Self>

Parse a root item from a raw byte buffer. Handles both v1 (shorter) and v2 (full) root item formats gracefully, defaulting missing fields to zero/nil.

Source

pub fn new_internal(generation: u64, bytenr: u64, level: u8) -> Self

Create a minimal root item for internal trees (not subvolumes).

Sets generation, bytenr, level, and refs=1. All other fields are zeroed/nil.

Source

pub fn to_bytes(&self) -> Vec<u8>

Serialize to the on-disk byte representation (496 bytes).

Starts with a 160-byte zeroed inode_item, followed by root item fields, padded with zeros to 496 bytes total.

Trait Implementations§

Source§

impl Clone for RootItem

Source§

fn clone(&self) -> RootItem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RootItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.