Don't depend on fuseshim for unmounting.
commit
d1c58d69c8
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue