unmount_linux.go 362 B

123456789101112131415161718192021
  1. package unmount
  2. import (
  3. "bytes"
  4. "errors"
  5. "os/exec"
  6. )
  7. func unmount(dir string) error {
  8. cmd := exec.Command("fusermount", "-u", dir)
  9. output, err := cmd.CombinedOutput()
  10. if err != nil {
  11. if len(output) > 0 {
  12. output = bytes.TrimRight(output, "\n")
  13. msg := err.Error() + ": " + string(output)
  14. err = errors.New(msg)
  15. }
  16. return err
  17. }
  18. return nil
  19. }