diff --git a/src/header/pthread/mod.rs b/src/header/pthread/mod.rs index a6c3801398..1e3f6c52fc 100644 --- a/src/header/pthread/mod.rs +++ b/src/header/pthread/mod.rs @@ -108,8 +108,8 @@ fn copy_u64_to_cpuset(mask: u64, cpusetsize: size_t, cpuset: *mut cpu_set_t) -> #[cfg(target_os = "redox")] fn redox_get_thread_affinity(thread: &crate::pthread::Pthread) -> Result { let os_tid = unsafe { thread.os_tid.get().read() }; - let path = alloc::format!("proc:{}/sched-affinity", os_tid.thread_fd); - let fd = Sys::open(&path, crate::header::fcntl::O_RDONLY, 0)?; + let path = alloc::format!("proc:{}/sched-affinity\0", os_tid.thread_fd); + let fd = Sys::open(crate::c_str::CStr::from_bytes_with_nul(path.as_bytes()).unwrap(), crate::header::fcntl::O_RDONLY, 0)?; let mut buf = [0u8; RLCT_AFFINITY_BYTES]; let read = Sys::read(fd, &mut buf)?; @@ -123,8 +123,8 @@ fn redox_get_thread_affinity(thread: &crate::pthread::Pthread) -> Result Result<(), Errno> { let os_tid = unsafe { thread.os_tid.get().read() }; - let path = alloc::format!("proc:{}/sched-affinity", os_tid.thread_fd); - let fd = Sys::open(&path, crate::header::fcntl::O_WRONLY, 0)?; + let path = alloc::format!("proc:{}/sched-affinity\0", os_tid.thread_fd); + let fd = Sys::open(crate::c_str::CStr::from_bytes_with_nul(path.as_bytes()).unwrap(), crate::header::fcntl::O_WRONLY, 0)?; let bytes = mask.to_ne_bytes(); let written = Sys::write(fd, &bytes)?; @@ -554,8 +554,8 @@ pub unsafe extern "C" fn pthread_setname_np(thread: pthread_t, name: *const c_ch { let thread = unsafe { &*thread.cast::() }; let os_tid = unsafe { thread.os_tid.get().read() }; - let path = alloc::format!("proc:{}/name", os_tid.thread_fd); - let fd = match Sys::open(&path, crate::header::fcntl::O_WRONLY, 0) { + let path = alloc::format!("proc:{}/name\0", os_tid.thread_fd); + let fd = match Sys::open(crate::c_str::CStr::from_bytes_with_nul(path.as_bytes()).unwrap(), crate::header::fcntl::O_WRONLY, 0) { Ok(fd) => fd, Err(Errno(code)) => return code, }; @@ -592,8 +592,8 @@ pub unsafe extern "C" fn pthread_getname_np( { let thread = unsafe { &*thread.cast::() }; let os_tid = unsafe { thread.os_tid.get().read() }; - let path = alloc::format!("proc:{}/name", os_tid.thread_fd); - let fd = match Sys::open(&path, crate::header::fcntl::O_RDONLY, 0) { + let path = alloc::format!("proc:{}/name\0", os_tid.thread_fd); + let fd = match Sys::open(crate::c_str::CStr::from_bytes_with_nul(path.as_bytes()).unwrap(), crate::header::fcntl::O_RDONLY, 0) { Ok(fd) => fd, Err(Errno(code)) => return code, };