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
+4 -1
View File
@@ -10,6 +10,7 @@ use rand_xorshift::XorShiftRng;
use crate::{
c_str::CStr,
error::ResultExt,
fs::File,
header::{
ctype,
@@ -673,12 +674,14 @@ pub unsafe extern "C" fn mkostemps(
suffix_len: c_int,
mut flags: c_int,
) -> c_int {
// TODO: Rustify impl
flags &= !O_ACCMODE;
flags |= O_RDWR | O_CREAT | O_EXCL;
inner_mktemp(name, suffix_len, || {
let name = CStr::from_ptr(name);
let fd = Sys::open(name, flags, 0o600);
let fd = Sys::open(name, flags, 0o600).or_minus_one_errno();
if fd >= 0 {
Some(fd)