mirror of
https://github.com/etcd-io/bbolt.git
synced 2025-04-27 21:23:15 +00:00
OpenBSD does not include a UBC kernel and writes must be synchronized with the msync(2) syscall. In addition, the NoSync field of the DB struct should be ignored on OpenBSD, since unlike other platforms, missing msyncs will result in data corruption. Depends on PR #258. Fixes #257.
30 lines
535 B
Go
30 lines
535 B
Go
package bolt
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
const (
|
|
msAsync = 1 << iota // perform asynchronous writes
|
|
msSync // perform synchronous writes
|
|
msInvalidate // invalidate cached data
|
|
)
|
|
|
|
var odirect int
|
|
|
|
func msync(db *DB) error {
|
|
_, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate)
|
|
if errno != 0 {
|
|
return errno
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func fdatasync(db *DB) error {
|
|
if db.data != nil {
|
|
return msync(db)
|
|
}
|
|
return db.file.Sync()
|
|
}
|