2018-11-28 03:22:20 +05:30
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package osfs
|
|
|
|
|
|
|
|
import (
|
2019-07-31 22:15:42 +05:30
|
|
|
"golang.org/x/sys/unix"
|
2018-11-28 03:22:20 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
func (f *file) Lock() error {
|
|
|
|
f.m.Lock()
|
|
|
|
defer f.m.Unlock()
|
|
|
|
|
2019-07-31 22:15:42 +05:30
|
|
|
return unix.Flock(int(f.File.Fd()), unix.LOCK_EX)
|
2018-11-28 03:22:20 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func (f *file) Unlock() error {
|
|
|
|
f.m.Lock()
|
|
|
|
defer f.m.Unlock()
|
|
|
|
|
2019-07-31 22:15:42 +05:30
|
|
|
return unix.Flock(int(f.File.Fd()), unix.LOCK_UN)
|
2018-11-28 03:22:20 +05:30
|
|
|
}
|