Open
Description
Mounting cgroupsv2 in linux requires passing NULL as the data parameter of the mount syscall. NixPath coerces None into an empty string instead. Constructing a null CStr is a little tricky and requires unsafe.
You can see the check in kernel/cgroup/cgroup.c. Mount returns EINVAL and the kernel prints cgroup2: unknown option ""
.
I was able to workaround by defining this struct
struct NullString;
impl nix::NixPath for NullString {
fn len(&self) -> usize { 0 }
fn with_nix_path<T, F>(&self, f: F) -> nix::Result<T>
where F: FnOnce(&CStr) -> T {
Ok(f(unsafe {
// CStr::from_ptr calls strlen and segfaults
CStr::from_bytes_with_nul_unchecked(
std::slice::from_raw_parts(std::ptr::null(), 0))
}))
}
}
And then providing Some(&NullString)
as the data argument of mount. I saw #221 about redesigning NixPath so I didn't want to attempt "fixing" this.
Activity