Fix ld.so access function on Redox.
This commit is contained in:
+2
-1
@@ -29,7 +29,7 @@ unsafe fn access(path: *const c_char, mode: c_int) -> c_int {
|
||||
Ok(ok) => ok,
|
||||
Err(_) => return -1,
|
||||
};
|
||||
let fd = match syscall::open(path, syscall::O_CLOEXEC) {
|
||||
let fd = match crate::platform::sys::path::open(path, syscall::O_CLOEXEC) {
|
||||
Ok(fd) => fd,
|
||||
_ => return -1,
|
||||
};
|
||||
@@ -40,6 +40,7 @@ unsafe fn access(path: *const c_char, mode: c_int) -> c_int {
|
||||
if syscall::fstat(fd, &mut stat).is_err() {
|
||||
return -1;
|
||||
}
|
||||
let _ = syscall::close(fd);
|
||||
let uid = match syscall::getuid() {
|
||||
Ok(uid) => uid,
|
||||
Err(_) => return -1,
|
||||
|
||||
@@ -181,6 +181,9 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack, ld_entry: usize) ->
|
||||
_r_debug.r_ldbase = ld_entry;
|
||||
}
|
||||
|
||||
// TODO: Fix memory leak, although minimal.
|
||||
crate::platform::init(auxv.clone());
|
||||
|
||||
// Some variables that will be overridden by environment and auxiliary vectors
|
||||
let ld_library_path = envs.get("LD_LIBRARY_PATH").map(|s| s.to_owned());
|
||||
|
||||
|
||||
+2
-2
@@ -21,11 +21,11 @@ pub use self::sys::{e, Sys};
|
||||
|
||||
#[cfg(all(not(feature = "no_std"), target_os = "linux"))]
|
||||
#[path = "linux/mod.rs"]
|
||||
mod sys;
|
||||
pub(crate) mod sys;
|
||||
|
||||
#[cfg(all(not(feature = "no_std"), target_os = "redox"))]
|
||||
#[path = "redox/mod.rs"]
|
||||
mod sys;
|
||||
pub(crate) mod sys;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
use super::{AtomicLock, AttemptStatus};
|
||||
|
||||
const WAITING_BIT: u32 = 1 << 31;
|
||||
const UNLOCKED: u32 = 0;
|
||||
// We now have 2^32 - 1 possible thread ID values
|
||||
|
||||
pub struct ReentrantMutex<T> {
|
||||
lock: AtomicLock,
|
||||
content: UnsafeCell<T>,
|
||||
}
|
||||
unsafe impl<T: Send> Send for ReentrantMutex {}
|
||||
unsafe impl<T: Send> Sync for ReentrantMutex {}
|
||||
|
||||
impl<T> ReentrantMutex<T> {
|
||||
pub const fn new(context: T) -> Self {
|
||||
Self {
|
||||
lock: AtomicLock::new(UNLOCKED),
|
||||
content: UnsafeCell::new(content),
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct ReentrantMutexGuard<'a, T: 'a> {
|
||||
mutex: &'a ReentrantMutex<T>,
|
||||
content: &'a T,
|
||||
}
|
||||
impl<'a, T> Deref for MutexGuard {
|
||||
}
|
||||
Reference in New Issue
Block a user