Selaa lähdekoodia

feat: impl several more syscalls, bump linux version to 5.17

greatbridf 7 kuukautta sitten
vanhempi
commit
82260f8ed8
2 muutettua tiedostoa jossa 23 lisäystä ja 9 poistoa
  1. 15 7
      src/kernel/syscall/file_rw.rs
  2. 8 2
      src/kernel/syscall/sysinfo.rs

+ 15 - 7
src/kernel/syscall/file_rw.rs

@@ -383,13 +383,14 @@ fn writev(fd: FD, iov_user: *const IoVec, iovcnt: u32) -> KResult<usize> {
     Ok(tot)
 }
 
-#[cfg(target_arch = "x86_64")]
-#[eonix_macros::define_syscall(SYS_ACCESS)]
-fn access(pathname: *const u8, _mode: u32) -> KResult<()> {
-    let path = UserString::new(pathname)?;
-    let path = Path::new(path.as_cstr().to_bytes())?;
-
-    let dentry = Dentry::open(&thread.fs_context, path, true)?;
+#[eonix_macros::define_syscall(SYS_FACCESSAT)]
+fn faccessat(dirfd: FD, pathname: *const u8, _mode: u32, flags: AtFlags) -> KResult<()> {
+    let dentry = if flags.at_empty_path() {
+        let file = thread.files.get(dirfd).ok_or(EBADF)?;
+        file.as_path().ok_or(EBADF)?.clone()
+    } else {
+        dentry_from(thread, dirfd, pathname, !flags.no_follow())?
+    };
 
     if !dentry.is_valid() {
         return Err(ENOENT);
@@ -403,9 +404,16 @@ fn access(pathname: *const u8, _mode: u32) -> KResult<()> {
     //     X_OK => todo!(),
     //     _ => Err(EINVAL),
     // }
+
     Ok(())
 }
 
+#[cfg(target_arch = "x86_64")]
+#[eonix_macros::define_syscall(SYS_ACCESS)]
+fn access(pathname: *const u8, mode: u32) -> KResult<()> {
+    sys_faccessat(thread, FD::AT_FDCWD, pathname, mode, AtFlags::empty())
+}
+
 #[eonix_macros::define_syscall(SYS_SENDFILE64)]
 fn sendfile64(out_fd: FD, in_fd: FD, offset: *mut u8, count: usize) -> KResult<usize> {
     let in_file = thread.files.get(in_fd).ok_or(EBADF)?;

+ 8 - 2
src/kernel/syscall/sysinfo.rs

@@ -40,9 +40,15 @@ fn newuname(buffer: *mut NewUTSName) -> KResult<()> {
     // Linux compatible
     copy_cstr_to_array(b"Linux", &mut uname.sysname);
     copy_cstr_to_array(b"(none)", &mut uname.nodename);
-    copy_cstr_to_array(b"1.0.0", &mut uname.release);
-    copy_cstr_to_array(b"1.0.0", &mut uname.version);
+    copy_cstr_to_array(b"5.17.1", &mut uname.release);
+    copy_cstr_to_array(b"eonix 1.1.4", &mut uname.version);
+
+    #[cfg(target_arch = "x86_64")]
     copy_cstr_to_array(b"x86", &mut uname.machine);
+
+    #[cfg(target_arch = "riscv64")]
+    copy_cstr_to_array(b"riscv64", &mut uname.machine);
+
     copy_cstr_to_array(b"(none)", &mut uname.domainname);
 
     buffer.write(uname)