Refactor Dentry to optimize the vfs layer

This commit is contained in:
Shaowei Song
2024-10-10 12:51:26 +00:00
committed by Tate, Hongliang Tian
parent 271e893889
commit ea489252f4
14 changed files with 177 additions and 175 deletions

View File

@ -58,7 +58,7 @@ fn lookup_executable_file(
filename: String,
flags: OpenFlags,
ctx: &Context,
) -> Result<Arc<Dentry>> {
) -> Result<Dentry> {
let fs_resolver = ctx.process.fs().read();
let dentry = if flags.contains(OpenFlags::AT_EMPTY_PATH) && filename.is_empty() {
fs_resolver.lookup_from_fd(dfd)
@ -79,7 +79,7 @@ fn lookup_executable_file(
}
fn do_execve(
elf_file: Arc<Dentry>,
elf_file: Dentry,
argv_ptr_ptr: Vaddr,
envp_ptr_ptr: Vaddr,
ctx: &Context,
@ -193,7 +193,7 @@ fn read_cstring_vec(
fn set_uid_from_elf(
current: &Process,
credentials: &Credentials<WriteOp>,
elf_file: &Arc<Dentry>,
elf_file: &Dentry,
) -> Result<()> {
if elf_file.mode()?.has_set_uid() {
let uid = elf_file.owner()?;
@ -211,7 +211,7 @@ fn set_uid_from_elf(
fn set_gid_from_elf(
current: &Process,
credentials: &Credentials<WriteOp>,
elf_file: &Arc<Dentry>,
elf_file: &Dentry,
) -> Result<()> {
if elf_file.mode()?.has_set_gid() {
let gid = elf_file.group()?;

View File

@ -83,7 +83,7 @@ fn do_remount() -> Result<()> {
/// Such as use user command `mount --rbind src dst`.
fn do_bind_mount(
src_name: CString,
dst_dentry: Arc<Dentry>,
dst_dentry: Dentry,
recursive: bool,
ctx: &Context,
) -> Result<()> {
@ -109,7 +109,7 @@ fn do_change_type() -> Result<()> {
}
/// Move a mount from src location to dst location.
fn do_move_mount_old(src_name: CString, dst_dentry: Arc<Dentry>, ctx: &Context) -> Result<()> {
fn do_move_mount_old(src_name: CString, dst_dentry: Dentry, ctx: &Context) -> Result<()> {
let src_dentry = {
let src_name = src_name.to_string_lossy();
if src_name.is_empty() {
@ -135,7 +135,7 @@ fn do_move_mount_old(src_name: CString, dst_dentry: Arc<Dentry>, ctx: &Context)
fn do_new_mount(
devname: CString,
fs_type: Vaddr,
target_dentry: Arc<Dentry>,
target_dentry: Dentry,
ctx: &Context,
) -> Result<()> {
if target_dentry.type_() != InodeType::Dir {

View File

@ -109,7 +109,7 @@ struct Utimbuf {
modtime: i64,
}
fn vfs_utimes(dentry: &Arc<Dentry>, times: Option<TimeSpecPair>) -> Result<SyscallReturn> {
fn vfs_utimes(dentry: &Dentry, times: Option<TimeSpecPair>) -> Result<SyscallReturn> {
let (atime, mtime, ctime) = match times {
Some(times) => {
if !times.atime.is_valid() || !times.mtime.is_valid() {