github.com/fisco-bcos/crypto@v0.0.0-20200202032121-bd8ab0b5d4f1/internal/poll/fd_fsync_darwin.go (about)

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package poll
     6  
     7  import (
     8  	"syscall"
     9  	_ "unsafe" // for go:linkname
    10  )
    11  
    12  // Fsync invokes SYS_FCNTL with SYS_FULLFSYNC because
    13  // on OS X, SYS_FSYNC doesn't fully flush contents to disk.
    14  // See Issue #26650 as well as the man page for fsync on OS X.
    15  func (fd *FD) Fsync() error {
    16  	if err := fd.incref(); err != nil {
    17  		return err
    18  	}
    19  	defer fd.decref()
    20  
    21  	_, e1 := fcntl(fd.Sysfd, syscall.F_FULLFSYNC, 0)
    22  	return e1
    23  }
    24  
    25  // Implemented in syscall/syscall_darwin.go.
    26  //go:linkname fcntl syscall.fcntl
    27  func fcntl(fd int, cmd int, arg int) (int, error)