pub struct OpenFile {
scheme: DynScheme,
file_id: u64,
path: String,
offset: SpinLock<u64>,
open_flags: OpenFlags,
file_flags: FileFlags,
size: Option<u64>,
}Expand description
An open file handle.
Fields§
§scheme: DynSchemeScheme handling this file.
file_id: u64File ID within the scheme.
path: StringOriginal path (for debugging).
offset: SpinLock<u64>Current read/write offset.
open_flags: OpenFlagsFlags from open().
file_flags: FileFlagsFile properties.
size: Option<u64>Cached file size (if known).
Implementations§
Source§impl OpenFile
impl OpenFile
Sourcepub fn new(
scheme: DynScheme,
file_id: u64,
path: String,
open_flags: OpenFlags,
file_flags: FileFlags,
size: Option<u64>,
) -> Self
pub fn new( scheme: DynScheme, file_id: u64, path: String, open_flags: OpenFlags, file_flags: FileFlags, size: Option<u64>, ) -> Self
Create a new open file.
Sourcepub fn read(&self, buf: &mut [u8]) -> Result<usize, SyscallError>
pub fn read(&self, buf: &mut [u8]) -> Result<usize, SyscallError>
Read from the file at current offset, advancing the offset.
Sourcepub fn write(&self, buf: &[u8]) -> Result<usize, SyscallError>
pub fn write(&self, buf: &[u8]) -> Result<usize, SyscallError>
Write to the file at current offset, advancing the offset.
Sourcepub fn pread(&self, offset: u64, buf: &mut [u8]) -> Result<usize, SyscallError>
pub fn pread(&self, offset: u64, buf: &mut [u8]) -> Result<usize, SyscallError>
Read at a specific offset without changing current offset (pread).
Sourcepub fn pwrite(&self, offset: u64, buf: &[u8]) -> Result<usize, SyscallError>
pub fn pwrite(&self, offset: u64, buf: &[u8]) -> Result<usize, SyscallError>
Write at a specific offset without changing current offset (pwrite).
Sourcepub fn seek(&self, new_offset: u64) -> Result<u64, SyscallError>
pub fn seek(&self, new_offset: u64) -> Result<u64, SyscallError>
Seek to a new offset (absolute).
Sourcepub fn lseek(&self, off: i64, whence: u32) -> Result<u64, SyscallError>
pub fn lseek(&self, off: i64, whence: u32) -> Result<u64, SyscallError>
POSIX lseek: whence=0 SET, 1 CUR, 2 END.
Sourcepub fn size(&self) -> Result<u64, SyscallError>
pub fn size(&self) -> Result<u64, SyscallError>
Get file size.
Sourcepub fn sync(&self) -> Result<(), SyscallError>
pub fn sync(&self) -> Result<(), SyscallError>
Sync file to storage.
Sourcepub fn close(&self) -> Result<(), SyscallError>
pub fn close(&self) -> Result<(), SyscallError>
Signal that this file descriptor is being closed.
Does NOT call scheme.close() directly; the actual scheme close is deferred
to the Drop impl so it fires only when the last Arc
Sourcepub fn open_flags(&self) -> OpenFlags
pub fn open_flags(&self) -> OpenFlags
Get open flags.
Sourcepub fn stat(&self) -> Result<FileStat, SyscallError>
pub fn stat(&self) -> Result<FileStat, SyscallError>
Get file metadata.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OpenFile
impl !RefUnwindSafe for OpenFile
impl !UnwindSafe for OpenFile
impl Send for OpenFile
impl Sync for OpenFile
impl Unpin for OpenFile
impl UnsafeUnpin for OpenFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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