parent
ffe3eb03da
commit
b6e2754edf
|
@ -12,6 +12,17 @@ import (
|
||||||
"golang.org/x/sys/unix"
|
"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) {
|
func fusermount(dir string, cfg *MountConfig) (*os.File, error) {
|
||||||
// Create a socket pair.
|
// Create a socket pair.
|
||||||
fds, err := syscall.Socketpair(syscall.AF_FILE, syscall.SOCK_STREAM, 0)
|
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.
|
// Start fusermount, passing it a buffer in which to write stderr.
|
||||||
var stderr bytes.Buffer
|
var stderr bytes.Buffer
|
||||||
|
|
||||||
|
fusermount, err := findFusermount()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
"fusermount",
|
fusermount,
|
||||||
"-o", cfg.toOptionsString(),
|
"-o", cfg.toOptionsString(),
|
||||||
"--",
|
"--",
|
||||||
dir,
|
dir,
|
||||||
|
|
|
@ -7,8 +7,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func unmount(dir string) error {
|
func unmount(dir string) error {
|
||||||
// Call fusermount.
|
fusermount, err := findFusermount()
|
||||||
cmd := exec.Command("fusermount", "-u", dir)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd := exec.Command(fusermount, "-u", dir)
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if len(output) > 0 {
|
if len(output) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue