Commit 41b8187f authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

mount_linux: Also try absolute path for fusermount and umount

Assuming that the loopback example binary is at /bin/loopbackfs,
you can mount like this:

	mount -t fuse.loopbackfs /tmp/mountpoint /tmp/original

However, "mount" passes an empty PATH to loopbackfs.
Trying the absolute path too fixes the issue.

This is in preparation of porting xfstests to go-fuse.
parent 9c1a7bb0
package fuse package fuse
import ( import (
"path"
"bytes" "bytes"
"fmt" "fmt"
"log" "log"
...@@ -120,13 +121,25 @@ func getConnection(local *os.File) (int, error) { ...@@ -120,13 +121,25 @@ func getConnection(local *os.File) (int, error) {
return int(fd), nil return int(fd), nil
} }
// lookPathFallback - search binary in PATH and, if that fails,
// in fallbackDir. This is useful if PATH is possible empty.
func lookPathFallback(file string, fallbackDir string) (string, error) {
binPath, err := exec.LookPath(file)
if err == nil {
return binPath, nil
}
abs := path.Join(fallbackDir, file)
return exec.LookPath(abs)
}
func init() { func init() {
var err error var err error
fusermountBinary, err = exec.LookPath("fusermount") fusermountBinary, err = lookPathFallback("/bin/fusermount", "/bin")
if err != nil { if err != nil {
log.Fatalf("Could not find fusermount binary: %v", err) log.Fatalf("Could not find fusermount binary: %v", err)
} }
umountBinary, _ = exec.LookPath("umount") umountBinary, err = lookPathFallback("umount", "/bin")
if err != nil { if err != nil {
log.Fatalf("Could not find umount binary: %v", err) log.Fatalf("Could not find umount binary: %v", err)
} }
......
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