Move rt into sys::rt, fix tidy
This commit is contained in:
parent
01157e6b3c
commit
e55596fa20
18 changed files with 163 additions and 337 deletions
|
|
@ -26,9 +26,8 @@
|
|||
pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count};
|
||||
|
||||
// Reexport the start module on platforms that provide it
|
||||
#[unstable(feature = "start_fn", issue="0")]
|
||||
#[cfg(target_os = "redox")]
|
||||
pub use sys::start::*;
|
||||
#[unstable(feature = "sys_rt", issue="0")]
|
||||
pub use sys::rt::*;
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[lang = "start"]
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ pub mod path;
|
|||
pub mod pipe;
|
||||
pub mod process;
|
||||
pub mod rand;
|
||||
pub mod rt;
|
||||
pub mod rwlock;
|
||||
pub mod stack_overflow;
|
||||
pub mod start;
|
||||
pub mod stdio;
|
||||
pub mod syscall;
|
||||
pub mod thread;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub type in_addr_t = u32;
|
||||
pub type in_port_t = u16;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,18 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Defintion of functions like _start for the linker
|
||||
|
||||
use sys::syscall::exit;
|
||||
|
||||
#[unstable(feature = "start_fn", issue = "0")]
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
#[naked]
|
||||
#[cfg(target_arch = "x86")]
|
||||
|
|
@ -15,7 +27,7 @@ pub unsafe fn _start() {
|
|||
let _ = exit(0);
|
||||
}
|
||||
|
||||
#[unstable(feature = "start_fn", issue = "0")]
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
#[naked]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
|
|
@ -30,7 +42,7 @@ pub unsafe fn _start() {
|
|||
let _ = exit(0);
|
||||
}
|
||||
|
||||
#[unstable(feature = "start_fn", issue = "0")]
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn _start_stack(stack: *const usize){
|
||||
extern "C" {
|
||||
|
|
@ -45,7 +57,7 @@ pub unsafe extern "C" fn _start_stack(stack: *const usize){
|
|||
/// Memcpy
|
||||
///
|
||||
/// Copy N bytes of memory from one location to another.
|
||||
#[unstable(feature = "start_fn", issue = "0")]
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8,
|
||||
n: usize) -> *mut u8 {
|
||||
|
|
@ -61,7 +73,7 @@ pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8,
|
|||
/// Memmove
|
||||
///
|
||||
/// Copy N bytes of memory from src to dest. The memory areas may overlap.
|
||||
#[unstable(feature = "start_fn", issue = "0")]
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn memmove(dest: *mut u8, src: *const u8,
|
||||
n: usize) -> *mut u8 {
|
||||
|
|
@ -85,7 +97,7 @@ pub unsafe extern fn memmove(dest: *mut u8, src: *const u8,
|
|||
/// Memset
|
||||
///
|
||||
/// Fill a block of memory with a specified value.
|
||||
#[unstable(feature = "start_fn", issue = "0")]
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn memset(dest: *mut u8, c: i32, n: usize) -> *mut u8 {
|
||||
let mut i = 0;
|
||||
|
|
@ -100,7 +112,7 @@ pub unsafe extern fn memset(dest: *mut u8, c: i32, n: usize) -> *mut u8 {
|
|||
/// Memcmp
|
||||
///
|
||||
/// Compare two blocks of memory.
|
||||
#[unstable(feature = "start_fn", issue = "0")]
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
|
||||
let mut i = 0;
|
||||
|
|
@ -1,3 +1,13 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use super::error::{Error, Result};
|
||||
|
||||
pub unsafe fn syscall0(mut a: usize) -> Result<usize> {
|
||||
|
|
@ -61,7 +71,8 @@ pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) ->
|
|||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> Result<usize> {
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize)
|
||||
-> Result<usize> {
|
||||
asm!("swi $$0"
|
||||
: "={r0}"(a)
|
||||
: "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d), "{r3}"(e), "{r4}"(f)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use super::error::{Error, Result};
|
||||
|
||||
pub unsafe fn syscall0(mut a: usize) -> Result<usize> {
|
||||
|
|
@ -61,7 +71,8 @@ pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) ->
|
|||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> Result<usize> {
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize)
|
||||
-> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d), "{esi}"(e), "{edi}"(f)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use super::error::{Error, Result};
|
||||
|
||||
pub unsafe fn syscall0(mut a: usize) -> Result<usize> {
|
||||
|
|
@ -25,7 +35,8 @@ pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result<usize> {
|
|||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b)
|
||||
: "memory", "rbx", "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
|
||||
: "memory", "rbx", "rcx", "rdx", "rsi", "rdi", "r8",
|
||||
"r9", "r10", "r11", "r12", "r13", "r14", "r15"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
|
|
@ -61,7 +72,8 @@ pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) ->
|
|||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> Result<usize> {
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize)
|
||||
-> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b), "{rcx}"(c), "{rdx}"(d), "{rsi}"(e), "{rdi}"(f)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use super::arch::*;
|
||||
use super::data::{Stat, StatVfs, TimeSpec};
|
||||
use super::error::Result;
|
||||
|
|
@ -63,7 +73,8 @@ pub fn dup(fd: usize, buf: &[u8]) -> Result<usize> {
|
|||
|
||||
/// Replace the current process with a new executable
|
||||
pub fn execve(path: &str, args: &[[usize; 2]]) -> Result<usize> {
|
||||
unsafe { syscall4(SYS_EXECVE, path.as_ptr() as usize, path.len(), args.as_ptr() as usize, args.len()) }
|
||||
unsafe { syscall4(SYS_EXECVE, path.as_ptr() as usize, path.len(),
|
||||
args.as_ptr() as usize, args.len()) }
|
||||
}
|
||||
|
||||
/// Exit the current process
|
||||
|
|
@ -116,8 +127,9 @@ pub fn ftruncate(fd: usize, len: usize) -> Result<usize> {
|
|||
unsafe { syscall2(SYS_FTRUNCATE, fd, len) }
|
||||
}
|
||||
|
||||
/// Fast userspace mutex - TODO: Document
|
||||
pub unsafe fn futex(addr: *mut i32, op: usize, val: i32, val2: usize, addr2: *mut i32) -> Result<usize> {
|
||||
/// Fast userspace mutex
|
||||
pub unsafe fn futex(addr: *mut i32, op: usize, val: i32, val2: usize, addr2: *mut i32)
|
||||
-> Result<usize> {
|
||||
syscall5(SYS_FUTEX, addr as usize, op, (val as isize) as usize, val2, addr2 as usize)
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +200,8 @@ pub fn mkns(schemes: &[[usize; 2]]) -> Result<usize> {
|
|||
|
||||
/// Sleep for the time specified in `req`
|
||||
pub fn nanosleep(req: &TimeSpec, rem: &mut TimeSpec) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_NANOSLEEP, req as *const TimeSpec as usize, rem as *mut TimeSpec as usize) }
|
||||
unsafe { syscall2(SYS_NANOSLEEP, req as *const TimeSpec as usize,
|
||||
rem as *mut TimeSpec as usize) }
|
||||
}
|
||||
|
||||
/// Open a file
|
||||
|
|
|
|||
|
|
@ -1,60 +1,16 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::{mem, slice};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
pub struct Event {
|
||||
pub id: usize,
|
||||
pub flags: usize,
|
||||
pub data: usize
|
||||
}
|
||||
|
||||
impl Deref for Event {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const Event as *const u8, mem::size_of::<Event>()) as &[u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Event {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut Event as *mut u8, mem::size_of::<Event>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
#[repr(packed)]
|
||||
pub struct Packet {
|
||||
pub id: u64,
|
||||
pub pid: usize,
|
||||
pub uid: u32,
|
||||
pub gid: u32,
|
||||
pub a: usize,
|
||||
pub b: usize,
|
||||
pub c: usize,
|
||||
pub d: usize
|
||||
}
|
||||
|
||||
impl Deref for Packet {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const Packet as *const u8, mem::size_of::<Packet>()) as &[u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Packet {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut Packet as *mut u8, mem::size_of::<Packet>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
#[repr(packed)]
|
||||
pub struct Stat {
|
||||
|
|
@ -87,34 +43,8 @@ impl Deref for Stat {
|
|||
impl DerefMut for Stat {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut Stat as *mut u8, mem::size_of::<Stat>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
#[repr(packed)]
|
||||
pub struct StatVfs {
|
||||
pub f_bsize: u32,
|
||||
pub f_blocks: u64,
|
||||
pub f_bfree: u64,
|
||||
pub f_bavail: u64,
|
||||
//TODO: More fields https://linux.die.net/man/2/statvfs
|
||||
}
|
||||
|
||||
impl Deref for StatVfs {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const StatVfs as *const u8, mem::size_of::<StatVfs>()) as &[u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for StatVfs {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut StatVfs as *mut u8, mem::size_of::<StatVfs>()) as &mut [u8]
|
||||
slice::from_raw_parts_mut(self as *mut Stat as *mut u8,
|
||||
mem::size_of::<Stat>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::{fmt, result};
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub const CLONE_VM: usize = 0x100;
|
||||
pub const CLONE_FS: usize = 0x200;
|
||||
pub const CLONE_FILES: usize = 0x400;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,19 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::arch::*;
|
||||
pub use self::call::*;
|
||||
pub use self::data::*;
|
||||
pub use self::error::*;
|
||||
pub use self::flag::*;
|
||||
pub use self::number::*;
|
||||
pub use self::scheme::*;
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[path="arch/arm.rs"]
|
||||
|
|
@ -32,6 +41,3 @@ pub mod flag;
|
|||
|
||||
/// Call numbers used by each system call
|
||||
pub mod number;
|
||||
|
||||
/// A trait useful for scheme handlers
|
||||
pub mod scheme;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub const SYS_CLASS: usize = 0xF000_0000;
|
||||
pub const SYS_CLASS_PATH: usize=0x1000_0000;
|
||||
pub const SYS_CLASS_FILE: usize=0x2000_0000;
|
||||
|
|
|
|||
|
|
@ -1,232 +0,0 @@
|
|||
use core::{mem, slice};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub trait Scheme {
|
||||
fn handle(&self, packet: &mut Packet) {
|
||||
packet.a = Error::mux(match packet.a {
|
||||
SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid),
|
||||
SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid),
|
||||
SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid),
|
||||
SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid),
|
||||
|
||||
SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
|
||||
SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
|
||||
SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
|
||||
SYS_LSEEK => self.seek(packet.b, packet.c, packet.d),
|
||||
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
|
||||
SYS_FEVENT => self.fevent(packet.b, packet.c),
|
||||
SYS_FMAP => self.fmap(packet.b, packet.c, packet.d),
|
||||
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
|
||||
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() { self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) } else { Err(Error::new(EFAULT)) },
|
||||
SYS_FSTATVFS => if packet.d >= mem::size_of::<StatVfs>() { self.fstatvfs(packet.b, unsafe { &mut *(packet.c as *mut StatVfs) }) } else { Err(Error::new(EFAULT)) },
|
||||
SYS_FSYNC => self.fsync(packet.b),
|
||||
SYS_FTRUNCATE => self.ftruncate(packet.b, packet.c),
|
||||
SYS_CLOSE => self.close(packet.b),
|
||||
|
||||
_ => Err(Error::new(ENOSYS))
|
||||
});
|
||||
}
|
||||
|
||||
/* Scheme operations */
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn open(&self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn rmdir(&self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn unlink(&self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
/* Resource operations */
|
||||
#[allow(unused_variables)]
|
||||
fn dup(&self, old_id: usize, buf: &[u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn read(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn write(&self, id: usize, buf: &[u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn seek(&self, id: usize, pos: usize, whence: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fcntl(&self, id: usize, cmd: usize, arg: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fevent(&self, id: usize, flags: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fmap(&self, id: usize, offset: usize, size: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fstat(&self, id: usize, stat: &mut Stat) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fstatvfs(&self, id: usize, stat: &mut StatVfs) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fsync(&self, id: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn ftruncate(&self, id: usize, len: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn close(&self, id: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SchemeMut {
|
||||
fn handle(&mut self, packet: &mut Packet) {
|
||||
packet.a = Error::mux(match packet.a {
|
||||
SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid),
|
||||
SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid),
|
||||
SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid),
|
||||
SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid),
|
||||
|
||||
SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
|
||||
SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
|
||||
SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
|
||||
SYS_LSEEK => self.seek(packet.b, packet.c, packet.d),
|
||||
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
|
||||
SYS_FEVENT => self.fevent(packet.b, packet.c),
|
||||
SYS_FMAP => self.fmap(packet.b, packet.c, packet.d),
|
||||
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
|
||||
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() { self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) } else { Err(Error::new(EFAULT)) },
|
||||
SYS_FSTATVFS => if packet.d >= mem::size_of::<StatVfs>() { self.fstatvfs(packet.b, unsafe { &mut *(packet.c as *mut StatVfs) }) } else { Err(Error::new(EFAULT)) },
|
||||
SYS_FSYNC => self.fsync(packet.b),
|
||||
SYS_FTRUNCATE => self.ftruncate(packet.b, packet.c),
|
||||
SYS_CLOSE => self.close(packet.b),
|
||||
|
||||
_ => Err(Error::new(ENOSYS))
|
||||
});
|
||||
}
|
||||
|
||||
/* Scheme operations */
|
||||
#[allow(unused_variables)]
|
||||
fn open(&mut self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn rmdir(&mut self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn unlink(&mut self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
/* Resource operations */
|
||||
#[allow(unused_variables)]
|
||||
fn dup(&mut self, old_id: usize, buf: &[u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn read(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn write(&mut self, id: usize, buf: &[u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn seek(&mut self, id: usize, pos: usize, whence: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fcntl(&mut self, id: usize, cmd: usize, arg: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fevent(&mut self, id: usize, flags: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fmap(&mut self, id: usize, offset: usize, size: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fstat(&mut self, id: usize, stat: &mut Stat) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fstatvfs(&self, id: usize, stat: &mut StatVfs) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fsync(&mut self, id: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn ftruncate(&mut self, id: usize, len: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn close(&mut self, id: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
}
|
||||
|
|
@ -50,6 +50,7 @@ pub mod path;
|
|||
pub mod pipe;
|
||||
pub mod process;
|
||||
pub mod rand;
|
||||
pub mod rt;
|
||||
pub mod rwlock;
|
||||
pub mod stack_overflow;
|
||||
pub mod thread;
|
||||
|
|
|
|||
11
src/libstd/sys/unix/rt.rs
Normal file
11
src/libstd/sys/unix/rt.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Stub for placing functions like _start for the linker
|
||||
|
|
@ -36,6 +36,7 @@ pub mod path;
|
|||
pub mod pipe;
|
||||
pub mod process;
|
||||
pub mod rand;
|
||||
pub mod rt;
|
||||
pub mod rwlock;
|
||||
pub mod stack_overflow;
|
||||
pub mod thread;
|
||||
|
|
|
|||
11
src/libstd/sys/windows/rt.rs
Normal file
11
src/libstd/sys/windows/rt.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Stub for placing functions like _start for the linker
|
||||
Loading…
Add table
Add a link
Reference in a new issue