Skip to main content

c_scape/process/
chroot.rs

1use core::ffi::CStr;
2
3use libc::{c_char, c_int};
4
5use crate::convert_res;
6
7#[no_mangle]
8unsafe extern "C" fn chroot(path: *const c_char) -> c_int {
9    libc!(libc::chroot(path));
10
11    let path = CStr::from_ptr(path.cast());
12    match convert_res(rustix::process::chroot(path)) {
13        Some(()) => 0,
14        None => -1,
15    }
16}