mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-18 20:16:42 +00:00
Unseekable files need not to manipulate the offset
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
92680ea25d
commit
9638744712
@ -48,6 +48,10 @@ impl InodeHandle_ {
|
||||
return file_io.read(writer);
|
||||
}
|
||||
|
||||
if !self.dentry.inode().is_seekable() {
|
||||
return self.read_at(0, writer);
|
||||
}
|
||||
|
||||
let mut offset = self.offset.lock();
|
||||
|
||||
let len = self.read_at(*offset, writer)?;
|
||||
@ -61,6 +65,10 @@ impl InodeHandle_ {
|
||||
return file_io.write(reader);
|
||||
}
|
||||
|
||||
if !self.dentry.inode().is_seekable() {
|
||||
return self.write_at(0, reader);
|
||||
}
|
||||
|
||||
let mut offset = self.offset.lock();
|
||||
|
||||
if self.status_flags().contains(StatusFlags::O_APPEND) {
|
||||
|
@ -1189,6 +1189,13 @@ impl Inode for RamInode {
|
||||
return_errno_with_message!(Errno::EINVAL, "ioctl is not supported");
|
||||
}
|
||||
|
||||
fn is_seekable(&self) -> bool {
|
||||
!matches!(
|
||||
self.typ,
|
||||
InodeType::NamedPipe | InodeType::CharDevice | InodeType::Dir | InodeType::Socket
|
||||
)
|
||||
}
|
||||
|
||||
fn extension(&self) -> Option<&Extension> {
|
||||
Some(&self.extension)
|
||||
}
|
||||
|
@ -426,6 +426,10 @@ pub trait Inode: Any + Sync + Send {
|
||||
true
|
||||
}
|
||||
|
||||
fn is_seekable(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Get the extension of this inode
|
||||
fn extension(&self) -> Option<&Extension> {
|
||||
None
|
||||
|
Reference in New Issue
Block a user