mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 02:13:24 +00:00
Make the file lookup faster
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
fb8f493b43
commit
b9ce3e64ad
@ -1,7 +1,10 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{fs::file_table::FileDesc, prelude::*};
|
||||
use crate::{
|
||||
fs::file_table::{get_file_fast, FileDesc},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
pub fn sys_read(
|
||||
fd: FileDesc,
|
||||
@ -14,10 +17,8 @@ pub fn sys_read(
|
||||
fd, user_buf_addr, buf_len
|
||||
);
|
||||
|
||||
let file = {
|
||||
let file_table = ctx.posix_thread.file_table().lock();
|
||||
file_table.get_file(fd)?.clone()
|
||||
};
|
||||
let mut file_table = ctx.thread_local.file_table().borrow_mut();
|
||||
let file = get_file_fast!(&mut file_table, fd);
|
||||
|
||||
// According to <https://man7.org/linux/man-pages/man2/read.2.html>, if
|
||||
// the user specified an empty buffer, we should detect errors by checking
|
||||
|
Reference in New Issue
Block a user