Inode

Struct Inode 

Source
pub struct Inode {
    pub header: InodeHeader,
    pub extra: Option<InodeExtraAttr>,
    pub inline_data: Option<Box<[u8]>>,
    pub footer: InodeFooter,
    pub xattr: Vec<XattrEntry>,
    pub context: Option<Context>,
    pub block_addrs: Vec<u32>,
    /* private fields */
}
Expand description

Inode represents a file or directory and consumes one 4kB block in the metadata region.

An Inode’s basic layout is as follows: +–––––––+ | InodeHeader | +–––––––+ | i_addrs[923] | +–––––––+ | nids[5] | +–––––––+ | InodeFooter | +–––––––+

The i_addrs region consists of 32-bit block addresses to data associated with the inode. Some or all of this may be repurposed for optional structures based on header flags:

  • extra: Contains additional metadata. Consumes the first 9 entries of i_addrs.
  • xattr: Extended attributes. Consumes the last 50 entries of i_addrs.
  • inline_data: Consumes all remaining i_addrs. If used, no external data blocks are used.
  • inline_dentry: Consumes all remaining i_addrs. If used, no external data blocks are used.

For inodes that do not contain inline data or inline dentry, the remaining i_addrs[] list the block offsets for data blocks that contain the contents of the inode. A value of NULL_ADDR indicates a zero page. A value of NEW_ADDR indicates a page that has not yet been allocated and should be treated the same as a zero page for our purposes.

If a file contains more data than available i_addrs[], nids[] will be used.

nids[0] and nids[1] are what F2fs called “direct node” blocks. These contain nids (i.e. NAT translated block addresses) to RawAddrBlock. Each RawAddrBlock contains up to 1018 block offsets to data blocks.

If that is insufficient, nids[2] and nids[3] contain what F2fs calls “indirect node” blocks. This is the same format as RawAddrBlock but each entry contains the nid of another RawAddrBlock, providing another layer of indirection and thus the ability to reference 1018^2 further blocks.

Finally, nids[4] may point at a “double indirect node” block. This adds one more layer of indirection, allowing for a further 1018^3 blocks.

For sparse files, any individual blocks or pages of blocks (at any indirection level) may be replaced with NULL_ADDR.

Block addressing starts at i_addrs and flows through each of nids[0..5] in order.

Fields§

§header: InodeHeader§extra: Option<InodeExtraAttr>§inline_data: Option<Box<[u8]>>§footer: InodeFooter§xattr: Vec<XattrEntry>§context: Option<Context>§block_addrs: Vec<u32>

Implementations§

Source§

impl Inode

Source

pub fn get_inline_dir_entries( &self, is_encrypted: bool, is_casefolded: bool, decryptor: &Option<PerFileDecryptor>, ) -> Result<Option<Vec<DirEntry>>, Error>

Source§

impl Inode

Source

pub fn data_blocks(&self) -> DataBlocksIter<'_>

Walks through the data blocks of the file in order, handling sparse regions. Emits extents of (logical_block_num, physical_block_num, length).

Source

pub fn data_block_addr(&self, block_num: u32) -> u32

Get the address of a specific logical data block. NULL_ADDR and NEW_ADDR should be considered sparse (unallocated) zero blocks.

Trait Implementations§

Source§

impl Debug for Inode

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Inode

§

impl RefUnwindSafe for Inode

§

impl Send for Inode

§

impl Sync for Inode

§

impl Unpin for Inode

§

impl UnwindSafe for Inode

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
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. 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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V