Hello,
I am trying to mount an file in my Centos 7 server.
Here is my code: syscall.Mount(src, dst, "auto", syscall.MS_BIND, "ro")
The issue is file is being mounted but not as read-only, it is mounting as read-write.
Hi @monsterlegend99, I’d like to help but I am a bit confused about “mounting a file”. I know I can mount a filesystem, but mounting a single file is new to me. (Although I can see that it works from your cat ouput.)
Does syscall.Mount() return any non-nill error?
From a Go point of view, did you try the package golang.org/x/sys/unix instead of syscall already?
The syscall package is deprecated and locked down, and maybe there is just a bug in syscall.Mount that has been fixed in unix.Mount already (just a wild guess).
Also, this SO thread indicates that “auto” does not work well with syscall.Mount. Maybe try passing “ext4” instead.