pub struct File {
pub node: Arc<dyn VfsNode>,
pub flags: OpenFlags,
pub nonblock: AtomicBool,
pub position: RwLock<usize>,
pub refcount: RwLock<usize>,
pub path: Option<String>,
}Expand description
Open file structure
Fields§
§node: Arc<dyn VfsNode>VFS node this file refers to
flags: OpenFlagsOpen flags
nonblock: AtomicBoolNon-blocking I/O flag (can be toggled via fcntl F_SETFL after open). Stored as AtomicBool because File is behind Arc and F_SETFL needs to toggle this without mutable access.
position: RwLock<usize>Current position in file
refcount: RwLock<usize>Reference count
path: Option<String>Absolute path this file was opened with (for dirfd resolution in *at syscalls)
Implementations§
Source§impl File
impl File
Sourcepub fn new_with_path(
node: Arc<dyn VfsNode>,
flags: OpenFlags,
path: String,
) -> Self
pub fn new_with_path( node: Arc<dyn VfsNode>, flags: OpenFlags, path: String, ) -> Self
Create a new file structure with a known path
Sourcepub fn read(&self, buffer: &mut [u8]) -> Result<usize, KernelError>
pub fn read(&self, buffer: &mut [u8]) -> Result<usize, KernelError>
Read from the file
Sourcepub fn write(&self, data: &[u8]) -> Result<usize, KernelError>
pub fn write(&self, data: &[u8]) -> Result<usize, KernelError>
Write to the file
Sourcepub fn seek(&self, from: SeekFrom) -> Result<usize, KernelError>
pub fn seek(&self, from: SeekFrom) -> Result<usize, KernelError>
Seek to a position in the file