Add read_at and write_at for FileLike and InodeHandle

This commit is contained in:
Jianfeng Jiang
2024-05-15 11:03:59 +00:00
committed by Tate, Hongliang Tian
parent 6e9516daa4
commit 14ada9000a
3 changed files with 67 additions and 14 deletions

View File

@ -23,6 +23,23 @@ pub trait FileLike: Send + Sync + Any {
return_errno_with_message!(Errno::EINVAL, "write is not supported");
}
/// Read at the given file offset.
///
/// The file must be seekable to support `read_at`.
/// Unlike [`read`], `read_at` will not change the file offset.
fn read_at(&self, offset: usize, buf: &mut [u8]) -> Result<usize> {
return_errno_with_message!(Errno::EINVAL, "read_at is not supported");
}
/// Write at the given file offset.
///
/// The file must be seekable to support `write_at`.
/// Unlike [`write`], `write_at` will not change the file offset.
/// If the file is append-only, the `offset` will be ignored.
fn write_at(&self, offset: usize, buf: &[u8]) -> Result<usize> {
return_errno_with_message!(Errno::EINVAL, "write_at is not supported");
}
fn ioctl(&self, cmd: IoctlCmd, arg: usize) -> Result<i32> {
return_errno_with_message!(Errno::EINVAL, "ioctl is not supported");
}