1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-21 23:56:18 +04:00

Now ready to use busybox sh for user shell

This commit is contained in:
Jiajie Chen 2019-04-17 08:16:02 +08:00
parent 1bba33a05f
commit ff50a45396
8 changed files with 48 additions and 14 deletions

4
kernel/Cargo.lock generated
View File

@ -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)",

View File

@ -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)
}
}

View File

@ -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)?;
}

View File

@ -69,7 +69,7 @@ macro_rules! impl_inode {
fn move_(&self, _old_name: &str, _target: &Arc<INode>, _new_name: &str) -> Result<()> { Err(FsError::NotDir) }
fn find(&self, _name: &str) -> Result<Arc<INode>> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<String> { 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<FileSystem> { unimplemented!() }
fn as_any_ref(&self) -> &Any { self }
};

View File

@ -62,12 +62,20 @@ macro_rules! impl_inode {
fn move_(&self, _old_name: &str, _target: &Arc<INode>, _new_name: &str) -> Result<()> { Err(FsError::NotDir) }
fn find(&self, _name: &str) -> Result<Arc<INode>> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<String> { 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)
}
}

View File

@ -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);

View File

@ -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;
}
}

2
user

@ -1 +1 @@
Subproject commit fdaa1be8635944d88ff128da13bf0464f7ce2eb6
Subproject commit 8dbc0edb935a62d748aaac39258d4a985de0ae17