Fixed fdatasync build errors on darwin.

geesefs-0-30-9
Aaron Jacobs 2015-03-24 12:31:16 +11:00
parent cf22c43238
commit e4e12848fb
2 changed files with 18 additions and 3 deletions

View File

@ -48,3 +48,10 @@ func AnonymousFile(dir string) (f *os.File, err error) {
return
}
// Call fdatasync on the supplied file.
//
// REQUIRES: FdatasyncSupported is true.
func Fdatasync(f *os.File) error {
return fdatasync(f)
}

View File

@ -413,6 +413,10 @@ func (t *NoErrorsTest) Fdatasync() {
var n int
var err error
if !fsutil.FdatasyncSupported {
return
}
// Open the file.
t.f1, err = os.OpenFile(path.Join(t.Dir, "foo"), os.O_WRONLY, 0)
AssertEq(nil, err)
@ -426,7 +430,7 @@ func (t *NoErrorsTest) Fdatasync() {
AssertThat(t.getFsyncs(), ElementsAre())
// Fdatasync.
err = syscall.Fdatasync(int(t.f1.Fd()))
err = fsutil.Fdatasync(t.f1)
AssertEq(nil, err)
AssertThat(t.getFlushes(), ElementsAre())
@ -441,7 +445,7 @@ func (t *NoErrorsTest) Fdatasync() {
AssertThat(t.getFsyncs(), ElementsAre("taco"))
// Fdatasync.
err = syscall.Fdatasync(int(t.f1.Fd()))
err = fsutil.Fdatasync(t.f1)
AssertEq(nil, err)
AssertThat(t.getFlushes(), ElementsAre())
@ -789,12 +793,16 @@ func (t *FsyncErrorTest) Fsync() {
func (t *FsyncErrorTest) Fdatasync() {
var err error
if !fsutil.FdatasyncSupported {
return
}
// Open the file.
t.f1, err = os.OpenFile(path.Join(t.Dir, "foo"), os.O_RDWR, 0)
AssertEq(nil, err)
// Fdatasync.
err = syscall.Fdatasync(int(t.f1.Fd()))
err = fsutil.Fdatasync(t.f1)
ExpectThat(err, Error(HasSubstr("no such file")))
}