Commit 4115e0f4 authored by Jeremy Soller's avatar Jeremy Soller

Merge branch 'deprecate-stuff' into 'master'

Breaking Change: Goodbye, deprecated functions

See merge request !58
parents a7d066a3 2bc9acc5
Pipeline #8309 failed with stages
in 39 seconds
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::flag::*;
use super::number::*;
......@@ -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()) }
}
/// 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
/// or as a requirement of the map.
///
......@@ -120,18 +114,13 @@ pub unsafe fn fmap(fd: usize, map: &Map) -> Result<usize> {
/// `EINVAL` - invalid combination of flags
/// `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> {
syscall3(SYS_FMAP2, fd, map as *const Map2 as usize, mem::size_of::<Map2>())
}
/// Unmap a memory-mapped file
pub unsafe fn funmap(addr: usize) -> Result<usize> {
syscall1(SYS_FUNMAP, addr)
pub unsafe fn fmap(fd: usize, map: &Map) -> Result<usize> {
syscall3(SYS_FMAP, fd, map as *const Map as usize, mem::size_of::<Map>())
}
/// Unmap whole (or partial) continous memory-mapped files
pub unsafe fn funmap2(addr: usize, len: usize) -> Result<usize> {
syscall2(SYS_FUNMAP2, addr, len)
pub unsafe fn funmap(addr: usize, len: usize) -> Result<usize> {
syscall2(SYS_FUNMAP, addr, len)
}
/// Retrieve the canonical path of a file
......
......@@ -55,31 +55,31 @@ impl DerefMut for ITimerSpec {
#[derive(Copy, Clone, Debug, Default)]
#[repr(C)]
pub struct Map {
pub struct OldMap {
pub offset: usize,
pub size: usize,
pub flags: MapFlags,
}
impl Deref for Map {
impl Deref for OldMap {
type Target = [u8];
fn deref(&self) -> &[u8] {
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] {
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)]
#[repr(C)]
pub struct Map2 {
pub struct Map {
/// The offset inside the file that is being mapped.
pub offset: usize,
......@@ -95,19 +95,19 @@ pub struct Map2 {
pub address: usize,
}
impl Deref for Map2 {
impl Deref for Map {
type Target = [u8];
fn deref(&self) -> &[u8] {
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] {
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;
pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84;
pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10;
pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6;
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_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3;
pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4;
pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19;
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;
pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11;
pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 90;
pub const SYS_FMAP2: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 900;
pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 91;
pub const SYS_FUNMAP2: usize = SYS_CLASS_FILE | 92;
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;
pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100;
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;
pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6;
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_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3;
pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4;
pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19;
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;
pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11;
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;
pub const SYS_FUNMAP_OLD: usize = SYS_CLASS_FILE | 91;
pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 92;
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;
pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100;
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;
pub const SYS_BRK: usize = 45;
pub const SYS_CHDIR: usize = 12;
......
......@@ -21,18 +21,18 @@ 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 => if packet.d >= mem::size_of::<Map>() {
self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
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_FMAP2 => if packet.d >= mem::size_of::<Map2>() {
self.fmap2(packet.b, unsafe { &*(packet.c as *const Map2) })
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 => self.funmap(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c),
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 => 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>() {
......@@ -123,15 +123,15 @@ pub trait Scheme {
}
#[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))
}
#[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) {
return Err(Error::new(EINVAL));
}
self.fmap(id, &Map {
self.fmap_old(id, &OldMap {
offset: map.offset,
size: map.size,
flags: map.flags,
......@@ -139,12 +139,12 @@ pub trait Scheme {
}
#[allow(unused_variables)]
fn funmap(&self, address: usize) -> Result<usize> {
fn funmap_old(&self, address: usize) -> Result<usize> {
Ok(0)
}
#[allow(unused_variables)]
fn funmap2(&self, address: usize, length: usize) -> Result<usize> {
fn funmap(&self, address: usize, length: usize) -> Result<usize> {
Ok(0)
}
......
......@@ -21,18 +21,18 @@ 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 => if packet.d >= mem::size_of::<Map>() {
self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
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_FMAP2 => if packet.d >= mem::size_of::<Map2>() {
self.fmap2(packet.b, unsafe { &*(packet.c as *const Map2) })
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 => self.funmap(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c),
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 => 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>() {
......@@ -123,15 +123,15 @@ pub trait SchemeBlock {
}
#[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))
}
#[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) {
return Err(Error::new(EINVAL));
}
self.fmap(id, &Map {
self.fmap_old(id, &OldMap {
offset: map.offset,
size: map.size,
flags: map.flags,
......@@ -139,12 +139,12 @@ pub trait SchemeBlock {
}
#[allow(unused_variables)]
fn funmap(&self, address: usize) -> Result<Option<usize>> {
fn funmap_old(&self, address: usize) -> Result<Option<usize>> {
Ok(Some(0))
}
#[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))
}
......
......@@ -21,18 +21,18 @@ 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 => if packet.d >= mem::size_of::<Map>() {
self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
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_FMAP2 => if packet.d >= mem::size_of::<Map2>() {
self.fmap2(packet.b, unsafe { &*(packet.c as *const Map2) })
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 => self.funmap(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c),
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 => 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>() {
......@@ -123,15 +123,15 @@ pub trait SchemeBlockMut {
}
#[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))
}
#[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) {
return Err(Error::new(EINVAL));
}
self.fmap(id, &Map {
self.fmap_old(id, &OldMap {
offset: map.offset,
size: map.size,
flags: map.flags,
......@@ -139,12 +139,12 @@ pub trait SchemeBlockMut {
}
#[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))
}
#[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))
}
......
......@@ -21,18 +21,18 @@ 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 => if packet.d >= mem::size_of::<Map>() {
self.fmap(packet.b, unsafe { &*(packet.c as *const Map) })
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_FMAP2 => if packet.d >= mem::size_of::<Map2>() {
self.fmap2(packet.b, unsafe { &*(packet.c as *const Map2) })
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 => self.funmap(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c),
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 => 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>() {
......@@ -123,15 +123,15 @@ pub trait SchemeMut {
}
#[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))
}
#[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) {
return Err(Error::new(EINVAL));
}
self.fmap(id, &Map {
self.fmap_old(id, &OldMap {
offset: map.offset,
size: map.size,
flags: map.flags,
......@@ -139,12 +139,12 @@ pub trait SchemeMut {
}
#[allow(unused_variables)]
fn funmap(&mut self, address: usize) -> Result<usize> {
fn funmap_old(&mut self, address: usize) -> Result<usize> {
Ok(0)
}
#[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)
}
......
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