Struct kdevice::fat::FAT[][src]

pub struct FAT { /* fields omitted */ }
Expand description

TFAT32

Implementations

impl FAT[src]

pub async fn new(ninodes: usize, nbuf: usize, disk: &Arc<Chan>) -> Result<Self>[src]

Initialize a new FAT from a virtual disk.

ninodes is the maximum active inode, nbuf is the number of cached buffer.

pub fn to_inode<'a>(&'a self, path: u64) -> ManuallyDrop<CacheEntry<'a, Self>>[src]

Convert qid to inode pointer.

pub fn to_path<'a>(&'a self, ip: ManuallyDrop<CacheEntry<'a, Self>>) -> u64[src]

Convert inode pointer to unique path id.

pub async fn iget<'a>(
    &'a self,
    key: InodeKey
) -> Option<ManuallyDrop<CacheEntry<'a, Self>>>
[src]

Open and increase the reference of a file.

pub fn iput<'a>(&'a self, ip: ManuallyDrop<CacheEntry<'a, Self>>)[src]

Close and decrease the reference counter of a file.

pub async fn fatrw<'a>(
    &'a self,
    cno: u32,
    f: impl FnOnce(u32) -> u32
) -> Result<u32>
[src]

Read or modify a FAT entry. Return the old value.

If f is None, read the fat value. Otherwise apply f on the value of FAT entry. If failed the FAT entry won’t be updated in both bio cache and log.

Return the old entry value.

pub async fn calloc<'a>(&'a self, n: usize) -> Result<u32>[src]

Allocate a chain of cluster of len n.

Return validated head cluster number.

pub async fn removei<'a>(&'a self, ip: &'a CacheGuard<'a, Self>) -> Result<()>[src]

This should only be called when

  1. No other transactions.
  2. The size of file is within one cluster.
  3. A plain file or empty directory.

Modify at most 2 blocks.

pub async fn stati<'a>(&'a self, ip: &'a CacheGuard<'a, Self>) -> Result<Dirent>[src]

Get the meta information of this file.

pub async fn extend<'a>(&'a self, ip: &mut CacheGuard<'a, Self>) -> Result<()>[src]

Extend the addr pointers.

pub async fn resize<'a>(
    &'a self,
    ip: &mut CacheGuard<'a, Self>,
    f: impl FnOnce(u32) -> u32
) -> Result<u32>
[src]

Modify the size of this file and update its cluster pointers.

Return the new size. For directory, the old size is always a multiple of byte-per-cluster.

pub async fn readi<'a>(
    &'a self,
    ip: &mut CacheGuard<'a, Self>,
    buf: &mut [u8],
    off: usize
) -> Result<usize>
[src]

Read data from inode.

pub async fn writei<'a>(
    &'a self,
    ip: &mut CacheGuard<'a, Self>,
    buf: &[u8],
    off: usize
) -> Result<usize>
[src]

Write data to inode.

pub async fn dirlookup<'a>(
    &'a self,
    dp: &CacheGuard<'a, Self>,
    name: &[u8]
) -> Result<Option<InodeKey>>
[src]

Look up a file in directory. Return a referenced inode.

Create a directory entry with specific inum.

Caller should guarantee then name doesn’t exist in this dir. Return inode if the link succeed. Return None if entry with the same name already exist.

pub async fn dirempty<'a>(
    &'a self,
    dp: &'a CacheGuard<'a, Self>
) -> Result<bool>
[src]

Check if directory is empty.

Trait Implementations

impl Cache for FAT[src]

The inode cache.

type Key = InodeKey

type Value = Inode

fn cache_self<'a>(&'a self) -> &'a Spinlock<CacheData<Self::Key, Self::Value>>[src]

Function used to retrieve the cache.

type GetFut = impl Future<Output = Result<Option<CacheEntry<'a, Self>>>>

fn cache_get<'a>(&'a self, key: Self::Key, flush: bool) -> Self::GetFut[src]

Get a cache item by key. Won’t lock it. If key has already been in memory, this operation always succeed. If cannot reserve cache entry, returns None. Donot implement it. Instead, injected to the trait implementation by super::cache_impl. Read more

fn disk_read<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    _key: &'life1 Self::Key,
    inode: &'life2 mut Self::Value
) -> Self::DiskReadFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

fn disk_write<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    _key: &'life1 Self::Key,
    _ip: &'life2 Self::Value
) -> Self::DiskWriteFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

type DiskReadFuture = impl Future<Output = Result<()>> + 'async_trait

type DiskWriteFuture = impl Future<Output = Result<()>> + 'async_trait

fn new_cache(
    n: usize,
    default_val: impl Fn() -> Result<Self::Value>
) -> Result<Spinlock<CacheData<Self::Key, Self::Value>>>
[src]

Create a new cache with at most n in-memory cache entries. Read more

fn cache_invalidate<'a>(&'a self)[src]

Mark all dirty entry as invalid without synchronizing with disk. May cause inconsistency! Donot implement it. Read more

impl Debug for FAT[src]

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

Formats the value using the given formatter. Read more

impl Device for FAT[src]

fn remove<'life0, 'life1, 'async_trait>(
    &'life0 self,
    c: &'life1 ChanId
) -> Result<Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>, AllocError> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Return false the link is already zero or it is an non-empty directory.

fn shutdown<'async_trait>(
    self
) -> Result<Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>, AllocError> where
    Self: Sized,
    Self: 'async_trait, 
[src]

The async destructor of the device. Read more

fn attach<'life0, 'life1, 'async_trait>(
    &'life0 self,
    aname: &'life1 [u8]
) -> Result<Pin<Box<dyn Future<Output = Result<ChanId>> + Send + 'async_trait>>, AllocError> where
    Self: Sized,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Return the root channel. aname is a user-specified hint.

fn open<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    dir: &'life1 ChanId,
    name: &'life2 [u8],
    create_dir: Option<bool>
) -> Result<Pin<Box<dyn Future<Output = Result<Option<ChanId>>> + Send + 'async_trait>>, AllocError> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Open a file in the directory or reopen a file. Read more

fn close<'life0, 'async_trait>(
    &'life0 self,
    c: ChanId
) -> Result<Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>, AllocError> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Close a file. The drop of channel is done by Chan::close Read more

fn truncate<'life0, 'life1, 'async_trait>(
    &'life0 self,
    c: &'life1 ChanId,
    size: usize
) -> Result<Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>, AllocError> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Reduce the size of a file. Read more

fn stat<'life0, 'life1, 'async_trait>(
    &'life0 self,
    c: &'life1 ChanId
) -> Result<Pin<Box<dyn Future<Output = Result<Dirent>> + Send + 'async_trait>>, AllocError> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Inquires about the file attribute identified by a channel.

fn wstat<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    c: &'life1 ChanId,
    dirent: &'life2 Dirent
) -> Result<Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>, AllocError> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Change the file attribute identified by a channel. Should be atomic.

fn read<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    c: &'life1 ChanId,
    buf: &'life2 mut [u8],
    off: usize
) -> Result<Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>, AllocError> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Read data from a channel by offset and store to buffer. Read more

fn write<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    c: &'life1 ChanId,
    buf: &'life2 [u8],
    off: usize
) -> Result<Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>, AllocError> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Write the data in buffer to a channel starting by specific offset. Directories are not allowed to be written. Read more

Auto Trait Implementations

impl !RefUnwindSafe for FAT

impl Send for FAT

impl Sync for FAT

impl Unpin for FAT

impl !UnwindSafe for FAT

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.