Merge "fuse: Enable tests on Linux; make them pass"

This commit is contained in:
Brad Fitzpatrick 2013-12-27 20:52:46 +00:00 committed by Gerrit Code Review
commit bce395b9b3
2 changed files with 34 additions and 7 deletions

View File

@ -50,7 +50,7 @@ func condSkip(t *testing.T) {
if lasterr != nil {
t.Skipf("Skipping test; some other test already failed.")
}
if runtime.GOOS != "darwin" {
if !(runtime.GOOS == "darwin" || runtime.GOOS == "linux") {
t.Skipf("Skipping test on OS %q", runtime.GOOS)
}
if runtime.GOOS == "darwin" {
@ -567,6 +567,10 @@ func dirToBeFUSE(dir string) func() bool {
}
return false
}
if runtime.GOOS == "linux" {
return strings.Contains(string(out), "/dev/fuse") &&
strings.Contains(string(out), dir)
}
return false
}
}

View File

@ -646,25 +646,48 @@ func (h *mutFileHandle) Write(req *fuse.WriteRequest, res *fuse.WriteResponse, i
return nil
}
func (h *mutFileHandle) Release(req *fuse.ReleaseRequest, intr fuse.Intr) fuse.Error {
// Flush is called to let the file system clean up any data buffers
// and to pass any errors in the process of closing a file to the user
// application.
//
// Flush *may* be called more than once in the case where a file is
// opened more than once, but it's not possible to detect from the
// call itself whether this is a final flush.
//
// This is generally the last opportunity to finalize data and the
// return value sets the return value of the Close that led to the
// calling of Flush.
//
// Note that this is distinct from Fsync -- which is a user-requested
// flush (fsync, etc...)
func (h *mutFileHandle) Flush(*fuse.FlushRequest, fuse.Intr) fuse.Error {
if h.tmp == nil {
log.Printf("Release called on camli mutFileHandle without a tempfile set")
log.Printf("Flush called on camli mutFileHandle without a tempfile set")
return fuse.EIO
}
log.Printf("mutFileHandle release.")
_, err := h.tmp.Seek(0, 0)
if err != nil {
log.Println("mutFileHandle.Release:", err)
log.Println("mutFileHandle.Flush:", err)
return fuse.EIO
}
var n int64
br, err := schema.WriteFileFromReader(h.f.fs.client, h.f.name, readerutil.CountingReader{Reader: h.tmp, N: &n})
if err != nil {
log.Println("mutFileHandle.Release:", err)
log.Println("mutFileHandle.Flush:", err)
return fuse.EIO
}
err = h.f.setContent(br, n)
if err != nil {
log.Printf("mutFileHandle.Flush: %v", err)
return fuse.EIO
}
h.f.setContent(br, n)
return nil
}
// Release is called when a file handle is no longer needed. This is
// called asynchronously after the last handle to a file is closed.
func (h *mutFileHandle) Release(req *fuse.ReleaseRequest, intr fuse.Intr) fuse.Error {
h.tmp.Close()
os.Remove(h.tmp.Name())
h.tmp = nil