# Struct os::fs::easy_fs::layout::DiskInode

source · [−]

    #[repr(C)]pub struct DiskInode {
        pub size: u32,
        pub direct: [u32; 28],
        pub indirect1: u32,
        pub indirect2: u32,
        type_: DiskInodeType,
    }

## Fields

`size: u32` `direct: [u32; 28]` `indirect1: u32` `indirect2: u32` `type_: DiskInodeType`

## Implementations

source

### impl DiskInode

source

#### pub fn initialize(&mut self, type_: DiskInodeType)

indirect1 and indirect2 block are allocated only when they are needed.

source

#### pub fn is_dir(&self) -> bool

source

#### pub fn is_file(&self) -> bool

source

#### pub fn data_blocks(&self) -> u32

Return block number correspond to size.

source

#### fn _data_blocks(size: u32) -> u32

source

#### pub fn total_blocks(size: u32) -> u32

Return number of blocks needed include indirect1/2.

source

#### pub fn blocks_num_needed(&self, new_size: u32) -> u32

source

#### pub fn get_block_id(
&self,
inner_id: u32,
block_device: &Arc<dyn BlockDevice>
) -> u32

source

#### pub fn increase_size(
&mut self,
new_size: u32,
new_blocks: Vec<u32>,
block_device: &Arc<dyn BlockDevice>
)

source

#### pub fn clear_size(&mut self, block_device: &Arc<dyn BlockDevice>) -> Vec<u32>

Clear size to zero and return blocks that should be deallocated.

We will clear the block contents to zero later.

source

#### pub fn read_at(
&self,
offset: usize,
buf: &mut [ u8 ],
block_device: &Arc<dyn BlockDevice>
) -> usize

source

#### pub fn write_at(
&mut self,
offset: usize,
buf: &[ u8 ],
block_device: &Arc<dyn BlockDevice>
) -> usize

File size must be adjusted before.

## Auto Trait Implementations

### impl RefUnwindSafe for DiskInode

### impl Send for DiskInode

### impl Sync for DiskInode

### impl Unpin for DiskInode

### impl UnwindSafe for DiskInode

## Blanket Implementations

source

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

source

#### pub fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more

source

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

source

#### pub fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

source

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

source

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

Mutably borrows from an owned value. Read more

source

### impl<T> From<T> for T

source

#### pub fn from(t: T) -> T

Performs the conversion.

source

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

source

#### pub fn into(self) -> U

Performs the conversion.

source

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

#### type Error = Infallible

The type returned in the event of a conversion error.

source

#### pub 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>,

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

The type returned in the event of a conversion error.

source

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

Performs the conversion.