summaryrefslogtreecommitdiffstats
path: root/vendor/redox_syscall
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/redox_syscall
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/redox_syscall')
-rw-r--r--vendor/redox_syscall/.cargo-checksum.json2
-rw-r--r--vendor/redox_syscall/Cargo.toml2
-rw-r--r--vendor/redox_syscall/src/call.rs15
-rw-r--r--vendor/redox_syscall/src/data.rs59
-rw-r--r--vendor/redox_syscall/src/error.rs6
-rw-r--r--vendor/redox_syscall/src/flag.rs40
-rw-r--r--vendor/redox_syscall/src/io/mmio.rs129
-rw-r--r--vendor/redox_syscall/src/number.rs20
-rwxr-xr-xvendor/redox_syscall/src/scheme/generate.sh2
-rw-r--r--vendor/redox_syscall/src/scheme/mod.rs50
-rw-r--r--vendor/redox_syscall/src/scheme/scheme.rs72
-rw-r--r--vendor/redox_syscall/src/scheme/scheme_block.rs72
-rw-r--r--vendor/redox_syscall/src/scheme/scheme_block_mut.rs72
-rw-r--r--vendor/redox_syscall/src/scheme/scheme_mut.rs72
-rw-r--r--vendor/redox_syscall/src/tests.rs26
15 files changed, 420 insertions, 219 deletions
diff --git a/vendor/redox_syscall/.cargo-checksum.json b/vendor/redox_syscall/.cargo-checksum.json
index 72e27feeb..5f5e9d559 100644
--- a/vendor/redox_syscall/.cargo-checksum.json
+++ b/vendor/redox_syscall/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"80db3d7e545f9b8a04804e634948c6e80c712f051680b2e7a39ddb848c200151","LICENSE":"efcfee7981ff72431fffb06925cad00a23dce079ed4354f61030ad5abdb78829","README.md":"9161f18ba7f69b4ca51e844aee8ffb8237513a468c5c3b1f3a5f989044f895ac","src/arch/aarch64.rs":"9b4cf7da1f001ce54bfd01b7a001dbc8043c1ef89823781a2a1070e2c096a9ce","src/arch/nonredox.rs":"1055cd441f4b95c9ec428222a7796c7fac953a8a500ca08173743ea95220aab3","src/arch/riscv64.rs":"20bf9a8db779059773b113643d0cb3737fbb5d57f45ee39b8ae9d3396b6ef636","src/arch/x86.rs":"cf01f4d798e8861ad5b9429714c947e2d7c53a3cb9a13d53dc7a38e4bdad4101","src/arch/x86_64.rs":"fd80c9a412d07c85f2b942f36de364edfff7cd49f6c00c043e69becb7c76119f","src/call.rs":"141bdb2cb64dc118beadf40fc8180cd32e41841c8d7db71aed646a5a8ab9fac3","src/data.rs":"bd4545d4c2fcc59ff26ae52ad7f773a697d5ccf639a2ffc253cece6b31e94d51","src/error.rs":"ef20f3817f997a1aeb7114628407f19cb8bc13c555d4e093918f38a5d098f798","src/flag.rs":"aad91126a0bb3413cd103fc38b457aa4d1f6b949605e3ae249aea0dfec8504ff","src/io/dma.rs":"85577342547afaac0dc46740dfeb9d2e4239d8809b86748c3fcaa12f922b1c9d","src/io/io.rs":"e1d454ff47efac70fdaa709251a5a9c1c5637f931994ba3bf6a38c6db9145822","src/io/mmio.rs":"12d0fb4d4f45097bf2c14f73cb1ce21325eae193b537e9f18af73ed5281b5e63","src/io/mod.rs":"79c2fce4fd6d75f3b9169df64b7a605feff31fab2e5ed81984ae085a1d07c0c4","src/io/pio.rs":"9ee6f2229b700d1c45b4c8c6242bd99fe69634e16dcd5843d9e8d1c958047406","src/lib.rs":"25c9f35cf709e7e50336ae12f0390f968cc11515f93b6d757825a7b7725eeadb","src/number.rs":"773d9f55a98c6ae5b4cb08b396568f05f8d9b187a7609b7a1c5dd940f6ee674a","src/scheme/generate.sh":"dde4e30f4e0223fb1a24ed486a6c36e624c854dbf890862cb6866f4fa3c7a6eb","src/scheme/mod.rs":"cb622405deb0aef4ab04499ea1adfd338c9c5dd9c31a1fe9989786dbf69b49d8","src/scheme/scheme.rs":"2e27e08e3b9005a5705fadd10a6160a570322c873d1b6477f269e0beae35f046","src/scheme/scheme_block.rs":"a8d0137e106dcb605367bfc6a22b83317142996b7e410c832de0f63a423d5305","src/scheme/scheme_block_mut.rs":"b6cea44a3e79dd6c30b4280b6913a215628918978451efe11f31b0d7eddd44a5","src/scheme/scheme_mut.rs":"e77da9d5208de101c126eca9fa685f2b78a5ddc4890ad5f5f4d79ded3bbd8fbd","src/scheme/seek.rs":"94e044de47b0f00eb0c2aea3fb21001ac2b9aa1e4b20d73fd54163fe92fa63f7","src/tests.rs":"b44de69251d6bcc1cb796147a1212fffd3ac7d5796d9a0d2265db0aac8a909df"},"package":"567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"} \ No newline at end of file
+{"files":{"Cargo.toml":"91d2cdde6f3eaad21dc8f0d8879b0572d92b0eca34fd2dcac26ccc00c50b6839","LICENSE":"efcfee7981ff72431fffb06925cad00a23dce079ed4354f61030ad5abdb78829","README.md":"9161f18ba7f69b4ca51e844aee8ffb8237513a468c5c3b1f3a5f989044f895ac","src/arch/aarch64.rs":"9b4cf7da1f001ce54bfd01b7a001dbc8043c1ef89823781a2a1070e2c096a9ce","src/arch/nonredox.rs":"1055cd441f4b95c9ec428222a7796c7fac953a8a500ca08173743ea95220aab3","src/arch/riscv64.rs":"20bf9a8db779059773b113643d0cb3737fbb5d57f45ee39b8ae9d3396b6ef636","src/arch/x86.rs":"cf01f4d798e8861ad5b9429714c947e2d7c53a3cb9a13d53dc7a38e4bdad4101","src/arch/x86_64.rs":"fd80c9a412d07c85f2b942f36de364edfff7cd49f6c00c043e69becb7c76119f","src/call.rs":"1630ef687b0de538e19e7408d79c55177e61a7a7c8a2693da9bd01e5358a9a8e","src/data.rs":"cff635f60875977935e1b243aff638ef2193aa05a73fc1399964e55225eb3934","src/error.rs":"c8cacebca86e388e2ef12ac504818d7c1bc16df5d89fcabc1dfc9839e7c3aecf","src/flag.rs":"0505c4ed82970109d83ef01100c40d0fee344919d10f5a78957fc20706f8e228","src/io/dma.rs":"85577342547afaac0dc46740dfeb9d2e4239d8809b86748c3fcaa12f922b1c9d","src/io/io.rs":"e1d454ff47efac70fdaa709251a5a9c1c5637f931994ba3bf6a38c6db9145822","src/io/mmio.rs":"ab64f0bee9d13ebcfc21d0125f6c973f460f582cbc3d566d00491fe1ac714127","src/io/mod.rs":"79c2fce4fd6d75f3b9169df64b7a605feff31fab2e5ed81984ae085a1d07c0c4","src/io/pio.rs":"9ee6f2229b700d1c45b4c8c6242bd99fe69634e16dcd5843d9e8d1c958047406","src/lib.rs":"25c9f35cf709e7e50336ae12f0390f968cc11515f93b6d757825a7b7725eeadb","src/number.rs":"c0463c7f8eb3f3d16062efb0e65472b22f81821329af2ed8271fdddfa70f3e8b","src/scheme/generate.sh":"2eed5d6a382cd3daa31ccaa7c80b1995258f9126462228191b41f32e7af958a2","src/scheme/mod.rs":"acdd7526d6477288c47efc2a4c310d9a9fef8795cad4358c54aba0763ae2fcd2","src/scheme/scheme.rs":"860526f02cb8cab0d1a996079c9ef5d9440b45796429c4376e00d253b4d3ba51","src/scheme/scheme_block.rs":"6afebd8f3d6dd2716236e63bfd3943f5d6725e29aac392ce0e21101fd4578a82","src/scheme/scheme_block_mut.rs":"ed2d27e7519f437a42d32cbd80e33c4b9446cd90d3e6dbd82e3509a41e92acb7","src/scheme/scheme_mut.rs":"1d2e2ad31da6622ef80493c3670909fe8179306081bbc7f450b24528e6ef23d8","src/scheme/seek.rs":"94e044de47b0f00eb0c2aea3fb21001ac2b9aa1e4b20d73fd54163fe92fa63f7","src/tests.rs":"0fb2355fe625188a348fbae8c23fa622d4a08c6378a56ff40d3ef54ed78884b9"},"package":"4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"} \ No newline at end of file
diff --git a/vendor/redox_syscall/Cargo.toml b/vendor/redox_syscall/Cargo.toml
index ab14e3fe8..c9fda075e 100644
--- a/vendor/redox_syscall/Cargo.toml
+++ b/vendor/redox_syscall/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "redox_syscall"
-version = "0.3.5"
+version = "0.4.1"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
description = "A Rust library to access raw Redox system calls"
documentation = "https://docs.rs/redox_syscall"
diff --git a/vendor/redox_syscall/src/call.rs b/vendor/redox_syscall/src/call.rs
index bc1af0dc2..87ba8a980 100644
--- a/vendor/redox_syscall/src/call.rs
+++ b/vendor/redox_syscall/src/call.rs
@@ -264,21 +264,6 @@ pub unsafe fn physmap(physical_address: usize, size: usize, flags: PhysmapFlags)
syscall3(SYS_PHYSMAP, physical_address, size, flags.bits())
}
-/// Unmap previously mapped physical memory
-///
-/// # Errors
-///
-/// * `EPERM` - `uid != 0`
-/// * `EFAULT` - `virtual_address` has not been mapped
-pub unsafe fn physunmap(virtual_address: usize) -> Result<usize> {
- syscall1(SYS_PHYSUNMAP, virtual_address)
-}
-
-/// Create a pair of file descriptors referencing the read and write ends of a pipe
-pub fn pipe2(fds: &mut [usize; 2], flags: usize) -> Result<usize> {
- unsafe { syscall2(SYS_PIPE2, fds.as_ptr() as usize, flags) }
-}
-
/// Read from a file descriptor into a buffer
pub fn read(fd: usize, buf: &mut [u8]) -> Result<usize> {
unsafe { syscall3(SYS_READ, fd, buf.as_mut_ptr() as usize, buf.len()) }
diff --git a/vendor/redox_syscall/src/data.rs b/vendor/redox_syscall/src/data.rs
index 45d2dd862..c93869793 100644
--- a/vendor/redox_syscall/src/data.rs
+++ b/vendor/redox_syscall/src/data.rs
@@ -149,6 +149,24 @@ pub struct SigAction {
pub sa_mask: [u64; 2],
pub sa_flags: SigActionFlags,
}
+impl Deref for SigAction {
+ type Target = [u8];
+ fn deref(&self) -> &[u8] {
+ unsafe {
+ slice::from_raw_parts(self as *const SigAction as *const u8,
+ mem::size_of::<SigAction>())
+ }
+ }
+}
+
+impl DerefMut for SigAction {
+ fn deref_mut(&mut self) -> &mut [u8] {
+ unsafe {
+ slice::from_raw_parts_mut(self as *mut SigAction as *mut u8,
+ mem::size_of::<SigAction>())
+ }
+ }
+}
#[allow(dead_code)]
unsafe fn _assert_size_of_function_is_sane() {
@@ -295,3 +313,44 @@ macro_rules! ptrace_event {
}
}
}
+
+bitflags::bitflags! {
+ #[derive(Default)]
+ pub struct GrantFlags: usize {
+ const GRANT_READ = 0x0000_0001;
+ const GRANT_WRITE = 0x0000_0002;
+ const GRANT_EXEC = 0x0000_0004;
+
+ const GRANT_SHARED = 0x0000_0008;
+ const GRANT_LAZY = 0x0000_0010;
+ const GRANT_SCHEME = 0x0000_0020;
+ const GRANT_PHYS = 0x0000_0040;
+ const GRANT_PINNED = 0x0000_0080;
+ }
+}
+
+#[derive(Clone, Copy, Debug, Default)]
+#[repr(C)]
+pub struct GrantDesc {
+ pub base: usize,
+ pub size: usize,
+ pub flags: GrantFlags,
+ pub offset: u64,
+}
+
+impl Deref for GrantDesc {
+ type Target = [u8];
+ fn deref(&self) -> &[u8] {
+ unsafe {
+ slice::from_raw_parts(self as *const GrantDesc as *const u8, mem::size_of::<GrantDesc>())
+ }
+ }
+}
+
+impl DerefMut for GrantDesc {
+ fn deref_mut(&mut self) -> &mut [u8] {
+ unsafe {
+ slice::from_raw_parts_mut(self as *mut GrantDesc as *mut u8, mem::size_of::<GrantDesc>())
+ }
+ }
+}
diff --git a/vendor/redox_syscall/src/error.rs b/vendor/redox_syscall/src/error.rs
index 9a4b0b5ad..5cc0bfc33 100644
--- a/vendor/redox_syscall/src/error.rs
+++ b/vendor/redox_syscall/src/error.rs
@@ -176,8 +176,9 @@ pub const EKEYREVOKED: i32 = 128; /* Key has been revoked */
pub const EKEYREJECTED: i32 = 129; /* Key was rejected by service */
pub const EOWNERDEAD: i32 = 130; /* Owner died */
pub const ENOTRECOVERABLE: i32 = 131; /* State not recoverable */
+pub const ESKMSG: i32 = 132; /* Scheme-kernel message code */
-pub static STR_ERROR: [&'static str; 132] = ["Success",
+pub static STR_ERROR: [&'static str; 133] = ["Success",
"Operation not permitted",
"No such file or directory",
"No such process",
@@ -308,4 +309,5 @@ pub static STR_ERROR: [&'static str; 132] = ["Success",
"Key has been revoked",
"Key was rejected by service",
"Owner died",
- "State not recoverable"];
+ "State not recoverable",
+ "Scheme-kernel message code"];
diff --git a/vendor/redox_syscall/src/flag.rs b/vendor/redox_syscall/src/flag.rs
index 341104856..45a6e42e8 100644
--- a/vendor/redox_syscall/src/flag.rs
+++ b/vendor/redox_syscall/src/flag.rs
@@ -54,9 +54,18 @@ pub const FUTEX_WAKE: usize = 1;
pub const FUTEX_REQUEUE: usize = 2;
pub const FUTEX_WAIT64: usize = 3;
+// packet.c = fd
+pub const SKMSG_FRETURNFD: usize = 0;
+
+// packet.uid:packet.gid = offset, packet.c = base address, packet.d = page count
+pub const SKMSG_PROVIDE_MMAP: usize = 1;
+
bitflags! {
pub struct MapFlags: usize {
+ // TODO: Downgrade PROT_NONE to global constant? (bitflags specifically states zero flags
+ // can cause buggy behavior).
const PROT_NONE = 0x0000_0000;
+
const PROT_EXEC = 0x0001_0000;
const PROT_WRITE = 0x0002_0000;
const PROT_READ = 0x0004_0000;
@@ -64,9 +73,30 @@ bitflags! {
const MAP_SHARED = 0x0001;
const MAP_PRIVATE = 0x0002;
- /// Only accepted for mmap2(2).
const MAP_FIXED = 0x0004;
const MAP_FIXED_NOREPLACE = 0x000C;
+
+ /// For *userspace-backed mmaps*, return from the mmap call before all pages have been
+ /// provided by the scheme. This requires the scheme to be trusted, as the current context
+ /// can block indefinitely, if the scheme does not respond to the page fault handler's
+ /// request, as it tries to map the page by requesting it from the scheme.
+ ///
+ /// In some cases however, such as the program loader, the data needs to be trusted as much
+ /// with or without MAP_LAZY, and if so, mapping lazily will not cause insecureness by
+ /// itself.
+ ///
+ /// For kernel-backed mmaps, this flag has no effect at all. It is unspecified whether
+ /// kernel mmaps are lazy or not.
+ const MAP_LAZY = 0x0010;
+ }
+}
+bitflags! {
+ pub struct MunmapFlags: usize {
+ /// Indicates whether the funmap call must implicitly do an msync, for the changes to
+ /// become visible later.
+ ///
+ /// This flag will currently be set if and only if MAP_SHARED | PROT_WRITE are set.
+ const NEEDS_SYNC = 1;
}
}
@@ -334,3 +364,11 @@ pub fn wexitstatus(status: usize) -> usize {
pub fn wcoredump(status: usize) -> bool {
(status & 0x80) != 0
}
+
+bitflags! {
+ pub struct MremapFlags: usize {
+ const FIXED = 1;
+ const FIXED_REPLACE = 3;
+ // TODO: MAYMOVE, DONTUNMAP
+ }
+}
diff --git a/vendor/redox_syscall/src/io/mmio.rs b/vendor/redox_syscall/src/io/mmio.rs
index 3966ab454..ef8f60391 100644
--- a/vendor/redox_syscall/src/io/mmio.rs
+++ b/vendor/redox_syscall/src/io/mmio.rs
@@ -1,5 +1,6 @@
-use core::ptr::{read_volatile, write_volatile, addr_of, addr_of_mut};
use core::mem::MaybeUninit;
+use core::ptr;
+#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
use core::ops::{BitAnd, BitOr, Not};
use super::io::Io;
@@ -32,14 +33,136 @@ impl<T> Mmio<T> {
}
}
+// Generic implementation (WARNING: requires aligned pointers!)
+#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
impl<T> Io for Mmio<T> where T: Copy + PartialEq + BitAnd<Output = T> + BitOr<Output = T> + Not<Output = T> {
type Value = T;
fn read(&self) -> T {
- unsafe { read_volatile(addr_of!(self.value).cast::<T>()) }
+ unsafe { ptr::read_volatile(ptr::addr_of!(self.value).cast::<T>()) }
}
fn write(&mut self, value: T) {
- unsafe { write_volatile(addr_of_mut!(self.value).cast::<T>(), value) };
+ unsafe { ptr::write_volatile(ptr::addr_of_mut!(self.value).cast::<T>(), value) };
+ }
+}
+
+// x86 u8 implementation
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+impl Io for Mmio<u8> {
+ type Value = u8;
+
+ fn read(&self) -> Self::Value {
+ unsafe {
+ let value: Self::Value;
+ let ptr: *const Self::Value = ptr::addr_of!(self.value).cast::<Self::Value>();
+ core::arch::asm!(
+ "mov {}, [{}]",
+ out(reg_byte) value,
+ in(reg) ptr
+ );
+ value
+ }
+ }
+
+ fn write(&mut self, value: Self::Value) {
+ unsafe {
+ let ptr: *mut Self::Value = ptr::addr_of_mut!(self.value).cast::<Self::Value>();
+ core::arch::asm!(
+ "mov [{}], {}",
+ in(reg) ptr,
+ in(reg_byte) value,
+ );
+ }
+ }
+}
+
+// x86 u16 implementation
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+impl Io for Mmio<u16> {
+ type Value = u16;
+
+ fn read(&self) -> Self::Value {
+ unsafe {
+ let value: Self::Value;
+ let ptr: *const Self::Value = ptr::addr_of!(self.value).cast::<Self::Value>();
+ core::arch::asm!(
+ "mov {:x}, [{}]",
+ out(reg) value,
+ in(reg) ptr
+ );
+ value
+ }
+ }
+
+ fn write(&mut self, value: Self::Value) {
+ unsafe {
+ let ptr: *mut Self::Value = ptr::addr_of_mut!(self.value).cast::<Self::Value>();
+ core::arch::asm!(
+ "mov [{}], {:x}",
+ in(reg) ptr,
+ in(reg) value,
+ );
+ }
+ }
+}
+
+// x86 u32 implementation
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+impl Io for Mmio<u32> {
+ type Value = u32;
+
+ fn read(&self) -> Self::Value {
+ unsafe {
+ let value: Self::Value;
+ let ptr: *const Self::Value = ptr::addr_of!(self.value).cast::<Self::Value>();
+ core::arch::asm!(
+ "mov {:e}, [{}]",
+ out(reg) value,
+ in(reg) ptr
+ );
+ value
+ }
+ }
+
+ fn write(&mut self, value: Self::Value) {
+ unsafe {
+ let ptr: *mut Self::Value = ptr::addr_of_mut!(self.value).cast::<Self::Value>();
+ core::arch::asm!(
+ "mov [{}], {:e}",
+ in(reg) ptr,
+ in(reg) value,
+ );
+ }
+ }
+}
+
+// x86 u64 implementation (x86_64 only)
+#[cfg(target_arch = "x86_64")]
+impl Io for Mmio<u64> {
+ type Value = u64;
+
+ fn read(&self) -> Self::Value {
+ unsafe {
+ let value: Self::Value;
+ let ptr: *const Self::Value = ptr::addr_of!(self.value).cast::<Self::Value>();
+ core::arch::asm!(
+ "mov {:r}, [{}]",
+ out(reg) value,
+ in(reg) ptr
+ );
+ value
+ }
+ }
+
+ fn write(&mut self, value: Self::Value) {
+ unsafe {
+ let ptr: *mut Self::Value = ptr::addr_of_mut!(self.value).cast::<Self::Value>();
+ core::arch::asm!(
+ "mov [{}], {:r}",
+ in(reg) ptr,
+ in(reg) value,
+ );
+ }
}
}
diff --git a/vendor/redox_syscall/src/number.rs b/vendor/redox_syscall/src/number.rs
index 2b9205a26..056cfc76a 100644
--- a/vendor/redox_syscall/src/number.rs
+++ b/vendor/redox_syscall/src/number.rs
@@ -25,10 +25,16 @@ pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94;
pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207;
pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55;
pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927;
+
+// TODO: Rename FMAP/FUNMAP to MMAP/MUNMAP
pub const SYS_FMAP_OLD: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 90;
pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 900;
+// TODO: SYS_FUNMAP should be SYS_CLASS_FILE
+// TODO: Remove FMAP/FMAP_OLD
pub const SYS_FUNMAP_OLD: usize = SYS_CLASS_FILE | 91;
pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 92;
+pub const SYS_MREMAP: usize = 155;
+
pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928;
pub const SYS_FRENAME: usize = SYS_CLASS_FILE | SYS_ARG_PATH | 38;
pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28;
@@ -37,6 +43,18 @@ pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118;
pub const SYS_FTRUNCATE: usize = SYS_CLASS_FILE | 93;
pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320;
+// b = file, c = flags, d = required_page_count, uid:gid = offset
+pub const KSMSG_MMAP: usize = SYS_CLASS_FILE | 72;
+
+// b = file, c = flags, d = page_count, uid:gid = offset
+pub const KSMSG_MSYNC: usize = SYS_CLASS_FILE | 73;
+
+// b = file, c = page_count, uid:gid = offset
+pub const KSMSG_MUNMAP: usize = SYS_CLASS_FILE | 74;
+
+// b = file, c = flags, d = page_count, uid:gid = offset
+pub const KSMSG_MMAP_PREP: usize = SYS_CLASS_FILE | 75;
+
pub const SYS_CLOCK_GETTIME: usize = 265;
pub const SYS_EXIT: usize = 1;
pub const SYS_FUTEX: usize = 240;
@@ -58,9 +76,7 @@ pub const SYS_PHYSALLOC: usize =945;
pub const SYS_PHYSALLOC3: usize=9453;
pub const SYS_PHYSFREE: usize = 946;
pub const SYS_PHYSMAP: usize = 947;
-pub const SYS_PHYSUNMAP: usize =948;
pub const SYS_VIRTTOPHYS: usize=949;
-pub const SYS_PIPE2: usize = 331;
pub const SYS_SETPGID: usize = 57;
pub const SYS_SETREGID: usize = 204;
pub const SYS_SETRENS: usize = 952;
diff --git a/vendor/redox_syscall/src/scheme/generate.sh b/vendor/redox_syscall/src/scheme/generate.sh
index a877cda92..be851f57b 100755
--- a/vendor/redox_syscall/src/scheme/generate.sh
+++ b/vendor/redox_syscall/src/scheme/generate.sh
@@ -15,6 +15,8 @@ sed 's/trait Scheme/trait SchemeBlock/' scheme.rs \
| sed 's/\.map(|o| o as usize)/.map(|o| o.map(|o| o as usize))/' \
| sed 's/Ok(0)/Ok(Some(0))/g' \
| sed 's/Result<\([^>]\+\)>/Result<Option<\1>>/g' \
+| sed 's/convert_to_this_scheme/convert_to_this_scheme_block/g' \
+| sed 's/convert_in_scheme_handle/convert_in_scheme_handle_block/g' \
> scheme_block.rs
echo "Generating SchemeBlockMut from SchemeBlock"
diff --git a/vendor/redox_syscall/src/scheme/mod.rs b/vendor/redox_syscall/src/scheme/mod.rs
index f65d1e2c0..61655dabf 100644
--- a/vendor/redox_syscall/src/scheme/mod.rs
+++ b/vendor/redox_syscall/src/scheme/mod.rs
@@ -1,5 +1,7 @@
use core::{slice, str};
+use crate::{Error, Result, EOPNOTSUPP, ESKMSG, Packet, SKMSG_FRETURNFD};
+
pub use self::scheme::Scheme;
pub use self::scheme_mut::SchemeMut;
pub use self::scheme_block::SchemeBlock;
@@ -16,3 +18,51 @@ mod scheme_mut;
mod scheme_block;
mod scheme_block_mut;
mod seek;
+
+pub struct CallerCtx {
+ pub pid: usize,
+ pub uid: u32,
+ pub gid: u32,
+}
+
+pub enum OpenResult {
+ ThisScheme { number: usize },
+ OtherScheme { fd: usize },
+}
+
+// TODO: Find a better solution than generate.sh
+pub(crate) fn convert_to_this_scheme(r: Result<usize>) -> Result<OpenResult> {
+ r.map(|number| OpenResult::ThisScheme { number })
+}
+pub(crate) fn convert_to_this_scheme_block(r: Result<Option<usize>>) -> Result<Option<OpenResult>> {
+ r.map(|o| o.map(|number| OpenResult::ThisScheme { number }))
+}
+pub(crate) fn convert_in_scheme_handle_block(_: &Packet, result: Result<Option<OpenResult>>) -> Result<Option<usize>> {
+ match result {
+ Ok(Some(OpenResult::ThisScheme { number })) => Ok(Some(number)),
+ Ok(Some(OpenResult::OtherScheme { .. })) => Err(Error::new(EOPNOTSUPP)),
+ Ok(None) => Ok(None),
+ Err(err) => Err(err),
+ }
+}
+pub(crate) fn convert_in_scheme_handle(packet: &mut Packet, result: Result<OpenResult>) -> Result<usize> {
+ match result {
+ Ok(OpenResult::ThisScheme { number }) => Ok(number),
+ Ok(OpenResult::OtherScheme { fd }) => {
+ packet.b = SKMSG_FRETURNFD;
+ packet.c = fd;
+ Err(Error::new(ESKMSG))
+ }
+ Err(err) => Err(err),
+ }
+}
+
+impl CallerCtx {
+ pub fn from_packet(packet: &Packet) -> Self {
+ Self {
+ pid: packet.pid,
+ uid: packet.uid,
+ gid: packet.gid,
+ }
+ }
+}
diff --git a/vendor/redox_syscall/src/scheme/scheme.rs b/vendor/redox_syscall/src/scheme/scheme.rs
index 6bf36172c..ee09d697b 100644
--- a/vendor/redox_syscall/src/scheme/scheme.rs
+++ b/vendor/redox_syscall/src/scheme/scheme.rs
@@ -1,17 +1,20 @@
use core::{mem, slice};
+use crate::CallerCtx;
+use crate::OpenResult;
use crate::data::*;
use crate::error::*;
use crate::flag::*;
use crate::number::*;
-use crate::scheme::str_from_raw_parts;
+use crate::scheme::*;
pub trait Scheme {
fn handle(&self, packet: &mut Packet) {
let res = match packet.a {
SYS_OPEN => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
- self.open(path, packet.d, packet.uid, packet.gid)
- } else {
+ convert_in_scheme_handle(packet, self.xopen(path, packet.d, &CallerCtx::from_packet(&packet)))
+ }
+ else {
Err(Error::new(EINVAL))
},
SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
@@ -25,7 +28,7 @@ pub trait Scheme {
Err(Error::new(EINVAL))
},
- SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
+ SYS_DUP => convert_in_scheme_handle(packet, self.xdup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, &CallerCtx::from_packet(&packet))),
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 as isize, packet.d).map(|o| o as usize),
@@ -33,18 +36,6 @@ pub trait Scheme {
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32),
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
SYS_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.bits()),
- SYS_FMAP_OLD => if packet.d >= mem::size_of::<OldMap>() {
- self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) })
- } else {
- Err(Error::new(EFAULT))
- },
- SYS_FMAP => if packet.d >= mem::size_of::<Map>() {
- self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
- } else {
- Err(Error::new(EFAULT))
- },
- SYS_FUNMAP_OLD => self.funmap_old(packet.b),
- SYS_FUNMAP => self.funmap(packet.b, packet.c),
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => if let Some(path) = unsafe { str_from_raw_parts(packet.c as *const u8, packet.d) } {
self.frename(packet.b, path, packet.uid, packet.gid)
@@ -69,6 +60,10 @@ pub trait Scheme {
Err(Error::new(EFAULT))
},
SYS_CLOSE => self.close(packet.b),
+
+ KSMSG_MMAP_PREP => self.mmap_prep(packet.b, u64::from(packet.uid) | (u64::from(packet.gid) << 32), packet.c, MapFlags::from_bits_truncate(packet.d)),
+ KSMSG_MUNMAP => self.munmap(packet.b, u64::from(packet.uid) | (u64::from(packet.gid) << 32), packet.c, MunmapFlags::from_bits_truncate(packet.d)),
+
_ => Err(Error::new(ENOSYS))
};
@@ -81,6 +76,10 @@ pub trait Scheme {
fn open(&self, path: &str, flags: usize, uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(ENOENT))
}
+ #[allow(unused_variables)]
+ fn xopen(&self, path: &str, flags: usize, ctx: &CallerCtx) -> Result<OpenResult> {
+ convert_to_this_scheme(self.open(path, flags, ctx.uid, ctx.gid))
+ }
#[allow(unused_variables)]
fn chmod(&self, path: &str, mode: u16, uid: u32, gid: u32) -> Result<usize> {
@@ -104,6 +103,11 @@ pub trait Scheme {
}
#[allow(unused_variables)]
+ fn xdup(&self, old_id: usize, buf: &[u8], ctx: &CallerCtx) -> Result<OpenResult> {
+ convert_to_this_scheme(self.dup(old_id, buf))
+ }
+
+ #[allow(unused_variables)]
fn read(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
Err(Error::new(EBADF))
}
@@ -139,32 +143,6 @@ pub trait Scheme {
}
#[allow(unused_variables)]
- fn fmap_old(&self, id: usize, map: &OldMap) -> Result<usize> {
- Err(Error::new(EBADF))
- }
- #[allow(unused_variables)]
- fn fmap(&self, id: usize, map: &Map) -> Result<usize> {
- if map.flags.contains(MapFlags::MAP_FIXED) {
- return Err(Error::new(EINVAL));
- }
- self.fmap_old(id, &OldMap {
- offset: map.offset,
- size: map.size,
- flags: map.flags,
- })
- }
-
- #[allow(unused_variables)]
- fn funmap_old(&self, address: usize) -> Result<usize> {
- Ok(0)
- }
-
- #[allow(unused_variables)]
- fn funmap(&self, address: usize, length: usize) -> Result<usize> {
- Ok(0)
- }
-
- #[allow(unused_variables)]
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
Err(Error::new(EBADF))
}
@@ -203,4 +181,14 @@ pub trait Scheme {
fn close(&self, id: usize) -> Result<usize> {
Err(Error::new(EBADF))
}
+
+ #[allow(unused_variables)]
+ fn mmap_prep(&self, id: usize, offset: u64, size: usize, flags: MapFlags) -> Result<usize> {
+ Err(Error::new(EOPNOTSUPP))
+ }
+
+ #[allow(unused_variables)]
+ fn munmap(&self, id: usize, offset: u64, size: usize, flags: MunmapFlags) -> Result<usize> {
+ Err(Error::new(EOPNOTSUPP))
+ }
}
diff --git a/vendor/redox_syscall/src/scheme/scheme_block.rs b/vendor/redox_syscall/src/scheme/scheme_block.rs
index 3b3de4bc9..e74e3b7e2 100644
--- a/vendor/redox_syscall/src/scheme/scheme_block.rs
+++ b/vendor/redox_syscall/src/scheme/scheme_block.rs
@@ -1,17 +1,20 @@
use core::{mem, slice};
+use crate::CallerCtx;
+use crate::OpenResult;
use crate::data::*;
use crate::error::*;
use crate::flag::*;
use crate::number::*;
-use crate::scheme::str_from_raw_parts;
+use crate::scheme::*;
pub trait SchemeBlock {
fn handle(&self, packet: &Packet) -> Option<usize> {
let res = match packet.a {
SYS_OPEN => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
- self.open(path, packet.d, packet.uid, packet.gid)
- } else {
+ convert_in_scheme_handle_block(packet, self.xopen(path, packet.d, &CallerCtx::from_packet(&packet)))
+ }
+ else {
Err(Error::new(EINVAL))
},
SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
@@ -25,7 +28,7 @@ pub trait SchemeBlock {
Err(Error::new(EINVAL))
},
- SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
+ SYS_DUP => convert_in_scheme_handle_block(packet, self.xdup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, &CallerCtx::from_packet(&packet))),
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 as isize, packet.d).map(|o| o.map(|o| o as usize)),
@@ -33,18 +36,6 @@ pub trait SchemeBlock {
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32),
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
SYS_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.map(|f| f.bits())),
- SYS_FMAP_OLD => if packet.d >= mem::size_of::<OldMap>() {
- self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) })
- } else {
- Err(Error::new(EFAULT))
- },
- SYS_FMAP => if packet.d >= mem::size_of::<Map>() {
- self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
- } else {
- Err(Error::new(EFAULT))
- },
- SYS_FUNMAP_OLD => self.funmap_old(packet.b),
- SYS_FUNMAP => self.funmap(packet.b, packet.c),
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => if let Some(path) = unsafe { str_from_raw_parts(packet.c as *const u8, packet.d) } {
self.frename(packet.b, path, packet.uid, packet.gid)
@@ -69,6 +60,10 @@ pub trait SchemeBlock {
Err(Error::new(EFAULT))
},
SYS_CLOSE => self.close(packet.b),
+
+ KSMSG_MMAP_PREP => self.mmap_prep(packet.b, u64::from(packet.uid) | (u64::from(packet.gid) << 32), packet.c, MapFlags::from_bits_truncate(packet.d)),
+ KSMSG_MUNMAP => self.munmap(packet.b, u64::from(packet.uid) | (u64::from(packet.gid) << 32), packet.c, MunmapFlags::from_bits_truncate(packet.d)),
+
_ => Err(Error::new(ENOSYS))
};
@@ -81,6 +76,10 @@ pub trait SchemeBlock {
fn open(&self, path: &str, flags: usize, uid: u32, gid: u32) -> Result<Option<usize>> {
Err(Error::new(ENOENT))
}
+ #[allow(unused_variables)]
+ fn xopen(&self, path: &str, flags: usize, ctx: &CallerCtx) -> Result<Option<OpenResult>> {
+ convert_to_this_scheme_block(self.open(path, flags, ctx.uid, ctx.gid))
+ }
#[allow(unused_variables)]
fn chmod(&self, path: &str, mode: u16, uid: u32, gid: u32) -> Result<Option<usize>> {
@@ -104,6 +103,11 @@ pub trait SchemeBlock {
}
#[allow(unused_variables)]
+ fn xdup(&self, old_id: usize, buf: &[u8], ctx: &CallerCtx) -> Result<Option<OpenResult>> {
+ convert_to_this_scheme_block(self.dup(old_id, buf))
+ }
+
+ #[allow(unused_variables)]
fn read(&self, id: usize, buf: &mut [u8]) -> Result<Option<usize>> {
Err(Error::new(EBADF))
}
@@ -139,32 +143,6 @@ pub trait SchemeBlock {
}
#[allow(unused_variables)]
- fn fmap_old(&self, id: usize, map: &OldMap) -> Result<Option<usize>> {
- Err(Error::new(EBADF))
- }
- #[allow(unused_variables)]
- fn fmap(&self, id: usize, map: &Map) -> Result<Option<usize>> {
- if map.flags.contains(MapFlags::MAP_FIXED) {
- return Err(Error::new(EINVAL));
- }
- self.fmap_old(id, &OldMap {
- offset: map.offset,
- size: map.size,
- flags: map.flags,
- })
- }
-
- #[allow(unused_variables)]
- fn funmap_old(&self, address: usize) -> Result<Option<usize>> {
- Ok(Some(0))
- }
-
- #[allow(unused_variables)]
- fn funmap(&self, address: usize, length: usize) -> Result<Option<usize>> {
- Ok(Some(0))
- }
-
- #[allow(unused_variables)]
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<Option<usize>> {
Err(Error::new(EBADF))
}
@@ -203,4 +181,14 @@ pub trait SchemeBlock {
fn close(&self, id: usize) -> Result<Option<usize>> {
Err(Error::new(EBADF))
}
+
+ #[allow(unused_variables)]
+ fn mmap_prep(&self, id: usize, offset: u64, size: usize, flags: MapFlags) -> Result<Option<usize>> {
+ Err(Error::new(EOPNOTSUPP))
+ }
+
+ #[allow(unused_variables)]
+ fn munmap(&self, id: usize, offset: u64, size: usize, flags: MunmapFlags) -> Result<Option<usize>> {
+ Err(Error::new(EOPNOTSUPP))
+ }
}
diff --git a/vendor/redox_syscall/src/scheme/scheme_block_mut.rs b/vendor/redox_syscall/src/scheme/scheme_block_mut.rs
index 1fae3a0e5..fd2c59069 100644
--- a/vendor/redox_syscall/src/scheme/scheme_block_mut.rs
+++ b/vendor/redox_syscall/src/scheme/scheme_block_mut.rs
@@ -1,17 +1,20 @@
use core::{mem, slice};
+use crate::CallerCtx;
+use crate::OpenResult;
use crate::data::*;
use crate::error::*;
use crate::flag::*;
use crate::number::*;
-use crate::scheme::str_from_raw_parts;
+use crate::scheme::*;
pub trait SchemeBlockMut {
fn handle(&mut self, packet: &Packet) -> Option<usize> {
let res = match packet.a {
SYS_OPEN => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
- self.open(path, packet.d, packet.uid, packet.gid)
- } else {
+ convert_in_scheme_handle_block(packet, self.xopen(path, packet.d, &CallerCtx::from_packet(&packet)))
+ }
+ else {
Err(Error::new(EINVAL))
},
SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
@@ -25,7 +28,7 @@ pub trait SchemeBlockMut {
Err(Error::new(EINVAL))
},
- SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
+ SYS_DUP => convert_in_scheme_handle_block(packet, self.xdup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, &CallerCtx::from_packet(&packet))),
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 as isize, packet.d).map(|o| o.map(|o| o as usize)),
@@ -33,18 +36,6 @@ pub trait SchemeBlockMut {
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32),
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
SYS_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.map(|f| f.bits())),
- SYS_FMAP_OLD => if packet.d >= mem::size_of::<OldMap>() {
- self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) })
- } else {
- Err(Error::new(EFAULT))
- },
- SYS_FMAP => if packet.d >= mem::size_of::<Map>() {
- self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
- } else {
- Err(Error::new(EFAULT))
- },
- SYS_FUNMAP_OLD => self.funmap_old(packet.b),
- SYS_FUNMAP => self.funmap(packet.b, packet.c),
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => if let Some(path) = unsafe { str_from_raw_parts(packet.c as *const u8, packet.d) } {
self.frename(packet.b, path, packet.uid, packet.gid)
@@ -69,6 +60,10 @@ pub trait SchemeBlockMut {
Err(Error::new(EFAULT))
},
SYS_CLOSE => self.close(packet.b),
+
+ KSMSG_MMAP_PREP => self.mmap_prep(packet.b, u64::from(packet.uid) | (u64::from(packet.gid) << 32), packet.c, MapFlags::from_bits_truncate(packet.d)),
+ KSMSG_MUNMAP => self.munmap(packet.b, u64::from(packet.uid) | (u64::from(packet.gid) << 32), packet.c, MunmapFlags::from_bits_truncate(packet.d)),
+
_ => Err(Error::new(ENOSYS))
};
@@ -81,6 +76,10 @@ pub trait SchemeBlockMut {
fn open(&mut self, path: &str, flags: usize, uid: u32, gid: u32) -> Result<Option<usize>> {
Err(Error::new(ENOENT))
}
+ #[allow(unused_variables)]
+ fn xopen(&mut self, path: &str, flags: usize, ctx: &CallerCtx) -> Result<Option<OpenResult>> {
+ convert_to_this_scheme_block(self.open(path, flags, ctx.uid, ctx.gid))
+ }
#[allow(unused_variables)]
fn chmod(&mut self, path: &str, mode: u16, uid: u32, gid: u32) -> Result<Option<usize>> {
@@ -104,6 +103,11 @@ pub trait SchemeBlockMut {
}
#[allow(unused_variables)]
+ fn xdup(&mut self, old_id: usize, buf: &[u8], ctx: &CallerCtx) -> Result<Option<OpenResult>> {
+ convert_to_this_scheme_block(self.dup(old_id, buf))
+ }
+
+ #[allow(unused_variables)]
fn read(&mut self, id: usize, buf: &mut [u8]) -> Result<Option<usize>> {
Err(Error::new(EBADF))
}
@@ -139,32 +143,6 @@ pub trait SchemeBlockMut {
}
#[allow(unused_variables)]
- fn fmap_old(&mut self, id: usize, map: &OldMap) -> Result<Option<usize>> {
- Err(Error::new(EBADF))
- }
- #[allow(unused_variables)]
- fn fmap(&mut self, id: usize, map: &Map) -> Result<Option<usize>> {
- if map.flags.contains(MapFlags::MAP_FIXED) {
- return Err(Error::new(EINVAL));
- }
- self.fmap_old(id, &OldMap {
- offset: map.offset,
- size: map.size,
- flags: map.flags,
- })
- }
-
- #[allow(unused_variables)]
- fn funmap_old(&mut self, address: usize) -> Result<Option<usize>> {
- Ok(Some(0))
- }
-
- #[allow(unused_variables)]
- fn funmap(&mut self, address: usize, length: usize) -> Result<Option<usize>> {
- Ok(Some(0))
- }
-
- #[allow(unused_variables)]
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<Option<usize>> {
Err(Error::new(EBADF))
}
@@ -203,4 +181,14 @@ pub trait SchemeBlockMut {
fn close(&mut self, id: usize) -> Result<Option<usize>> {
Err(Error::new(EBADF))
}
+
+ #[allow(unused_variables)]
+ fn mmap_prep(&mut self, id: usize, offset: u64, size: usize, flags: MapFlags) -> Result<Option<usize>> {
+ Err(Error::new(EOPNOTSUPP))
+ }
+
+ #[allow(unused_variables)]
+ fn munmap(&mut self, id: usize, offset: u64, size: usize, flags: MunmapFlags) -> Result<Option<usize>> {
+ Err(Error::new(EOPNOTSUPP))
+ }
}
diff --git a/vendor/redox_syscall/src/scheme/scheme_mut.rs b/vendor/redox_syscall/src/scheme/scheme_mut.rs
index b364b62aa..2eea4dcbc 100644
--- a/vendor/redox_syscall/src/scheme/scheme_mut.rs
+++ b/vendor/redox_syscall/src/scheme/scheme_mut.rs
@@ -1,17 +1,20 @@
use core::{mem, slice};
+use crate::CallerCtx;
+use crate::OpenResult;
use crate::data::*;
use crate::error::*;
use crate::flag::*;
use crate::number::*;
-use crate::scheme::str_from_raw_parts;
+use crate::scheme::*;
pub trait SchemeMut {
fn handle(&mut self, packet: &mut Packet) {
let res = match packet.a {
SYS_OPEN => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
- self.open(path, packet.d, packet.uid, packet.gid)
- } else {
+ convert_in_scheme_handle(packet, self.xopen(path, packet.d, &CallerCtx::from_packet(&packet)))
+ }
+ else {
Err(Error::new(EINVAL))
},
SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
@@ -25,7 +28,7 @@ pub trait SchemeMut {
Err(Error::new(EINVAL))
},
- SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
+ SYS_DUP => convert_in_scheme_handle(packet, self.xdup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, &CallerCtx::from_packet(&packet))),
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 as isize, packet.d).map(|o| o as usize),
@@ -33,18 +36,6 @@ pub trait SchemeMut {
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32),
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
SYS_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.bits()),
- SYS_FMAP_OLD => if packet.d >= mem::size_of::<OldMap>() {
- self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) })
- } else {
- Err(Error::new(EFAULT))
- },
- SYS_FMAP => if packet.d >= mem::size_of::<Map>() {
- self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
- } else {
- Err(Error::new(EFAULT))
- },
- SYS_FUNMAP_OLD => self.funmap_old(packet.b),
- SYS_FUNMAP => self.funmap(packet.b, packet.c),
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => if let Some(path) = unsafe { str_from_raw_parts(packet.c as *const u8, packet.d) } {
self.frename(packet.b, path, packet.uid, packet.gid)
@@ -69,6 +60,10 @@ pub trait SchemeMut {
Err(Error::new(EFAULT))
},
SYS_CLOSE => self.close(packet.b),
+
+ KSMSG_MMAP_PREP => self.mmap_prep(packet.b, u64::from(packet.uid) | (u64::from(packet.gid) << 32), packet.c, MapFlags::from_bits_truncate(packet.d)),
+ KSMSG_MUNMAP => self.munmap(packet.b, u64::from(packet.uid) | (u64::from(packet.gid) << 32), packet.c, MunmapFlags::from_bits_truncate(packet.d)),
+
_ => Err(Error::new(ENOSYS))
};
@@ -81,6 +76,10 @@ pub trait SchemeMut {
fn open(&mut self, path: &str, flags: usize, uid: u32, gid: u32) -> Result<usize> {
Err(Error::new(ENOENT))
}
+ #[allow(unused_variables)]
+ fn xopen(&mut self, path: &str, flags: usize, ctx: &CallerCtx) -> Result<OpenResult> {
+ convert_to_this_scheme(self.open(path, flags, ctx.uid, ctx.gid))
+ }
#[allow(unused_variables)]
fn chmod(&mut self, path: &str, mode: u16, uid: u32, gid: u32) -> Result<usize> {
@@ -104,6 +103,11 @@ pub trait SchemeMut {
}
#[allow(unused_variables)]
+ fn xdup(&mut self, old_id: usize, buf: &[u8], ctx: &CallerCtx) -> Result<OpenResult> {
+ convert_to_this_scheme(self.dup(old_id, buf))
+ }
+
+ #[allow(unused_variables)]
fn read(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
Err(Error::new(EBADF))
}
@@ -139,32 +143,6 @@ pub trait SchemeMut {
}
#[allow(unused_variables)]
- fn fmap_old(&mut self, id: usize, map: &OldMap) -> Result<usize> {
- Err(Error::new(EBADF))
- }
- #[allow(unused_variables)]
- fn fmap(&mut self, id: usize, map: &Map) -> Result<usize> {
- if map.flags.contains(MapFlags::MAP_FIXED) {
- return Err(Error::new(EINVAL));
- }
- self.fmap_old(id, &OldMap {
- offset: map.offset,
- size: map.size,
- flags: map.flags,
- })
- }
-
- #[allow(unused_variables)]
- fn funmap_old(&mut self, address: usize) -> Result<usize> {
- Ok(0)
- }
-
- #[allow(unused_variables)]
- fn funmap(&mut self, address: usize, length: usize) -> Result<usize> {
- Ok(0)
- }
-
- #[allow(unused_variables)]
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
Err(Error::new(EBADF))
}
@@ -203,4 +181,14 @@ pub trait SchemeMut {
fn close(&mut self, id: usize) -> Result<usize> {
Err(Error::new(EBADF))
}
+
+ #[allow(unused_variables)]
+ fn mmap_prep(&mut self, id: usize, offset: u64, size: usize, flags: MapFlags) -> Result<usize> {
+ Err(Error::new(EOPNOTSUPP))
+ }
+
+ #[allow(unused_variables)]
+ fn munmap(&mut self, id: usize, offset: u64, size: usize, flags: MunmapFlags) -> Result<usize> {
+ Err(Error::new(EOPNOTSUPP))
+ }
}
diff --git a/vendor/redox_syscall/src/tests.rs b/vendor/redox_syscall/src/tests.rs
index fdff89b4b..06a3c011b 100644
--- a/vendor/redox_syscall/src/tests.rs
+++ b/vendor/redox_syscall/src/tests.rs
@@ -287,32 +287,6 @@ fn nanosleep() {
//TODO: physunmap
-#[test]
-fn pipe2() {
- let mut fds = [0, 0];
- assert_eq!(dbg!(crate::pipe2(&mut fds, crate::O_CLOEXEC)), Ok(0));
- assert_ne!(dbg!(fds), [0, 0]);
-
- {
- let mut buf = [0; 256];
- for i in 0..buf.len() {
- buf[i] = i as u8;
- }
- assert_eq!(dbg!(crate::write(fds[1], &buf)), Ok(buf.len()));
- }
-
- {
- let mut buf = [0; 256];
- assert_eq!(dbg!(crate::read(fds[0], &mut buf)), Ok(buf.len()));
- for i in 0..buf.len() {
- assert_eq!(buf[i], i as u8);
- }
- }
-
- assert_eq!(dbg!(crate::close(fds[0])), Ok(0));
- assert_eq!(dbg!(crate::close(fds[1])), Ok(0));
-}
-
//TODO: read
#[test]