Remove kernel support for fmap_old and funmap_old.
This commit is contained in:
@@ -66,18 +66,6 @@ impl Scheme for MemoryScheme {
|
||||
fn fmap(&self, _id: usize, map: &Map) -> Result<usize> {
|
||||
Self::fmap_anonymous(map)
|
||||
}
|
||||
fn fmap_old(&self, id: usize, map: &OldMap) -> Result<usize> {
|
||||
if map.flags.contains(MapFlags::MAP_FIXED) {
|
||||
// not supported for fmap, which lacks the address argument.
|
||||
return Err(Error::new(EINVAL));
|
||||
}
|
||||
self.fmap(id, &Map {
|
||||
offset: map.offset,
|
||||
size: map.size,
|
||||
flags: map.flags,
|
||||
address: 0,
|
||||
})
|
||||
}
|
||||
|
||||
fn fcntl(&self, _id: usize, _cmd: usize, _arg: usize) -> Result<usize> {
|
||||
Ok(0)
|
||||
|
||||
@@ -381,59 +381,6 @@ impl Scheme for UserScheme {
|
||||
inner.call(SYS_FEVENT, file, flags.bits(), 0).map(EventFlags::from_bits_truncate)
|
||||
}
|
||||
|
||||
fn fmap_old(&self, file: usize, map: &OldMap) -> Result<usize> {
|
||||
let inner = self.inner.upgrade().ok_or(Error::new(ENODEV))?;
|
||||
|
||||
let (pid, uid, gid, context_lock, desc) = {
|
||||
let contexts = context::contexts();
|
||||
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
|
||||
let context = context_lock.read();
|
||||
// TODO: Faster, cleaner mechanism to get descriptor
|
||||
let scheme = inner.scheme_id.load(Ordering::SeqCst);
|
||||
let mut desc_res = Err(Error::new(EBADF));
|
||||
for context_file_opt in context.files.read().iter() {
|
||||
if let Some(context_file) = context_file_opt {
|
||||
let (context_scheme, context_number) = {
|
||||
let desc = context_file.description.read();
|
||||
(desc.scheme, desc.number)
|
||||
};
|
||||
if context_scheme == scheme && context_number == file {
|
||||
desc_res = Ok(context_file.clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let desc = desc_res?;
|
||||
(context.id, context.euid, context.egid, Arc::downgrade(&context_lock), desc)
|
||||
};
|
||||
|
||||
let address = inner.capture(map)?;
|
||||
|
||||
let id = inner.next_id.fetch_add(1, Ordering::SeqCst);
|
||||
|
||||
inner.fmap.lock().insert(id, (context_lock, desc, Map {
|
||||
offset: map.offset,
|
||||
size: map.size,
|
||||
flags: map.flags,
|
||||
address: 0,
|
||||
}));
|
||||
|
||||
let result = inner.call_inner(Packet {
|
||||
id,
|
||||
pid: pid.into(),
|
||||
uid,
|
||||
gid,
|
||||
a: SYS_FMAP_OLD,
|
||||
b: file,
|
||||
c: address,
|
||||
d: mem::size_of::<OldMap>()
|
||||
});
|
||||
|
||||
let _ = inner.release(address);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
fn fmap(&self, file: usize, map: &Map) -> Result<usize> {
|
||||
let inner = self.inner.upgrade().ok_or(Error::new(ENODEV))?;
|
||||
|
||||
@@ -482,36 +429,6 @@ impl Scheme for UserScheme {
|
||||
result
|
||||
}
|
||||
|
||||
fn funmap_old(&self, grant_address: usize) -> Result<usize> {
|
||||
let inner = self.inner.upgrade().ok_or(Error::new(ENODEV))?;
|
||||
let address_opt = {
|
||||
let contexts = context::contexts();
|
||||
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
|
||||
let context = context_lock.read();
|
||||
let mut grants = context.grants.write();
|
||||
let funmap = &mut grants.funmap;
|
||||
let entry = funmap.range(..=Region::byte(VirtualAddress::new(grant_address))).next_back();
|
||||
|
||||
let grant_address = VirtualAddress::new(grant_address);
|
||||
|
||||
if let Some((&grant, &user_base)) = entry {
|
||||
if grant_address >= grant.end_address() {
|
||||
return Err(Error::new(EINVAL));
|
||||
}
|
||||
funmap.remove(&grant);
|
||||
let user = Region::new(user_base, grant.size());
|
||||
Some(grant.rebase(user, grant_address).data())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
if let Some(user_address) = address_opt {
|
||||
inner.call(SYS_FUNMAP_OLD, user_address, 0, 0)
|
||||
} else {
|
||||
Err(Error::new(EINVAL))
|
||||
}
|
||||
}
|
||||
|
||||
fn funmap(&self, grant_address: usize, size: usize) -> Result<usize> {
|
||||
let inner = self.inner.upgrade().ok_or(Error::new(ENODEV))?;
|
||||
let address_opt = {
|
||||
|
||||
@@ -106,14 +106,6 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -
|
||||
c,
|
||||
d
|
||||
),
|
||||
SYS_FMAP_OLD => format!(
|
||||
"fmap_old({}, {:?})",
|
||||
b,
|
||||
validate_slice(
|
||||
c as *const OldMap,
|
||||
d/mem::size_of::<OldMap>()
|
||||
),
|
||||
),
|
||||
SYS_FMAP => format!(
|
||||
"fmap({}, {:?})",
|
||||
b,
|
||||
@@ -122,10 +114,6 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -
|
||||
d/mem::size_of::<Map>()
|
||||
),
|
||||
),
|
||||
SYS_FUNMAP_OLD => format!(
|
||||
"funmap_old({:#X})",
|
||||
b
|
||||
),
|
||||
SYS_FUNMAP => format!(
|
||||
"funmap({:#X}, {:#X})",
|
||||
b,
|
||||
|
||||
@@ -469,45 +469,6 @@ pub fn fstat(fd: FileHandle, stat: &mut Stat) -> Result<usize> {
|
||||
scheme.fstat(description.number, stat)
|
||||
}
|
||||
|
||||
pub fn funmap_old(virtual_address: usize) -> Result<usize> {
|
||||
if virtual_address == 0 {
|
||||
Ok(0)
|
||||
} else {
|
||||
let mut desc_opt = None;
|
||||
|
||||
{
|
||||
let contexts = context::contexts();
|
||||
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
|
||||
let context = context_lock.read();
|
||||
|
||||
let mut grants = context.grants.write();
|
||||
|
||||
if let Some(region) = grants.contains(VirtualAddress::new(virtual_address)).map(Region::from) {
|
||||
let mut grant = grants.take(®ion).unwrap();
|
||||
desc_opt = grant.desc_opt.take();
|
||||
grant.unmap();
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(file_ref) = desc_opt {
|
||||
let scheme_id = { file_ref.desc.description.read().scheme };
|
||||
|
||||
let scheme = {
|
||||
let schemes = scheme::schemes();
|
||||
let scheme = schemes.get(scheme_id).ok_or(Error::new(EBADF))?;
|
||||
scheme.clone()
|
||||
};
|
||||
let res = scheme.funmap_old(virtual_address);
|
||||
|
||||
let _ = file_ref.desc.close();
|
||||
|
||||
res
|
||||
} else {
|
||||
Err(Error::new(EFAULT))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn funmap(virtual_address: usize, length: usize) -> Result<usize> {
|
||||
if virtual_address == 0 || length == 0 {
|
||||
return Ok(0);
|
||||
|
||||
@@ -85,24 +85,6 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, bp: u
|
||||
SYS_FCNTL => fcntl(fd, c, d),
|
||||
SYS_FRENAME => frename(fd, validate_str(c as *const u8, d)?),
|
||||
SYS_FUNMAP => funmap(b, c),
|
||||
SYS_FMAP_OLD => {
|
||||
{
|
||||
let contexts = crate::context::contexts();
|
||||
let current = contexts.current().unwrap();
|
||||
let current = current.read();
|
||||
println!("{:?} using deprecated fmap(...) call", *current.name.read());
|
||||
}
|
||||
file_op(a, fd, c, d)
|
||||
},
|
||||
SYS_FUNMAP_OLD => {
|
||||
{
|
||||
let contexts = crate::context::contexts();
|
||||
let current = contexts.current().unwrap();
|
||||
let current = current.read();
|
||||
println!("{:?} using deprecated funmap(...) call", *current.name.read());
|
||||
}
|
||||
funmap_old(b)
|
||||
},
|
||||
_ => file_op(a, fd, c, d)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user