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

Make Unmount issue notify.

Drop sleep statements for unmount tests.
parent 7b7b45dc
......@@ -85,23 +85,28 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
return
}
func unmount(mountPoint string) (err os.Error) {
if os.Geteuid() == 0 {
maxTry := 2
delay := int64(0)
errNo := 0
func privilegedUnmount(mountPoint string) os.Error {
maxTry := 2
delay := int64(0)
errNo := syscall.Unmount(mountPoint, 0)
for try := 0; errNo != 0 && try < maxTry; try++ {
// 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)
delay = 2*delay + 0.01e9
time.Sleep(delay)
errNo = syscall.Unmount(mountPoint, 0)
}
if errNo == 0 {
return nil
}
return os.Errno(errNo)
}
func unmount(mountPoint string) (err os.Error) {
if os.Geteuid() == 0 {
return privilegedUnmount(mountPoint)
}
dir, _ := filepath.Split(mountPoint)
proc, err := os.StartProcess(mountBinary,
......
......@@ -593,6 +593,11 @@ func (me *FileSystemConnector) Unmount(path string) Status {
}
me.unsafeUnmountNode(node)
notifyMessage := NotifyInvalInodeOut{
Ino: node.NodeId,
}
me.fsInit.InodeNotify(&notifyMessage)
return OK
}
......
......@@ -7,7 +7,6 @@ import (
"fmt"
"log"
"testing"
"time"
)
var _ = fmt.Print
......@@ -93,10 +92,6 @@ func TestAutoFsSymlink(t *testing.T) {
err = os.Remove(wd + "/mount/config/manual1")
CheckSuccess(err)
// Need time for the unmount to be noticed.
log.Println("sleeping...")
time.Sleep(2 * entryTtl * 1e9)
scan := wd + "/mount/config/" + _SCAN_CONFIG
err = ioutil.WriteFile(scan, []byte("something"), 0644)
if err != nil {
......
......@@ -6,7 +6,6 @@ import (
"log"
"os"
"testing"
"time"
)
var _ = log.Printf
......@@ -92,10 +91,6 @@ func TestMultiZipFs(t *testing.T) {
err = os.Remove(mountPoint + "/config/zipmount")
CheckSuccess(err)
// This is ugly but necessary: We don't have ways to signal
// back to FUSE that the file disappeared.
time.Sleep(1.5e9 * testTtl)
fi, err = os.Stat(mountPoint + "/zipmount")
if err == nil {
t.Error("stat should fail after unmount.", fi)
......
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