Skip to main content

Superblock

Struct Superblock 

Source
pub struct Superblock {
Show 35 fields pub csum: [u8; 32], pub fsid: Uuid, pub bytenr: u64, pub flags: u64, pub magic: u64, pub generation: u64, pub root: u64, pub chunk_root: u64, pub log_root: u64, pub log_root_transid: u64, pub total_bytes: u64, pub bytes_used: u64, pub root_dir_objectid: u64, pub num_devices: u64, pub sectorsize: u32, pub nodesize: u32, pub leafsize: u32, pub stripesize: u32, pub sys_chunk_array_size: u32, pub chunk_root_generation: u64, pub compat_flags: u64, pub compat_ro_flags: u64, pub incompat_flags: u64, pub csum_type: ChecksumType, pub root_level: u8, pub chunk_root_level: u8, pub log_root_level: u8, pub dev_item: DeviceItem, pub label: String, pub cache_generation: u64, pub uuid_tree_generation: u64, pub metadata_uuid: Uuid, pub nr_global_roots: u64, pub backup_roots: [BackupRoot; 4], pub sys_chunk_array: [u8; 2048],
}
Expand description

Parsed btrfs superblock.

The superblock is the entry point for reading a btrfs filesystem. It lives at a fixed offset on each device (see super_mirror_offset) and contains the root pointers, feature flags, and embedded system chunk array needed to bootstrap access to all other on-disk structures.

Fields§

§csum: [u8; 32]

Checksum of everything past this field (bytes 32..4096).

§fsid: Uuid

Filesystem UUID. Shared by all devices in a multi-device filesystem.

§bytenr: u64

Physical byte offset where this superblock is stored on disk.

§flags: u64

Superblock flags (BTRFS_SUPER_FLAG_*).

§magic: u64

Magic number (_BHRfS_M). See Superblock::magic_is_valid.

§generation: u64

Transaction generation of this superblock write.

§root: u64

Logical bytenr of the root tree root block.

§chunk_root: u64

Logical bytenr of the chunk tree root block.

§log_root: u64

Logical bytenr of the log tree root block (0 if no log tree).

§log_root_transid: u64

Transaction ID of the log tree root.

§total_bytes: u64

Total usable bytes across all devices.

§bytes_used: u64

Total bytes used by data and metadata.

§root_dir_objectid: u64

Objectid of the root directory (always 6).

§num_devices: u64

Number of devices in this filesystem.

§sectorsize: u32

Minimum I/O alignment (typically 4096).

§nodesize: u32

Size of tree blocks in bytes (typically 16384).

§leafsize: u32

Legacy field, equal to nodesize in modern filesystems.

§stripesize: u32

Stripe size for RAID (typically 65536).

§sys_chunk_array_size: u32

Number of valid bytes in the sys_chunk_array.

§chunk_root_generation: u64

Generation of the chunk tree root.

§compat_flags: u64

Compatible feature flags.

§compat_ro_flags: u64

Compatible read-only feature flags.

§incompat_flags: u64

Incompatible feature flags (e.g. MIXED_GROUPS, SKINNY_METADATA).

§csum_type: ChecksumType

Checksum algorithm for this filesystem.

§root_level: u8

B-tree level of the root tree root.

§chunk_root_level: u8

B-tree level of the chunk tree root.

§log_root_level: u8

B-tree level of the log tree root.

§dev_item: DeviceItem

Embedded device item describing this device.

§label: String

Filesystem label (up to 255 bytes, NUL-terminated on disk).

§cache_generation: u64

Generation when the free space cache was written (v1 cache).

§uuid_tree_generation: u64

Generation when the UUID tree was last updated.

§metadata_uuid: Uuid

Metadata UUID (differs from fsid when METADATA_UUID incompat flag is set).

§nr_global_roots: u64

Number of global root entries (extent-tree-v2, not yet used).

§backup_roots: [BackupRoot; 4]

Four rotating backup copies of critical tree root pointers.

§sys_chunk_array: [u8; 2048]

Embedded chunk tree entries for bootstrapping the chunk cache.

Implementations§

Source§

impl Superblock

Source

pub fn magic_is_valid(&self) -> bool

Whether the magic bytes match BTRFS_MAGIC.

Source

pub fn has_metadata_uuid(&self) -> bool

Whether the METADATA_UUID incompat flag is set.

Source

pub fn to_bytes(&self) -> [u8; 4096]

Serialize the superblock to a 4096-byte buffer.

The checksum field is written as-is from self.csum; call csum_superblock on the result to recompute it.

Trait Implementations§

Source§

impl Clone for Superblock

Source§

fn clone(&self) -> Superblock

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 Superblock

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.