Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Implement mount, umount for basic testcases#21

Merged
Azure-stars merged 7 commits intooscomp:mainfrom
Ressed:impl_mount
Mar 24, 2025
Merged

Implement mount, umount for basic testcases#21
Azure-stars merged 7 commits intooscomp:mainfrom
Ressed:impl_mount

Conversation

@Ressed
Copy link
Copy Markdown

@Ressed Ressed commented Mar 21, 2025

No description provided.

Comment thread src/syscall_imp/fs/mount.rs Outdated
use core::ffi::{c_char, c_void};

pub(crate) fn sys_mount(
source: *const c_char,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use UserPtr struct to wrap the raw pointer passed from user mode

Comment thread src/syscall_imp/fs/mount.rs Outdated
/// check if a path is mounted
pub fn check_mounted(path: &FilePath) -> bool {
let mounted = MOUNTED.lock();
for m in mounted.iter() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify it by rewriting it as

mounted.iter().any(|m| path.starts_with(&m.mnt_dir()))
    .tap(|is_mounted| {
        if is_mounted {
            debug!("{} is mounted", path.as_str());
        }
    })

Comment thread src/syscall_imp/fs/mount.rs Outdated
pub fn umount_fat_fs(mount_path: &FilePath) -> bool {
let mut mounted = MOUNTED.lock();
let mut i = 0;
while i < mounted.len() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can use filter or retain method for iterator to simplify this code

Comment thread src/syscall_imp/fs/mount.rs Outdated
);
return true;
}
// }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove useless comment

Comment thread src/syscall_imp/fs/mount.rs Outdated
Ok(0)
}

pub(crate) fn sys_umount2(target: *const c_char, flags: i32) -> LinuxResult<isize> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add (crate) scope, use pub fn

@Ressed Ressed requested a review from Azure-stars March 23, 2025 12:37
Comment thread src/syscall_imp/fs/mount.rs Outdated
Comment thread src/syscall_imp/fs/mount.rs Outdated
@Azure-stars Azure-stars merged commit 9b4e530 into oscomp:main Mar 24, 2025
25 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants