Move FS things to PosixThread

This commit is contained in:
Ruihan Li
2024-12-01 11:41:23 +08:00
committed by Tate, Hongliang Tian
parent fe7e4884c9
commit 36fc1d3757
65 changed files with 268 additions and 215 deletions

View File

@ -11,7 +11,7 @@ pub fn sys_chdir(path_ptr: Vaddr, ctx: &Context) -> Result<SyscallReturn> {
let path = ctx.user_space().read_cstring(path_ptr, MAX_FILENAME_LEN)?;
debug!("path = {:?}", path);
let mut fs = ctx.process.fs().write();
let mut fs = ctx.posix_thread.fs().resolver().write();
let dentry = {
let path = path.to_string_lossy();
if path.is_empty() {
@ -31,7 +31,7 @@ pub fn sys_fchdir(fd: FileDesc, ctx: &Context) -> Result<SyscallReturn> {
debug!("fd = {}", fd);
let dentry = {
let file_table = ctx.process.file_table().lock();
let file_table = ctx.posix_thread.file_table().lock();
let file = file_table.get_file(fd)?;
let inode_handle = file
.downcast_ref::<InodeHandle>()
@ -41,6 +41,6 @@ pub fn sys_fchdir(fd: FileDesc, ctx: &Context) -> Result<SyscallReturn> {
if dentry.type_() != InodeType::Dir {
return_errno_with_message!(Errno::ENOTDIR, "must be directory");
}
ctx.process.fs().write().set_cwd(dentry);
ctx.posix_thread.fs().resolver().write().set_cwd(dentry);
Ok(SyscallReturn::Return(0))
}