filelock

Imports

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"

Constants & Variables

allBytes const #

const allBytes = *ast.UnaryExpr

inodes var #

var inodes = map[File]inode{...}

locks var #

var locks = map[inode]inodeLock{...}

mu var #

var mu sync.Mutex

readLock const #

const readLock lockType = syscall.F_RDLCK

readLock const #

const readLock lockType = 0

readLock const #

const readLock = *ast.BinaryExpr

readLock const #

const readLock lockType = syscall.LOCK_SH

reserved const #

const reserved = 0

writeLock const #

const writeLock lockType = syscall.F_WRLCK

writeLock const #

const writeLock lockType = windows.LOCKFILE_EXCLUSIVE_LOCK

writeLock const #

const writeLock

writeLock const #

const writeLock lockType = syscall.LOCK_EX

Type Aliases

inode type #

type inode uint64

lockType type #

type lockType uint32

lockType type #

type lockType int16

lockType type #

type lockType int8

lockType type #

type lockType int16

Interfaces

File interface #

A 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)
}

Structs

inodeLock struct #

type inodeLock struct {
owner File
queue []<-chan File
}

Functions

IsNotSupported function #

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) bool

Lock function #

Lock 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) error

RLock function #

RLock 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) error

String method #

String returns the name of the function corresponding to lt (Lock, RLock, or Unlock).

func (lt lockType) String() string

Unlock function #

Unlock 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) error

lock function #

func lock(f File, lt lockType) error

lock function #

func lock(f File, lt lockType) (err error)

lock function #

func lock(f File, lt lockType) error

lock function #

func lock(f File, lt lockType) (err error)

setlkw function #

setlkw calls FcntlFlock with F_SETLKW for the entire file indicated by fd.

func setlkw(fd uintptr, lt lockType) error

unlock function #

func unlock(f File) error

unlock function #

func unlock(f File) error

unlock function #

func unlock(f File) error

unlock function #

func unlock(f File) error

Generated with Arrow