I'm writing a filesystem using FUSE, but the sample shows that it only accepts one parameter
./hello ~/mount_point
but if I want to use FUSE to manage a device and mount it to a certain mount point, what should I do?
when doing this:
./hello /dev/nvme0n2 ~/mount_point
it reports an error:
fuse: invalid argument `~/mount_point'
Since you want to manage another device, I recommend starting from libfuse example "passthrough" and not "hello". "passthrough" would pass all file operations coming from your fuse mount down to your underlying device mount.
The mount of the HD device should be inside your code, with C function mount
. For instance, you could call it in the main
function in (your modified) passthrough.c
.
Additionally, you can see in main
how it takes additional user arguments in which you can pass the device path, as you asked about.
One thing to notice is that you need to mount a partition of this device, and not the path you used. See here: https://unix.stackexchange.com/questions/729980/bad-magic-number-while-trying-to-mount-a-new-hard-disk