rcore-os / rCore-Tutorial-Book-v3

A book about how to write OS kernels in Rust easily.
https://rcore-os.github.io/rCore-Tutorial-Book-v3/
GNU General Public License v3.0
1.23k stars 233 forks source link

rCore-Tutorial-Book-v3/chapter6/1fs-interface #123

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

文件系统接口 — rCore-Tutorial-Book-v3 3.6.0-alpha.1 文档

https://rcore-os.github.io/rCore-Tutorial-Book-v3/chapter6/1fs-interface.html

MrZLeo commented 2 years ago
pub fn sys_openat(dirfd: usize, path: &str, flags: u32, mode: u32) -> isize {
    syscall6(
        SYSCALL_OPENAT, [dirfd, path.as_ptr() as usize, flags as usize, mode as usize, 0, 0]
    )
}

syscall6() syscall()

jklincn commented 2 years ago
pub fn sys_openat(dirfd: usize, path: &str, flags: u32, mode: u32) -> isize {
    syscall6(
        SYSCALL_OPENAT, [dirfd, path.as_ptr() as usize, flags as usize, mode as usize, 0, 0]
    )
}

应该改成这样?

pub fn sys_open(path: &str, flags: u32) -> isize {
    syscall(SYSCALL_OPEN, [path.as_ptr() as usize, flags as usize, 0])
}
jklincn commented 2 years ago

在打开文件,对文件完成了读写操作后,还需要关闭文件,这样才让进程释放杯这个文件所占用的内核资源。

杯 -> 被

chyyuu commented 2 years ago

在打开文件,对文件完成了读写操作后,还需要关闭文件,这样才让进程释放杯这个文件所占用的内核资源。

杯 -> 被

已经修改。谢谢!

chyyuu commented 2 years ago
pub fn sys_openat(dirfd: usize, path: &str, flags: u32, mode: u32) -> isize {
    syscall6(
        SYSCALL_OPENAT, [dirfd, path.as_ptr() as usize, flags as usize, mode as usize, 0, 0]
    )
}

~syscall6()~ syscall()

已经修改。谢谢!

chyyuu commented 2 years ago
pub fn sys_openat(dirfd: usize, path: &str, flags: u32, mode: u32) -> isize {
    syscall6(
        SYSCALL_OPENAT, [dirfd, path.as_ptr() as usize, flags as usize, mode as usize, 0, 0]
    )
}

应该改成这样?

pub fn sys_open(path: &str, flags: u32) -> isize {
    syscall(SYSCALL_OPEN, [path.as_ptr() as usize, flags as usize, 0])
}

已经修改。谢谢!

Co1lin commented 2 years ago

关于文件夹的权限,可以参考 https://unix.stackexchange.com/a/21263