diff --git a/kernel/Cargo.lock b/kernel/Cargo.lock index 7ca71d53..4848e5e3 100644 --- a/kernel/Cargo.lock +++ b/kernel/Cargo.lock @@ -402,12 +402,12 @@ dependencies = [ [[package]] name = "rcore-fs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs#d7a2006cc316c98b7050aec63a2770dd690a4a80" +source = "git+https://github.com/rcore-os/rcore-fs#64d399fe664927f14853c22943a4bdeb34095f99" [[package]] name = "rcore-fs-sfs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs#d7a2006cc316c98b7050aec63a2770dd690a4a80" +source = "git+https://github.com/rcore-os/rcore-fs#64d399fe664927f14853c22943a4bdeb34095f99" dependencies = [ "bitvec 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/kernel/src/fs/file.rs b/kernel/src/fs/file.rs index dfb291fa..5e1b84f2 100644 --- a/kernel/src/fs/file.rs +++ b/kernel/src/fs/file.rs @@ -113,7 +113,7 @@ impl FileHandle { self.inode.poll() } - pub fn io_control(&self, cmd: u32, arg: u32) -> Result<()> { + pub fn io_control(&self, cmd: u32, arg: usize) -> Result<()> { self.inode.io_control(cmd, arg) } } diff --git a/kernel/src/fs/file_like.rs b/kernel/src/fs/file_like.rs index 47a3cc69..32c5cdcc 100644 --- a/kernel/src/fs/file_like.rs +++ b/kernel/src/fs/file_like.rs @@ -31,7 +31,7 @@ impl FileLike { } pub fn ioctl(&mut self, request: usize, arg1: usize, arg2: usize, arg3: usize) -> SysResult { match self { - FileLike::File(file) => file.io_control(request as u32, arg1 as u32)?, + FileLike::File(file) => file.io_control(request as u32, arg1)?, FileLike::Socket(socket) => { socket.ioctl(request, arg1, arg2, arg3)?; } diff --git a/kernel/src/fs/pipe.rs b/kernel/src/fs/pipe.rs index c0c50eac..88073807 100644 --- a/kernel/src/fs/pipe.rs +++ b/kernel/src/fs/pipe.rs @@ -69,7 +69,7 @@ macro_rules! impl_inode { fn move_(&self, _old_name: &str, _target: &Arc, _new_name: &str) -> Result<()> { Err(FsError::NotDir) } fn find(&self, _name: &str) -> Result> { Err(FsError::NotDir) } fn get_entry(&self, _id: usize) -> Result { Err(FsError::NotDir) } - fn io_control(&self, _cmd: u32, _data: u32) -> Result<()> { Err(FsError::NotSupported) } + fn io_control(&self, _cmd: u32, _data: usize) -> Result<()> { Err(FsError::NotSupported) } fn fs(&self) -> Arc { unimplemented!() } fn as_any_ref(&self) -> &Any { self } }; diff --git a/kernel/src/fs/stdio.rs b/kernel/src/fs/stdio.rs index 3fc60621..62500114 100644 --- a/kernel/src/fs/stdio.rs +++ b/kernel/src/fs/stdio.rs @@ -62,12 +62,20 @@ macro_rules! impl_inode { fn move_(&self, _old_name: &str, _target: &Arc, _new_name: &str) -> Result<()> { Err(FsError::NotDir) } fn find(&self, _name: &str) -> Result> { Err(FsError::NotDir) } fn get_entry(&self, _id: usize) -> Result { Err(FsError::NotDir) } - fn io_control(&self, cmd: u32, data: u32) -> Result<()> { + fn io_control(&self, cmd: u32, data: usize) -> Result<()> { match cmd { - TCGETS | TIOCGWINSZ | TIOCGPGRP | TIOCSPGRP => { + TCGETS | TIOCGWINSZ | TIOCSPGRP => { // pretend to be tty Ok(()) }, + TIOCGPGRP => { + // pretend to be have a tty process group + // TODO: verify pointer + unsafe { + *(data as *mut u32) = 0 + }; + Ok(()) + } _ => Err(FsError::NotSupported) } } diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 7381d4b8..4ad87e73 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -72,9 +72,7 @@ pub fn sys_ppoll(ufds: *mut PollFd, nfds: usize, timeout: *const TimeSpec) -> Sy 1 << 31 // infinity } else { proc.vm.check_read_ptr(timeout)?; - unsafe { - (*timeout).to_msec() - } + unsafe { (*timeout).to_msec() } }; drop(proc); diff --git a/kernel/src/syscall/proc.rs b/kernel/src/syscall/proc.rs index 6f33cf83..81876289 100644 --- a/kernel/src/syscall/proc.rs +++ b/kernel/src/syscall/proc.rs @@ -24,11 +24,12 @@ pub fn sys_clone( newtls: usize, tf: &TrapFrame, ) -> SysResult { + let clone_flags = CloneFlags::from_bits_truncate(flags); info!( - "clone: flags: {:#x}, newsp: {:#x}, parent_tid: {:?}, child_tid: {:?}, newtls: {:#x}", - flags, newsp, parent_tid, child_tid, newtls + "clone: flags: {:?}, newsp: {:#x}, parent_tid: {:?}, child_tid: {:?}, newtls: {:#x}", + clone_flags, newsp, parent_tid, child_tid, newtls ); - if flags == 0x4111 { + if flags == 0x4111 || flags == 0x11 { warn!("sys_clone is calling sys_fork instead, ignoring other args"); return sys_fork(tf); } @@ -317,3 +318,30 @@ pub fn sys_set_priority(priority: usize) -> SysResult { processor().manager().set_priority(pid, priority as u8); Ok(0) } + +bitflags! { + pub struct CloneFlags: usize { + const CSIGNAL = 0x000000ff; + const VM = 0x0000100; + const FS = 0x0000200; + const FILES = 0x0000400; + const SIGHAND = 0x0000800; + const PTRACE = 0x0002000; + const VFORK = 0x0004000; + const PARENT = 0x0008000; + const SYSVSEM = 0x0008000; + const SETTLS = 0x0008000; + const PARENT_SETTID = 0x0010000; + const CHILD_CLEARTID = 0x0020000; + const DETACHED = 0x0040000; + const UNTRACED = 0x0080000; + const CHILD_SETTID = 0x0100000; + const NEWCGROUP = 0x0200000; + const NEWUTS = 0x0400000; + const NEWIPC = 0x0800000; + const NEWUSER = 0x1000000; + const NEWPID = 0x2000000; + const NEWNET = 0x4000000; + const IO = 0x8000000; + } +} diff --git a/user b/user index fdaa1be8..8dbc0edb 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit fdaa1be8635944d88ff128da13bf0464f7ce2eb6 +Subproject commit 8dbc0edb935a62d748aaac39258d4a985de0ae17