Verified Commit 2bc9acc5 authored by jD91mZM2's avatar jD91mZM2

Breaking Change: Goodbye, deprecated functions

parent a7d066a3
use super::arch::*; use super::arch::*;
use super::data::{Map, Map2, SigAction, Stat, StatVfs, TimeSpec}; use super::data::{Map, SigAction, Stat, StatVfs, TimeSpec};
use super::error::Result; use super::error::Result;
use super::flag::*; use super::flag::*;
use super::number::*; use super::number::*;
...@@ -104,12 +104,6 @@ pub fn fexec(fd: usize, args: &[[usize; 2]], vars: &[[usize; 2]]) -> Result<usiz ...@@ -104,12 +104,6 @@ pub fn fexec(fd: usize, args: &[[usize; 2]], vars: &[[usize; 2]]) -> Result<usiz
unsafe { syscall5(SYS_FEXEC, fd, args.as_ptr() as usize, args.len(), vars.as_ptr() as usize, vars.len()) } unsafe { syscall5(SYS_FEXEC, fd, args.as_ptr() as usize, args.len(), vars.as_ptr() as usize, vars.len()) }
} }
/// Map a file into memory.
pub unsafe fn fmap(fd: usize, map: &Map) -> Result<usize> {
syscall3(SYS_FMAP, fd, map as *const Map as usize, mem::size_of::<Map>())
}
///
/// Map a file into memory, but with the ability to set the address to map into, either as a hint /// Map a file into memory, but with the ability to set the address to map into, either as a hint
/// or as a requirement of the map. /// or as a requirement of the map.
/// ///
...@@ -120,18 +114,13 @@ pub unsafe fn fmap(fd: usize, map: &Map) -> Result<usize> { ...@@ -120,18 +114,13 @@ pub unsafe fn fmap(fd: usize, map: &Map) -> Result<usize> {
/// `EINVAL` - invalid combination of flags /// `EINVAL` - invalid combination of flags
/// `EEXIST` - if [`MapFlags::MAP_FIXED`] was set, and the address specified was already in use. /// `EEXIST` - if [`MapFlags::MAP_FIXED`] was set, and the address specified was already in use.
/// ///
pub unsafe fn fmap2(fd: usize, map: &Map2) -> Result<usize> { pub unsafe fn fmap(fd: usize, map: &Map) -> Result<usize> {
syscall3(SYS_FMAP2, fd, map as *const Map2 as usize, mem::size_of::<Map2>()) syscall3(SYS_FMAP, fd, map as *const Map as usize, mem::size_of::<Map>())
}
/// Unmap a memory-mapped file
pub unsafe fn funmap(addr: usize) -> Result<usize> {
syscall1(SYS_FUNMAP, addr)
} }
/// Unmap whole (or partial) continous memory-mapped files /// Unmap whole (or partial) continous memory-mapped files
pub unsafe fn funmap2(addr: usize, len: usize) -> Result<usize> { pub unsafe fn funmap(addr: usize, len: usize) -> Result<usize> {
syscall2(SYS_FUNMAP2, addr, len) syscall2(SYS_FUNMAP, addr, len)
} }
/// Retrieve the canonical path of a file /// Retrieve the canonical path of a file
......
...@@ -55,31 +55,31 @@ impl DerefMut for ITimerSpec { ...@@ -55,31 +55,31 @@ impl DerefMut for ITimerSpec {
#[derive(Copy, Clone, Debug, Default)] #[derive(Copy, Clone, Debug, Default)]
#[repr(C)] #[repr(C)]
pub struct Map { pub struct OldMap {
pub offset: usize, pub offset: usize,
pub size: usize, pub size: usize,
pub flags: MapFlags, pub flags: MapFlags,
} }
impl Deref for Map { impl Deref for OldMap {
type Target = [u8]; type Target = [u8];
fn deref(&self) -> &[u8] { fn deref(&self) -> &[u8] {
unsafe { unsafe {
slice::from_raw_parts(self as *const Map as *const u8, mem::size_of::<Map>()) slice::from_raw_parts(self as *const OldMap as *const u8, mem::size_of::<OldMap>())
} }
} }
} }
impl DerefMut for Map { impl DerefMut for OldMap {
fn deref_mut(&mut self) -> &mut [u8] { fn deref_mut(&mut self) -> &mut [u8] {
unsafe { unsafe {
slice::from_raw_parts_mut(self as *mut Map as *mut u8, mem::size_of::<Map>()) slice::from_raw_parts_mut(self as *mut OldMap as *mut u8, mem::size_of::<OldMap>())
} }
} }
} }
#[derive(Copy, Clone, Debug, Default)] #[derive(Copy, Clone, Debug, Default)]
#[repr(C)] #[repr(C)]
pub struct Map2 { pub struct Map {
/// The offset inside the file that is being mapped. /// The offset inside the file that is being mapped.
pub offset: usize, pub offset: usize,
...@@ -95,19 +95,19 @@ pub struct Map2 { ...@@ -95,19 +95,19 @@ pub struct Map2 {
pub address: usize, pub address: usize,
} }
impl Deref for Map2 { impl Deref for Map {
type Target = [u8]; type Target = [u8];
fn deref(&self) -> &[u8] { fn deref(&self) -> &[u8] {
unsafe { unsafe {
slice::from_raw_parts(self as *const Map2 as *const u8, mem::size_of::<Map2>()) slice::from_raw_parts(self as *const Map as *const u8, mem::size_of::<Map>())
} }
} }
} }
impl DerefMut for Map2 { impl DerefMut for Map {
fn deref_mut(&mut self) -> &mut [u8] { fn deref_mut(&mut self) -> &mut [u8] {
unsafe { unsafe {
slice::from_raw_parts_mut(self as *mut Map2 as *mut u8, mem::size_of::<Map2>()) slice::from_raw_parts_mut(self as *mut Map as *mut u8, mem::size_of::<Map>())
} }
} }
} }
......
...@@ -16,28 +16,28 @@ pub const SYS_CHMOD: usize = SYS_CLASS_PATH | 15; ...@@ -16,28 +16,28 @@ pub const SYS_CHMOD: usize = SYS_CLASS_PATH | 15;
pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84; pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84;
pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10; pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10;
pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6; pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6;
pub const SYS_DUP: usize = SYS_CLASS_FILE | SYS_RET_FILE | 41; pub const SYS_DUP: usize = SYS_CLASS_FILE | SYS_RET_FILE | 41;
pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63; pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63;
pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3; pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3;
pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4; pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4;
pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19; pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19;
pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94; pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94;
pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207; pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207;
pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55; pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55;
pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927; pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927;
pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11; pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11;
pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 90; pub const SYS_FMAP_OLD: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 90;
pub const SYS_FMAP2: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 900; pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 900;
pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 91; pub const SYS_FUNMAP_OLD: usize = SYS_CLASS_FILE | 91;
pub const SYS_FUNMAP2: usize = SYS_CLASS_FILE | 92; pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 92;
pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928; 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_FRENAME: usize = SYS_CLASS_FILE | SYS_ARG_PATH | 38;
pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28; pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28;
pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100; pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100;
pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118; pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118;
pub const SYS_FTRUNCATE: usize =SYS_CLASS_FILE | 93; pub const SYS_FTRUNCATE: usize = SYS_CLASS_FILE | 93;
pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320; pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320;
pub const SYS_BRK: usize = 45; pub const SYS_BRK: usize = 45;
pub const SYS_CHDIR: usize = 12; pub const SYS_CHDIR: usize = 12;
......
...@@ -21,18 +21,18 @@ pub trait Scheme { ...@@ -21,18 +21,18 @@ pub trait Scheme {
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32), 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_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_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.bits()),
SYS_FMAP => if packet.d >= mem::size_of::<Map>() { SYS_FMAP_OLD => if packet.d >= mem::size_of::<OldMap>() {
self.fmap(packet.b, unsafe { &*(packet.c as *const Map) }) self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) })
} else { } else {
Err(Error::new(EFAULT)) Err(Error::new(EFAULT))
}, },
SYS_FMAP2 => if packet.d >= mem::size_of::<Map2>() { SYS_FMAP => if packet.d >= mem::size_of::<Map>() {
self.fmap2(packet.b, unsafe { &*(packet.c as *const Map2) }) self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
} else { } else {
Err(Error::new(EFAULT)) Err(Error::new(EFAULT))
}, },
SYS_FUNMAP => self.funmap(packet.b), SYS_FUNMAP_OLD => self.funmap_old(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c), 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_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid), SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid),
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() { SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() {
...@@ -123,15 +123,15 @@ pub trait Scheme { ...@@ -123,15 +123,15 @@ pub trait Scheme {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn fmap(&self, id: usize, map: &Map) -> Result<usize> { fn fmap_old(&self, id: usize, map: &OldMap) -> Result<usize> {
Err(Error::new(EBADF)) Err(Error::new(EBADF))
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn fmap2(&self, id: usize, map: &Map2) -> Result<usize> { fn fmap(&self, id: usize, map: &Map) -> Result<usize> {
if map.flags.contains(MapFlags::MAP_FIXED) { if map.flags.contains(MapFlags::MAP_FIXED) {
return Err(Error::new(EINVAL)); return Err(Error::new(EINVAL));
} }
self.fmap(id, &Map { self.fmap_old(id, &OldMap {
offset: map.offset, offset: map.offset,
size: map.size, size: map.size,
flags: map.flags, flags: map.flags,
...@@ -139,12 +139,12 @@ pub trait Scheme { ...@@ -139,12 +139,12 @@ pub trait Scheme {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn funmap(&self, address: usize) -> Result<usize> { fn funmap_old(&self, address: usize) -> Result<usize> {
Ok(0) Ok(0)
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn funmap2(&self, address: usize, length: usize) -> Result<usize> { fn funmap(&self, address: usize, length: usize) -> Result<usize> {
Ok(0) Ok(0)
} }
......
...@@ -21,18 +21,18 @@ pub trait SchemeBlock { ...@@ -21,18 +21,18 @@ pub trait SchemeBlock {
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32), 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_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_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.map(|f| f.bits())),
SYS_FMAP => if packet.d >= mem::size_of::<Map>() { SYS_FMAP_OLD => if packet.d >= mem::size_of::<OldMap>() {
self.fmap(packet.b, unsafe { &*(packet.c as *const Map) }) self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) })
} else { } else {
Err(Error::new(EFAULT)) Err(Error::new(EFAULT))
}, },
SYS_FMAP2 => if packet.d >= mem::size_of::<Map2>() { SYS_FMAP => if packet.d >= mem::size_of::<Map>() {
self.fmap2(packet.b, unsafe { &*(packet.c as *const Map2) }) self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
} else { } else {
Err(Error::new(EFAULT)) Err(Error::new(EFAULT))
}, },
SYS_FUNMAP => self.funmap(packet.b), SYS_FUNMAP_OLD => self.funmap_old(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c), 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_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid), SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid),
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() { SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() {
...@@ -123,15 +123,15 @@ pub trait SchemeBlock { ...@@ -123,15 +123,15 @@ pub trait SchemeBlock {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn fmap(&self, id: usize, map: &Map) -> Result<Option<usize>> { fn fmap_old(&self, id: usize, map: &OldMap) -> Result<Option<usize>> {
Err(Error::new(EBADF)) Err(Error::new(EBADF))
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn fmap2(&self, id: usize, map: &Map2) -> Result<Option<usize>> { fn fmap(&self, id: usize, map: &Map) -> Result<Option<usize>> {
if map.flags.contains(MapFlags::MAP_FIXED) { if map.flags.contains(MapFlags::MAP_FIXED) {
return Err(Error::new(EINVAL)); return Err(Error::new(EINVAL));
} }
self.fmap(id, &Map { self.fmap_old(id, &OldMap {
offset: map.offset, offset: map.offset,
size: map.size, size: map.size,
flags: map.flags, flags: map.flags,
...@@ -139,12 +139,12 @@ pub trait SchemeBlock { ...@@ -139,12 +139,12 @@ pub trait SchemeBlock {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn funmap(&self, address: usize) -> Result<Option<usize>> { fn funmap_old(&self, address: usize) -> Result<Option<usize>> {
Ok(Some(0)) Ok(Some(0))
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn funmap2(&self, address: usize, length: usize) -> Result<Option<usize>> { fn funmap(&self, address: usize, length: usize) -> Result<Option<usize>> {
Ok(Some(0)) Ok(Some(0))
} }
......
...@@ -21,18 +21,18 @@ pub trait SchemeBlockMut { ...@@ -21,18 +21,18 @@ pub trait SchemeBlockMut {
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32), 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_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_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.map(|f| f.bits())),
SYS_FMAP => if packet.d >= mem::size_of::<Map>() { SYS_FMAP_OLD => if packet.d >= mem::size_of::<OldMap>() {
self.fmap(packet.b, unsafe { &*(packet.c as *const Map) }) self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) })
} else { } else {
Err(Error::new(EFAULT)) Err(Error::new(EFAULT))
}, },
SYS_FMAP2 => if packet.d >= mem::size_of::<Map2>() { SYS_FMAP => if packet.d >= mem::size_of::<Map>() {
self.fmap2(packet.b, unsafe { &*(packet.c as *const Map2) }) self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
} else { } else {
Err(Error::new(EFAULT)) Err(Error::new(EFAULT))
}, },
SYS_FUNMAP => self.funmap(packet.b), SYS_FUNMAP_OLD => self.funmap_old(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c), 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_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid), SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid),
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() { SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() {
...@@ -123,15 +123,15 @@ pub trait SchemeBlockMut { ...@@ -123,15 +123,15 @@ pub trait SchemeBlockMut {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn fmap(&mut self, id: usize, map: &Map) -> Result<Option<usize>> { fn fmap_old(&mut self, id: usize, map: &OldMap) -> Result<Option<usize>> {
Err(Error::new(EBADF)) Err(Error::new(EBADF))
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn fmap2(&mut self, id: usize, map: &Map2) -> Result<Option<usize>> { fn fmap(&mut self, id: usize, map: &Map) -> Result<Option<usize>> {
if map.flags.contains(MapFlags::MAP_FIXED) { if map.flags.contains(MapFlags::MAP_FIXED) {
return Err(Error::new(EINVAL)); return Err(Error::new(EINVAL));
} }
self.fmap(id, &Map { self.fmap_old(id, &OldMap {
offset: map.offset, offset: map.offset,
size: map.size, size: map.size,
flags: map.flags, flags: map.flags,
...@@ -139,12 +139,12 @@ pub trait SchemeBlockMut { ...@@ -139,12 +139,12 @@ pub trait SchemeBlockMut {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn funmap(&mut self, address: usize) -> Result<Option<usize>> { fn funmap_old(&mut self, address: usize) -> Result<Option<usize>> {
Ok(Some(0)) Ok(Some(0))
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn funmap2(&mut self, address: usize, length: usize) -> Result<Option<usize>> { fn funmap(&mut self, address: usize, length: usize) -> Result<Option<usize>> {
Ok(Some(0)) Ok(Some(0))
} }
......
...@@ -21,18 +21,18 @@ pub trait SchemeMut { ...@@ -21,18 +21,18 @@ pub trait SchemeMut {
SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32), 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_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_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.bits()),
SYS_FMAP => if packet.d >= mem::size_of::<Map>() { SYS_FMAP_OLD => if packet.d >= mem::size_of::<OldMap>() {
self.fmap(packet.b, unsafe { &*(packet.c as *const Map) }) self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) })
} else { } else {
Err(Error::new(EFAULT)) Err(Error::new(EFAULT))
}, },
SYS_FMAP2 => if packet.d >= mem::size_of::<Map2>() { SYS_FMAP => if packet.d >= mem::size_of::<Map>() {
self.fmap2(packet.b, unsafe { &*(packet.c as *const Map2) }) self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
} else { } else {
Err(Error::new(EFAULT)) Err(Error::new(EFAULT))
}, },
SYS_FUNMAP => self.funmap(packet.b), SYS_FUNMAP_OLD => self.funmap_old(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c), 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_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid), SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid),
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() { SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() {
...@@ -123,15 +123,15 @@ pub trait SchemeMut { ...@@ -123,15 +123,15 @@ pub trait SchemeMut {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn fmap(&mut self, id: usize, map: &Map) -> Result<usize> { fn fmap_old(&mut self, id: usize, map: &OldMap) -> Result<usize> {
Err(Error::new(EBADF)) Err(Error::new(EBADF))
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn fmap2(&mut self, id: usize, map: &Map2) -> Result<usize> { fn fmap(&mut self, id: usize, map: &Map) -> Result<usize> {
if map.flags.contains(MapFlags::MAP_FIXED) { if map.flags.contains(MapFlags::MAP_FIXED) {
return Err(Error::new(EINVAL)); return Err(Error::new(EINVAL));
} }
self.fmap(id, &Map { self.fmap_old(id, &OldMap {
offset: map.offset, offset: map.offset,
size: map.size, size: map.size,
flags: map.flags, flags: map.flags,
...@@ -139,12 +139,12 @@ pub trait SchemeMut { ...@@ -139,12 +139,12 @@ pub trait SchemeMut {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn funmap(&mut self, address: usize) -> Result<usize> { fn funmap_old(&mut self, address: usize) -> Result<usize> {
Ok(0) Ok(0)
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn funmap2(&mut self, address: usize, length: usize) -> Result<usize> { fn funmap(&mut self, address: usize, length: usize) -> Result<usize> {
Ok(0) Ok(0)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment