Commit eb61a86c authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: capture fusermount stderr in error return.

parent 76e5775e
package fuse package fuse
import ( import (
"bytes"
"fmt" "fmt"
"log" "log"
"os" "os"
...@@ -81,21 +82,15 @@ func unmount(mountPoint string) (err error) { ...@@ -81,21 +82,15 @@ func unmount(mountPoint string) (err error) {
if os.Geteuid() == 0 { if os.Geteuid() == 0 {
return privilegedUnmount(mountPoint) return privilegedUnmount(mountPoint)
} }
dir, _ := filepath.Split(mountPoint) errBuf := bytes.Buffer{}
proc, err := os.StartProcess(fusermountBinary, cmd := exec.Command(fusermountBinary, "-u", mountPoint)
[]string{fusermountBinary, "-u", mountPoint}, cmd.Stderr = &errBuf
&os.ProcAttr{Dir: dir, Files: []*os.File{nil, nil, os.Stderr}}) err = cmd.Run()
if err != nil { if errBuf.Len() > 0 {
return return fmt.Errorf("%s (code %v)\n",
errBuf.String(), err)
} }
w, err := proc.Wait() return err
if err != nil {
return
}
if !w.Success() {
return fmt.Errorf("fusermount -u exited with code %v\n", w.Sys())
}
return
} }
func getConnection(local *os.File) (int, error) { func getConnection(local *os.File) (int, error) {
......
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