Rustify Sys::open and some fs:: error handling.

This commit is contained in:
4lDO2
2024-09-07 13:06:23 +02:00
parent b9653e689b
commit 198caa3bc5
13 changed files with 75 additions and 55 deletions
+3 -1
View File
@@ -2,6 +2,7 @@
use crate::{
c_str::CStr,
error::ResultExt,
header::fcntl::O_PATH,
platform::{types::*, Pal, Sys},
};
@@ -33,7 +34,8 @@ pub extern "C" fn fstatvfs(fildes: c_int, buf: *mut statvfs) -> c_int {
#[no_mangle]
pub unsafe extern "C" fn statvfs(file: *const c_char, buf: *mut statvfs) -> c_int {
let file = CStr::from_ptr(file);
let fd = Sys::open(file, O_PATH, 0);
// TODO: Rustify
let fd = Sys::open(file, O_PATH, 0).or_minus_one_errno();
if fd < 0 {
return -1;
}