mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-27 03:13:23 +00:00
Refactor DentryMnt and fix some issues
Signed-off-by: Zhenchen Wang <m202372036@hust.edu.cn>
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
60fa4d104a
commit
8d18a12385
@ -28,21 +28,21 @@ pub fn sys_ftruncate(fd: FileDesc, len: isize) -> Result<SyscallReturn> {
|
||||
|
||||
pub fn sys_truncate(path_ptr: Vaddr, len: isize) -> Result<SyscallReturn> {
|
||||
log_syscall_entry!(SYS_TRUNCATE);
|
||||
let pathname = read_cstring_from_user(path_ptr, PATH_MAX)?;
|
||||
debug!("pathname = {:?}, length = {}", pathname, len);
|
||||
let path = read_cstring_from_user(path_ptr, PATH_MAX)?;
|
||||
debug!("path = {:?}, length = {}", path, len);
|
||||
|
||||
check_length(len)?;
|
||||
|
||||
let current = current!();
|
||||
let dir_dentrymnt = {
|
||||
let pathname = pathname.to_string_lossy();
|
||||
if pathname.is_empty() {
|
||||
let path = path.to_string_lossy();
|
||||
if path.is_empty() {
|
||||
return_errno_with_message!(Errno::ENOENT, "path is empty");
|
||||
}
|
||||
let fs_path = FsPath::new(AT_FDCWD, pathname.as_ref())?;
|
||||
let fs_path = FsPath::new(AT_FDCWD, path.as_ref())?;
|
||||
current.fs().read().lookup(&fs_path)?
|
||||
};
|
||||
dir_dentrymnt.dentry().resize(len as usize)?;
|
||||
dir_dentrymnt.resize(len as usize)?;
|
||||
Ok(SyscallReturn::Return(0))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user