Backwards-compatibly rewrite getdents to use special syscall.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use alloc::boxed::Box;
|
||||
|
||||
use crate::{header::errno::STR_ERROR, platform::types::c_int};
|
||||
|
||||
/// Positive error codes (EINVAL, not -EINVAL).
|
||||
@@ -52,3 +54,28 @@ impl<T: From<i8>> ResultExt<T> for Result<T, Errno> {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub trait ResultExtPtrMut<T> {
|
||||
fn or_errno_null_mut(self) -> *mut T;
|
||||
}
|
||||
impl<T> ResultExtPtrMut<T> for Result<*mut T, Errno> {
|
||||
fn or_errno_null_mut(self) -> *mut T {
|
||||
match self {
|
||||
Self::Ok(ptr) => ptr,
|
||||
Self::Err(Errno(errno)) => {
|
||||
crate::platform::ERRNO.set(errno);
|
||||
core::ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<T> ResultExtPtrMut<T> for Result<Box<T>, Errno> {
|
||||
fn or_errno_null_mut(self) -> *mut T {
|
||||
match self {
|
||||
Self::Ok(ptr) => Box::into_raw(ptr),
|
||||
Self::Err(Errno(errno)) => {
|
||||
crate::platform::ERRNO.set(errno);
|
||||
core::ptr::null_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user