实现SYS_LINK和SYS_LINKAT (#611)

* 实现do_linkat及SYS_LINK和SYS_LINKAT

* 未在riscv上测试,添加target_arch

* 将c字符串检查移动到vfs/syscall.rs,修改do_linkat()逻辑

* 修改部分注释
This commit is contained in:
Chenzx
2024-03-22 18:27:07 +08:00
committed by GitHub
parent 70f159a398
commit 4695947e1b
3 changed files with 125 additions and 1 deletions

View File

@ -345,6 +345,21 @@ impl Syscall {
Self::rmdir(path)
}
SYS_LINK => {
let old = args[0] as *const u8;
let new = args[1] as *const u8;
return Self::link(old, new);
}
SYS_LINKAT => {
let oldfd = args[0] as i32;
let old = args[1] as *const u8;
let newfd = args[2] as i32;
let new = args[3] as *const u8;
let flags = args[4] as i32;
return Self::linkat(oldfd, old, newfd, new, flags);
}
#[cfg(target_arch = "x86_64")]
SYS_UNLINK => {
let path = args[0] as *const u8;

View File

@ -65,9 +65,10 @@
#define SYS_CHDIR 80
#define SYS_MKDIR 83
#define SYS_RMDIR 84
#define SYS_LINK 86
#define SYS_GETTIMEOFDAY 96
#define SYS_ARCH_PRCTL 158
@ -86,6 +87,8 @@
#define SYS_UNLINK_AT 263
#define SYS_LINKAT 265
#define SYS_PIPE 293
#define SYS_WRITEV 20