From 3e7dd81dec5121fda7f606d0912ad489b82cfae7 Mon Sep 17 00:00:00 2001 From: Yuhao Zhou Date: Wed, 17 Apr 2019 17:37:28 +0800 Subject: [PATCH] Add lstat, fix timespec for musln32. --- kernel/src/syscall/fs.rs | 14 +++++++++++--- kernel/src/syscall/mod.rs | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 7035b31..1017332 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -3,6 +3,7 @@ use core::cell::UnsafeCell; use core::cmp::min; use core::mem::size_of; +#[cfg(not(target_arch = "mips"))] use rcore_fs::vfs::Timespec; use crate::drivers::SOCKET_ACTIVITY; @@ -913,6 +914,13 @@ pub struct Stat { ctime: Timespec, } +#[cfg(target_arch = "mips")] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] +pub struct Timespec { + pub sec: i32, + pub nsec: i32, +} + #[cfg(target_arch = "mips")] #[repr(C)] #[derive(Debug)] @@ -1096,9 +1104,9 @@ impl From for Stat { size: info.size as u64, blksize: info.blk_size as u32, blocks: info.blocks as u64, - atime: info.atime, - mtime: info.mtime, - ctime: info.ctime, + atime: Timespec { sec: info.atime.sec as i32, nsec: info.atime.nsec }, + mtime: Timespec { sec: info.mtime.sec as i32, nsec: info.mtime.nsec }, + ctime: Timespec { sec: info.ctime.sec as i32, nsec: info.ctime.nsec }, __pad1: 0, __pad2: 0, __pad3: 0, diff --git a/kernel/src/syscall/mod.rs b/kernel/src/syscall/mod.rs index 86666ba..49051ec 100644 --- a/kernel/src/syscall/mod.rs +++ b/kernel/src/syscall/mod.rs @@ -324,6 +324,7 @@ fn mips_syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> Option sys_dup2(args[0], args[1]), SYS_MMAP2 => sys_mmap(args[0], args[1], args[2], args[3], args[4], args[5] * 4096), SYS_FSTAT64 => sys_fstat(args[0], args[1] as *mut Stat), + SYS_LSTAT64 => sys_lstat(args[0] as *const u8, args[1] as *mut Stat), SYS_STAT64 => sys_stat(args[0] as *const u8, args[1] as *mut Stat), SYS_PIPE => { let fd_ptr = args[0] as *mut u32;