pub trait AdvancedFileStructs {
// Required methods
fn create(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>;
fn mkdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>;
fn unlink(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>;
fn chdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>;
fn readdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>;
fn stat(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>;
fn fsync(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>;
}Expand description
A trait for extending file operation functionality.
This trait provides implementations for file system-related system calls
that operate on files and directories. Each method corresponds to a
specific system call, handling user-space arguments via SyscallAbi
and returning either success or a KernelError on failure.
Required Methods§
Sourcefn create(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn create(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Creates a new empty file in the current directory.
§Syscall API
int create(const char *pathname);pathname: Path of the new file to create.
Returns 0 on success.
Sourcefn mkdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn mkdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Creates a new directory in the current working directory.
§Syscall API
int mkdir(const char *pathname);pathname: Path of the new directory to create.
Returns 0 on success.
Sourcefn unlink(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn unlink(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Removes a file from the file system.
§Syscall API
int unlink(const char *pathname);pathname: Path of the file to remove.
Returns 0 on success.
Sourcefn chdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn chdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Changes the current working directory.
§Syscall API
int chdir(const char *pathname);pathname: Path of the directory to change to.
Returns 0 on success.
Sourcefn readdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn readdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Reads directory entries from the current directory.
§Syscall API
ssize_t readdir(int fd, struct dentry *buf, size_t count);fd: File descriptor of the directory to read from.buf: a pointer to the array of the dentries.count: the number of entries in the array.
Returns the number of entries read into the buffer.
Sourcefn stat(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn stat(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Retrieves file metadata.
§Syscall API
int stat(const char *pathname, struct stat *buf);pathname: Path of the file or directory.buf: Buffer to store the metadata.
Returns 0 on success.
Sourcefn fsync(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn fsync(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Synchronizes in-memory file contents to disk.
§Syscall API
int fsync(int fd);fd: File descriptor of the file to synchronize.
Returns 0 on success.
Implementations on Foreign Types§
Source§impl AdvancedFileStructs for FileStruct
impl AdvancedFileStructs for FileStruct
Source§fn create(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn create(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Creates a new empty file in the current directory.
§Syscall API
int create(const char *pathname);pathname: Path of the new file to create.
Returns 0 on success.
Source§fn mkdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn mkdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Creates a new directory in the current working directory.
§Syscall API
int mkdir(const char *pathname);pathname: Path of the new directory to create.
Returns 0 on success.
Source§fn unlink(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn unlink(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Removes a file from the file system.
§Syscall API
int unlink(const char *pathname);pathname: Path of the file to remove.
Returns 0 on success.
Source§fn chdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn chdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Changes the current working directory.
§Syscall API
int chdir(const char *pathname);pathname: Path of the directory to change to.
Returns 0 on success.
Source§fn readdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn readdir(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Reads directory entries from the current directory.
§Syscall API
ssize_t readdir(int fd, struct dentry *buf, size_t count);fd: File descriptor of the directory to read from.buf: a pointer to the array of the dentries.count: the number of entries in the array.
Returns the number of entries read into the buffer.
Source§fn stat(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn stat(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Retrieves file metadata.
§Syscall API
int stat(const char *pathname, struct stat *buf);pathname: Path of the file or directory.buf: Buffer to store the metadata.
Returns 0 on success.
Source§fn fsync(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
fn fsync(&mut self, abi: &SyscallAbi<'_>) -> Result<usize, KernelError>
Synchronizes in-memory file contents to disk.
§Syscall API
int fsync(int fd);fd: File descriptor of the file to synchronize.
Returns 0 on success.