prefer fusermount3 (from FUSE 3), fall back to old fusermount

fixes #84
geesefs-0-30-9
Michael Stapelberg 3 years ago
parent ffe3eb03da
commit b6e2754edf
  1. 17
      mount_linux.go
  2. 7
      unmount_linux.go

@ -12,6 +12,17 @@ import (
"golang.org/x/sys/unix"
)
func findFusermount() (string, error) {
path, err := exec.LookPath("fusermount3")
if err != nil {
path, err = exec.LookPath("fusermount")
}
if err != nil {
return "", err
}
return path, nil
}
func fusermount(dir string, cfg *MountConfig) (*os.File, error) {
// Create a socket pair.
fds, err := syscall.Socketpair(syscall.AF_FILE, syscall.SOCK_STREAM, 0)
@ -29,8 +40,12 @@ func fusermount(dir string, cfg *MountConfig) (*os.File, error) {
// Start fusermount, passing it a buffer in which to write stderr.
var stderr bytes.Buffer
fusermount, err := findFusermount()
if err != nil {
return nil, err
}
cmd := exec.Command(
"fusermount",
fusermount,
"-o", cfg.toOptionsString(),
"--",
dir,

@ -7,8 +7,11 @@ import (
)
func unmount(dir string) error {
// Call fusermount.
cmd := exec.Command("fusermount", "-u", dir)
fusermount, err := findFusermount()
if err != nil {
return err
}
cmd := exec.Command(fusermount, "-u", dir)
output, err := cmd.CombinedOutput()
if err != nil {
if len(output) > 0 {

Loading…
Cancel
Save