Commit 934a183e authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher

fuse: prefer fusermount3 over fusermount; add debug output

fusermount is (usually) from libfuse v2, and fusermount3 is from
libfuse v3, which is the actively-developed version.

Importantly, libfuse v3 added ExFAT to the list of filesystems
that users are allowed to mount on, and libfuse v2 did not.

The only ABI difference between fusermount and fusermount3 that
I am aware of is that fusermount3 dropped the allow_empty option.

Filesystems had to deal with that already, as fusermount may
also be from libfuse v3, depending on what the distro does.

This commit also adds two lines of debug output about which binary
we actually call.

Passes all.bash & the gocryptfs test suite.

Fixes https://github.com/hanwen/go-fuse/issues/394
Fixes https://github.com/rfjakob/gocryptfs/issues/626

Change-Id: Id4574fb9c8d2c812a524181a76616159256d551c
parent 3ab5d95a
......@@ -72,7 +72,8 @@ func mountDirect(mountPoint string, opts *MountOptions, ready chan<- error) (fd
// that it:
// * opens `/dev/fuse`
// * mount()s this file descriptor to `mountPoint`
// * passes this file descriptor back to use via a unix domain socket
// * passes this file descriptor back to us via a unix domain socket
// This file descriptor is returned as `fd`.
func callFusermount(mountPoint string, opts *MountOptions) (fd int, err error) {
local, remote, err := unixgramSocketpair()
if err != nil {
......@@ -91,6 +92,9 @@ func callFusermount(mountPoint string, opts *MountOptions) (fd int, err error) {
if s := opts.optionsStrings(); len(s) > 0 {
cmd = append(cmd, "-o", strings.Join(s, ","))
}
if opts.Debug {
log.Printf("callFusermount: executing %q", cmd)
}
proc, err := os.StartProcess(bin,
cmd,
&os.ProcAttr{
......@@ -168,6 +172,9 @@ func unmount(mountPoint string, opts *MountOptions) (err error) {
errBuf := bytes.Buffer{}
cmd := exec.Command(bin, "-u", mountPoint)
cmd.Stderr = &errBuf
if opts.Debug {
log.Printf("unmount: executing %q", cmd.Args)
}
err = cmd.Run()
if errBuf.Len() > 0 {
return fmt.Errorf("%s (code %v)\n",
......@@ -215,7 +222,12 @@ func lookPathFallback(file string, fallbackDir string) (string, error) {
return exec.LookPath(abs)
}
// fusermountBinary returns the path to the `fusermount3` binary, or, if not
// found, the `fusermount` binary.
func fusermountBinary() (string, error) {
if path, err := lookPathFallback("fusermount3", "/bin"); err == nil {
return path, nil
}
return lookPathFallback("fusermount", "/bin")
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment