github.com/coocood/badger@v1.5.1-0.20200528065104-c02ac3616d04/fileutil/sync_linux.go (about)

     1  // +build linux
     2  
     3  package fileutil
     4  
     5  import (
     6  	"os"
     7  
     8  	"golang.org/x/sys/unix"
     9  )
    10  
    11  // Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform.
    12  func Fsync(f *os.File) error {
    13  	return f.Sync()
    14  }
    15  
    16  // Fdatasync is similar to fsync(), but does not flush modified metadata
    17  // unless that metadata is needed in order to allow a subsequent data retrieval
    18  // to be correctly handled.
    19  func Fdatasync(f *os.File) error {
    20  	return unix.Fdatasync(int(f.Fd()))
    21  }