Superblock

Struct Superblock 

Source
pub struct Superblock {
    pub magic: [u8; 4],
    pub version: u32,
    pub root_inode: InodeId,
    pub next_inode: InodeId,
    pub next_block: BlockId,
    pub total_inodes: u64,
    pub total_blocks: u64,
    pub block_size: u32,
    pub created_us: u64,
    pub mounted_us: u64,
    pub label: String,
}
Expand description

Superblock - filesystem metadata

Fields§

§magic: [u8; 4]

Magic number for identification

§version: u32

Filesystem version

§root_inode: InodeId

Root inode number

§next_inode: InodeId

Next free inode number

§next_block: BlockId

Next free block number

§total_inodes: u64

Total inodes allocated

§total_blocks: u64

Total blocks used

§block_size: u32

Block size in bytes

§created_us: u64

Creation time

§mounted_us: u64

Last mount time

§label: String

Filesystem label

Implementations§

Source§

impl Superblock

Source

pub const MAGIC: [u8; 4]

Source

pub const VERSION: u32 = 1

Source

pub const DEFAULT_BLOCK_SIZE: u32 = 4096

Source

pub fn new(label: impl Into<String>) -> Self

Source

pub fn alloc_inode(&mut self) -> InodeId

Allocate a new inode number

Source

pub fn alloc_blocks(&mut self, count: u64) -> Vec<BlockId>

Allocate block numbers

Source

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

Serialize to bytes

Source

pub fn from_bytes(data: &[u8]) -> Result<Self, String>

Deserialize from bytes

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
Source§

impl<'de> Deserialize<'de> for Superblock

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Superblock

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,