2018-11-27 21:52:20 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package osfs
|
|
|
|
|
|
|
|
import (
|
2019-07-31 16:45:42 +00:00
|
|
|
"golang.org/x/sys/unix"
|
2018-11-27 21:52:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (f *file) Lock() error {
|
|
|
|
f.m.Lock()
|
|
|
|
defer f.m.Unlock()
|
|
|
|
|
2019-07-31 16:45:42 +00:00
|
|
|
return unix.Flock(int(f.File.Fd()), unix.LOCK_EX)
|
2018-11-27 21:52:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *file) Unlock() error {
|
|
|
|
f.m.Lock()
|
|
|
|
defer f.m.Unlock()
|
|
|
|
|
2019-07-31 16:45:42 +00:00
|
|
|
return unix.Flock(int(f.File.Fd()), unix.LOCK_UN)
|
2018-11-27 21:52:20 +00:00
|
|
|
}
|