Merge branch 'revert-74ebfb25' into 'master'
Revert "Merge branch 'rustifying' into 'master'" See merge request redox-os/relibc!667
This commit is contained in:
@@ -791,12 +791,20 @@ 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);
|
||||
Sys::open(name, flags, 0o600).ok()
|
||||
let fd = Sys::open(name, flags, 0o600).or_minus_one_errno();
|
||||
|
||||
if fd >= 0 {
|
||||
Some(fd)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.unwrap_or(-1)
|
||||
}
|
||||
|
||||
+22
-10
@@ -94,12 +94,18 @@ pub unsafe extern "C" fn futimens(fd: c_int, times: *const timespec) -> c_int {
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn lstat(path: *const c_char, buf: *mut stat) -> c_int {
|
||||
let path = CStr::from_ptr(path);
|
||||
// TODO: Rustify
|
||||
let fd = Sys::open(path, O_PATH | O_NOFOLLOW, 0).or_minus_one_errno();
|
||||
if fd < 0 {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Sys::open(path, O_PATH | O_NOFOLLOW, 0).map_or(-1, |fd| {
|
||||
let res = Sys::fstat(fd, buf).map(|()| 0).or_minus_one_errno();
|
||||
Sys::close(fd);
|
||||
res
|
||||
})
|
||||
// TODO: Rustify
|
||||
let res = Sys::fstat(fd, buf).map(|()| 0).or_minus_one_errno();
|
||||
|
||||
Sys::close(fd);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -136,12 +142,18 @@ pub unsafe extern "C" fn mknodat(
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn stat(file: *const c_char, buf: *mut stat) -> c_int {
|
||||
let file = CStr::from_ptr(file);
|
||||
// TODO: Rustify
|
||||
let fd = Sys::open(file, O_PATH, 0).or_minus_one_errno();
|
||||
if fd < 0 {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Sys::open(file, O_PATH, 0).map_or(-1, |fd| {
|
||||
let res = Sys::fstat(fd, buf).map(|()| 0).or_minus_one_errno();
|
||||
Sys::close(fd);
|
||||
res
|
||||
})
|
||||
// TODO: Rustify
|
||||
let res = Sys::fstat(fd, buf).map(|()| 0).or_minus_one_errno();
|
||||
|
||||
Sys::close(fd);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
@@ -34,9 +34,15 @@ pub unsafe 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);
|
||||
Sys::open(file, O_PATH, 0).map_or(-1, |fd| {
|
||||
let res = Sys::fstatvfs(fd, buf).map(|()| 0).or_minus_one_errno();
|
||||
Sys::close(fd);
|
||||
res
|
||||
})
|
||||
// TODO: Rustify
|
||||
let fd = Sys::open(file, O_PATH, 0).or_minus_one_errno();
|
||||
if fd < 0 {
|
||||
return -1;
|
||||
}
|
||||
|
||||
let res = Sys::fstatvfs(fd, buf).map(|()| 0).or_minus_one_errno();
|
||||
|
||||
Sys::close(fd);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
@@ -982,11 +982,17 @@ pub extern "C" fn tcsetpgrp(fd: c_int, pgrp: pid_t) -> c_int {
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn truncate(path: *const c_char, length: off_t) -> c_int {
|
||||
let file = unsafe { CStr::from_ptr(path) };
|
||||
Sys::open(file, fcntl::O_WRONLY, 0).map_or(-1, |fd| {
|
||||
let res = ftruncate(fd, length);
|
||||
Sys::close(fd);
|
||||
res
|
||||
})
|
||||
// TODO: Rustify
|
||||
let fd = Sys::open(file, fcntl::O_WRONLY, 0).or_minus_one_errno();
|
||||
if fd < 0 {
|
||||
return -1;
|
||||
}
|
||||
|
||||
let res = ftruncate(fd, length);
|
||||
|
||||
Sys::close(fd);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/ttyname.html>.
|
||||
|
||||
Reference in New Issue
Block a user