clean up previously mounted folder

This commit is contained in:
chrislu
2022-02-10 20:46:53 -08:00
parent c3f9d9fa2e
commit 7a0c35674c
6 changed files with 58 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
package unmount
import (
"bytes"
"errors"
"os/exec"
)
func unmount(dir string) error {
cmd := exec.Command("fusermount", "-u", dir)
output, err := cmd.CombinedOutput()
if err != nil {
if len(output) > 0 {
output = bytes.TrimRight(output, "\n")
msg := err.Error() + ": " + string(output)
err = errors.New(msg)
}
return err
}
return nil
}