From 0888482d8ac8b22b4008492e246e281163d633d2 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 24 Mar 2015 12:56:01 +1100 Subject: [PATCH] Implemented msync helper. --- samples/flushfs/flush_fs_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/samples/flushfs/flush_fs_test.go b/samples/flushfs/flush_fs_test.go index 403e6ee..c716259 100644 --- a/samples/flushfs/flush_fs_test.go +++ b/samples/flushfs/flush_fs_test.go @@ -24,6 +24,9 @@ import ( "runtime" "syscall" "testing" + "unsafe" + + "golang.org/x/sys/unix" "github.com/jacobsa/bazilfuse" "github.com/jacobsa/fuse/fsutil" @@ -174,7 +177,20 @@ func dup2(oldfd int, newfd int) (err error) { } // Call msync(2) on a slice previously returned by mmap(2). -func msync(p []byte) (err error) +func msync(p []byte) (err error) { + _, _, errno := unix.Syscall( + unix.SYS_MMAP, + uintptr(unsafe.Pointer(&p[0])), + uintptr(len(p)), + 0) + + if errno != 0 { + err = errno + return + } + + return +} //////////////////////////////////////////////////////////////////////// // No errors