mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 16:33:24 +00:00
Use SpinLock
on FileTable
for efficiency
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
4a43e317b2
commit
1186fb7ca9
@ -8,6 +8,7 @@ use crate::{
|
||||
|
||||
pub fn sys_lseek(fd: FileDesc, offset: isize, whence: u32, ctx: &Context) -> Result<SyscallReturn> {
|
||||
debug!("fd = {}, offset = {}, whence = {}", fd, offset, whence);
|
||||
|
||||
let seek_from = match whence {
|
||||
0 => {
|
||||
if offset < 0 {
|
||||
@ -19,8 +20,11 @@ pub fn sys_lseek(fd: FileDesc, offset: isize, whence: u32, ctx: &Context) -> Res
|
||||
2 => SeekFrom::End(offset),
|
||||
_ => return_errno!(Errno::EINVAL),
|
||||
};
|
||||
let file_table = ctx.process.file_table().lock();
|
||||
let file = file_table.get_file(fd)?;
|
||||
let file = {
|
||||
let file_table = ctx.process.file_table().lock();
|
||||
file_table.get_file(fd)?.clone()
|
||||
};
|
||||
|
||||
let offset = file.seek(seek_from)?;
|
||||
Ok(SyscallReturn::Return(offset as _))
|
||||
}
|
||||
|
Reference in New Issue
Block a user