Commit 5b4109b4 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Call syscall.Unmount directly if we're root.

Don't run TestAccess for root.
parent 8cb5bb39
......@@ -389,6 +389,10 @@ func TestOverwriteRename(t *testing.T) {
}
func TestAccess(t *testing.T) {
if os.Geteuid() == 0 {
t.Log("Skipping TestAccess() as root.")
return
}
me := NewTestCase(t)
defer me.Cleanup()
......
......@@ -8,6 +8,7 @@ import (
"path/filepath"
"strings"
"syscall"
"time"
"unsafe"
)
......@@ -85,6 +86,23 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
}
func unmount(mountPoint string) (err os.Error) {
if os.Geteuid() == 0 {
maxTry := 2
delay := int64(0)
errNo := 0
// A file close operation must be processed and acked
// by the daemon. This takes some time, so retry if
// the first unmount fails.
for try := 0; try < maxTry; try++ {
errNo = syscall.Unmount(mountPoint, 0)
if errNo == 0 {
return nil
}
delay = 2*delay + 0.01e9
time.Sleep(delay)
}
return os.Errno(errNo)
}
dir, _ := filepath.Split(mountPoint)
proc, err := os.StartProcess(mountBinary,
[]string{mountBinary, "-u", mountPoint},
......
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