Don't depend on fuseshim for unmounting.

geesefs-0-30-9
Aaron Jacobs 2015-07-24 16:22:03 +10:00
commit d1c58d69c8
3 changed files with 42 additions and 3 deletions

View File

@ -14,10 +14,8 @@
package fuse
import "github.com/jacobsa/fuse/internal/fuseshim"
// Attempt to unmount the file system whose mount point is the supplied
// directory.
func Unmount(dir string) error {
return fuseshim.Unmount(dir)
return unmount(dir)
}

23
unmount_linux.go Normal file
View File

@ -0,0 +1,23 @@
package fuseshim
import (
"bytes"
"fmt"
"os/exec"
)
func unmount(dir string) (err error) {
// Call fusermount.
cmd := exec.Command("fusermount", "-u", dir)
output, err := cmd.CombinedOutput()
if err != nil {
if len(output) > 0 {
output = bytes.TrimRight(output, "\n")
err = fmt.Errorf("%v: %s", err, output)
}
return
}
return
}

18
unmount_std.go Normal file
View File

@ -0,0 +1,18 @@
// +build !linux
package fuse
import (
"os"
"syscall"
)
func unmount(dir string) (err error) {
err = syscall.Unmount(dir, 0)
if err != nil {
err = &os.PathError{Op: "unmount", Path: dir, Err: err}
return
}
return
}