I'm trying to use the syscall.Mount function to mount a usb pendrive and autodetect the filesystem to some folder. I fetch the device path from the kernel's netlink socket and try to mount it to /tmp/+devicename
, in my instance /dev/sdd1
should be mounted to /tmp/sdd1
I have the following lines of code in a go program
if err := syscall.Mount(src, target, "auto", 0, "ro"); err != nil {
log.Printf("Mount(\"%s\", \"%s\", \"auto\", 0, \"ro\")
",src,target)
log.Fatal(err)
}
Output:
main.go:47: Mount("/dev/sdd1", "/tmp/sdd1", "auto", 0, "ro")
main.go:48: no such device
I'm running the application with root privileges with "sudo", however it seems unable to mount using the syscall package. If i however in the terminal type sudo mount /dev/sdd1 /tmp/sdd1
then that works fine.
What is the issue here? Is the device path somehow different when using the system call?
Any help is appreciated. Cheers