Imports #
"internal/syscall/windows"
"io/fs"
"syscall"
"errors"
"io/fs"
"errors"
"io"
"io/fs"
"math/rand"
"sync"
"syscall"
"time"
"errors"
"io/fs"
"io/fs"
"syscall"
"internal/syscall/windows"
"io/fs"
"syscall"
"errors"
"io/fs"
"errors"
"io"
"io/fs"
"math/rand"
"sync"
"syscall"
"time"
"errors"
"io/fs"
"io/fs"
"syscall"
const allBytes = *ast.UnaryExprvar inodes = map[File]inode{...}var locks = map[inode]inodeLock{...}var mu sync.Mutexconst readLock lockType = syscall.F_RDLCKconst readLock lockType = 0const readLock = *ast.BinaryExprconst readLock lockType = syscall.LOCK_SHconst reserved = 0const writeLock lockType = syscall.F_WRLCKconst writeLock lockType = windows.LOCKFILE_EXCLUSIVE_LOCKconst writeLockconst writeLock lockType = syscall.LOCK_EXtype inode uint64type lockType uint32type lockType int16type lockType int8type lockType int16A File provides the minimal set of methods required to lock an open file. File implementations must be usable as map keys. The usual implementation is *os.File.
type File interface {
Name() string
Fd() uintptr
Stat() (fs.FileInfo, error)
}type inodeLock struct {
owner File
queue []<-chan File
}IsNotSupported returns a boolean indicating whether the error is known to report that a function is not supported (possibly for a specific input). It is satisfied by errors.ErrUnsupported as well as some syscall errors.
func IsNotSupported(err error) boolLock places an advisory write lock on the file, blocking until it can be locked. If Lock returns nil, no other process will be able to place a read or write lock on the file until this process exits, closes f, or calls Unlock on it. If f's descriptor is already read- or write-locked, the behavior of Lock is unspecified. Closing the file may or may not release the lock promptly. Callers should ensure that Unlock is always called when Lock succeeds.
func Lock(f File) errorRLock places an advisory read lock on the file, blocking until it can be locked. If RLock returns nil, no other process will be able to place a write lock on the file until this process exits, closes f, or calls Unlock on it. If f is already read- or write-locked, the behavior of RLock is unspecified. Closing the file may or may not release the lock promptly. Callers should ensure that Unlock is always called if RLock succeeds.
func RLock(f File) errorString returns the name of the function corresponding to lt (Lock, RLock, or Unlock).
func (lt lockType) String() stringUnlock removes an advisory lock placed on f by this process. The caller must not attempt to unlock a file that is not locked.
func Unlock(f File) errorfunc lock(f File, lt lockType) errorfunc lock(f File, lt lockType) (err error)func lock(f File, lt lockType) errorfunc lock(f File, lt lockType) (err error)setlkw calls FcntlFlock with F_SETLKW for the entire file indicated by fd.
func setlkw(fd uintptr, lt lockType) errorfunc unlock(f File) errorfunc unlock(f File) errorfunc unlock(f File) errorfunc unlock(f File) errorGenerated with Arrow