Skip to content

Commit

Permalink
Rollup merge of #64640 - Wind-River:master, r=alexcrichton
Browse files Browse the repository at this point in the history
No home directory on vxWorks

r? @alexcrichton
  • Loading branch information
Centril committed Sep 21, 2019
2 parents 176e216 + 494d83c commit 6254d7a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/libstd/sys/vxworks/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
let p = cstr(p)?;
let mut stat: stat64 = unsafe { mem::zeroed() };
cvt(unsafe {
libc::lstat(p.as_ptr(), &mut stat as *mut _ as *mut _)
libc::stat(p.as_ptr(), &mut stat as *mut _ as *mut _)
})?;
Ok(FileAttr { stat })
}
Expand Down
23 changes: 1 addition & 22 deletions src/libstd/sys/vxworks/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,28 +287,7 @@ pub fn temp_dir() -> PathBuf {
}

pub fn home_dir() -> Option<PathBuf> {
return crate::env::var_os("HOME").or_else(|| unsafe {
fallback()
}).map(PathBuf::from);

unsafe fn fallback() -> Option<OsString> {
let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) {
n if n < 0 => 512 as usize,
n => n as usize,
};
let mut buf = Vec::with_capacity(amt);
let mut passwd: libc::passwd = mem::zeroed();
let mut result = ptr::null_mut();
match libc::getpwuid_r(libc::getuid(), &mut passwd, buf.as_mut_ptr(),
buf.capacity(), &mut result) {
0 if !result.is_null() => {
let ptr = passwd.pw_dir as *const _;
let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
Some(OsStringExt::from_vec(bytes))
},
_ => None,
}
}
None
}

pub fn exit(code: i32) -> ! {
Expand Down

0 comments on commit 6254d7a

Please sign in to comment.