I want to use nix::mount::mount() to replace with libc::mount(). Now I have the followed code :
libc::mount(ptr::null(), path.as_ptr(), ptr::null(), libc:: MS_SLAVE, ptr::null())
I just want to know how to replace the ptr::null() in nix library, I try to use 'None' to do it, but failed. Please help me, thanks.
``
39 | nix::mount::mount(
| ^^^^^^^^^^^^^^^^^ cannot infer type for type parameter
P1declared on the function
mount|
::: /root/.cargo/registry/src/mirrors.ustc.edu.cn-15f9db60536bad60/nix-0.19.0/src/mount.rs:57:27
|
57 | pub fn mount<P1: ?Sized + NixPath, P2: ?Sized + NixPath, P3: ?Sized + NixPath, P4: ?Sized + NixPath>(
| ------- required by this bound in
nix::mount::mount|
= note: cannot satisfy
_: nix::NixPath`
nix::mount::<str, str, str, str>
or something like that.
#include <stdio.h>
#include <sys/stat.h>
int main(void) {
struct stat stat_r;
stat("somefile", &stat_r);
if(S_ISREG(stat_r.st_mode)){
printf("regular file");
return;
}
if(S_ISDIR(stat_r.st_mode)){
printf("directory");
return;
}
if(S_ISBLK(stat_r.st_mode)){
printf("block device");
return;
}
if(S_ISCHR(stat_r.st_mode)){
printf("character device");
return;
}
if(S_ISSOCK(stat_r.st_mode)){
printf("socket");
return;
}
}
libc::syscall
on Linux. fcntl::copy_file_range and unistd::gettid, for example.
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
git-gamble
];
}
(it could be from something else than nixpkgs
)