Format
This commit is contained in:
+34
-24
@@ -1,9 +1,6 @@
|
||||
//! pwd implementation for relibc
|
||||
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
vec::Vec,
|
||||
};
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use core::{
|
||||
ops::{Deref, DerefMut},
|
||||
pin::Pin,
|
||||
@@ -12,11 +9,7 @@ use core::{
|
||||
|
||||
use crate::{
|
||||
fs::File,
|
||||
header::{
|
||||
errno,
|
||||
fcntl,
|
||||
string::strcmp,
|
||||
},
|
||||
header::{errno, fcntl, string::strcmp},
|
||||
io::{prelude::*, BufReader, SeekFrom},
|
||||
platform::{self, types::*},
|
||||
};
|
||||
@@ -122,9 +115,16 @@ where
|
||||
string.parse().ok()
|
||||
}
|
||||
|
||||
fn getpwent_r(reader: &mut BufReader<File>, destination: Option<DestBuffer>) -> Result<OwnedPwd, Cause> {
|
||||
fn getpwent_r(
|
||||
reader: &mut BufReader<File>,
|
||||
destination: Option<DestBuffer>,
|
||||
) -> Result<OwnedPwd, Cause> {
|
||||
let mut buf = Vec::new();
|
||||
if reader.read_until(b'\n', &mut buf).map_err(|_| Cause::Other)? == 0 {
|
||||
if reader
|
||||
.read_until(b'\n', &mut buf)
|
||||
.map_err(|_| Cause::Other)?
|
||||
== 0
|
||||
{
|
||||
return Err(Cause::Eof);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ fn getpwent_r(reader: &mut BufReader<File>, destination: Option<DestBuffer>) ->
|
||||
}
|
||||
new[..buf.len()].copy_from_slice(&buf);
|
||||
new
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
// Chop up the result into a valid structure
|
||||
@@ -187,21 +187,25 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn mux(status: Result<OwnedPwd, Cause>, out: *mut passwd, result: *mut *mut passwd) -> c_int {
|
||||
unsafe fn mux(
|
||||
status: Result<OwnedPwd, Cause>,
|
||||
out: *mut passwd,
|
||||
result: *mut *mut passwd,
|
||||
) -> c_int {
|
||||
match status {
|
||||
Ok(owned) => {
|
||||
*out = owned.reference;
|
||||
*result = out;
|
||||
0
|
||||
},
|
||||
}
|
||||
Err(Cause::Eof) => {
|
||||
*result = ptr::null_mut();
|
||||
0
|
||||
},
|
||||
}
|
||||
Err(Cause::Other) => {
|
||||
*result = ptr::null_mut();
|
||||
-1
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,10 +218,13 @@ pub unsafe extern "C" fn getpwnam_r(
|
||||
result: *mut *mut passwd,
|
||||
) -> c_int {
|
||||
mux(
|
||||
pwd_lookup(|parts| strcmp(parts.pw_name, name) == 0, Some(DestBuffer {
|
||||
ptr: buf as *mut u8,
|
||||
len: size,
|
||||
})),
|
||||
pwd_lookup(
|
||||
|parts| strcmp(parts.pw_name, name) == 0,
|
||||
Some(DestBuffer {
|
||||
ptr: buf as *mut u8,
|
||||
len: size,
|
||||
}),
|
||||
),
|
||||
out,
|
||||
result,
|
||||
)
|
||||
@@ -233,10 +240,13 @@ pub unsafe extern "C" fn getpwuid_r(
|
||||
) -> c_int {
|
||||
let slice = core::slice::from_raw_parts_mut(buf as *mut u8, size);
|
||||
mux(
|
||||
pwd_lookup(|part| part.pw_uid == uid, Some(DestBuffer {
|
||||
ptr: buf as *mut u8,
|
||||
len: size,
|
||||
})),
|
||||
pwd_lookup(
|
||||
|part| part.pw_uid == uid,
|
||||
Some(DestBuffer {
|
||||
ptr: buf as *mut u8,
|
||||
len: size,
|
||||
}),
|
||||
),
|
||||
out,
|
||||
result,
|
||||
)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
//! sys/resource.h implementation for Redox, following
|
||||
//! http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysresource.h.html
|
||||
|
||||
use crate::header::sys_time::timeval;
|
||||
use crate::platform::types::*;
|
||||
use crate::platform::{Pal, Sys};
|
||||
use crate::{
|
||||
header::sys_time::timeval,
|
||||
platform::{types::*, Pal, Sys},
|
||||
};
|
||||
|
||||
// Exported in bits file
|
||||
// const RUSAGE_SELF: c_int = 0;
|
||||
|
||||
@@ -140,12 +140,11 @@ pub unsafe extern "C" fn ctime(clock: *const time_t) -> *mut c_char {
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ctime_r(clock: *const time_t, buf: *mut c_char) -> *mut c_char {
|
||||
let mut tm1 : tm = core::mem::uninitialized();
|
||||
let mut tm1: tm = core::mem::uninitialized();
|
||||
localtime_r(clock, &mut tm1);
|
||||
asctime_r(&mut tm1, buf)
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn difftime(time1: time_t, time0: time_t) -> c_double {
|
||||
(time1 - time0) as c_double
|
||||
|
||||
+6
-7
@@ -4,11 +4,7 @@ use alloc::{
|
||||
string::{String, ToString},
|
||||
vec::Vec,
|
||||
};
|
||||
use core::{
|
||||
mem,
|
||||
ptr,
|
||||
slice
|
||||
};
|
||||
use core::{mem, ptr, slice};
|
||||
use goblin::{
|
||||
elf::{program_header, reloc, sym, Elf},
|
||||
error::{Error, Result},
|
||||
@@ -133,7 +129,7 @@ impl Linker {
|
||||
let mut elfs = BTreeMap::new();
|
||||
for (name, data) in self.objects.iter() {
|
||||
// Skip already linked libraries
|
||||
if ! self.mmaps.contains_key(&*name) {
|
||||
if !self.mmaps.contains_key(&*name) {
|
||||
elfs.insert(name.as_str(), Elf::parse(&data)?);
|
||||
}
|
||||
}
|
||||
@@ -324,7 +320,10 @@ impl Linker {
|
||||
} else {
|
||||
tcb_master.offset -= tls_offset;
|
||||
tls_offset += vsize;
|
||||
tls_ranges.insert(elf_name.to_string(), (tcb_masters.len(), tcb_master.range()));
|
||||
tls_ranges.insert(
|
||||
elf_name.to_string(),
|
||||
(tcb_masters.len(), tcb_master.range()),
|
||||
);
|
||||
tcb_masters.push(tcb_master);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-6
@@ -1,11 +1,6 @@
|
||||
// Start code adapted from https://gitlab.redox-os.org/redox-os/relibc/blob/master/src/start.rs
|
||||
|
||||
use crate::{
|
||||
c_str::CStr,
|
||||
header::unistd,
|
||||
platform::types::c_char,
|
||||
start::Stack,
|
||||
};
|
||||
use crate::{c_str::CStr, header::unistd, platform::types::c_char, start::Stack};
|
||||
|
||||
use super::linker::Linker;
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ impl Pal for Sys {
|
||||
|
||||
unsafe fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int {
|
||||
//TODO
|
||||
if ! rlim.is_null() {
|
||||
if !rlim.is_null() {
|
||||
(*rlim).rlim_cur = RLIM_INFINITY;
|
||||
(*rlim).rlim_max = RLIM_INFINITY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user