diff options
Diffstat (limited to 'bolt_linux.go')
-rw-r--r-- | bolt_linux.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bolt_linux.go b/bolt_linux.go index 4351db5..9aba955 100644 --- a/bolt_linux.go +++ b/bolt_linux.go @@ -7,6 +7,27 @@ import ( var odirect = syscall.O_DIRECT +// fdatasync flushes written data to a file descriptor. func fdatasync(f *os.File) error { return syscall.Fdatasync(int(f.Fd())) } + +// flock acquires an advisory lock on a file descriptor. +func flock(f *os.File) error { + return syscall.Flock(int(f.Fd()), syscall.LOCK_EX) +} + +// funlock releases an advisory lock on a file descriptor. +func funlock(f *os.File) error { + return syscall.Flock(int(f.Fd()), syscall.LOCK_UN) +} + +// mmap memory maps a file to a byte slice. +func mmap(f *os.File, sz int) ([]byte, error) { + return syscall.Mmap(int(f.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED) +} + +// munmap unmaps a pointer from a file. +func munmap(b []byte) error { + return syscall.Munmap(b) +} |