package rawfilelock
import "github.com/containers/storage/internal/rawfilelock"
Index ¶
- func CloseHandle(fd FileHandle)
- func LockFile(fd FileHandle, lockType LockType) error
- func TryLockFile(fd FileHandle, lockType LockType) error
- func UnlockAndCloseHandle(fd FileHandle)
- type FileHandle
- type LockType
Functions ¶
func CloseHandle ¶
func CloseHandle(fd FileHandle)
CloseHandle closes a file handle without unlocking
WARNING: This is a last-resort function for error handling only! On Unix systems, closing a file descriptor automatically releases any locks, so "closing without unlocking" is impossible. This function will release the lock as a side effect of closing the file.
This function should only be used in error paths where the lock state is already corrupted or when giving up on lock management entirely. Normal code should use UnlockAndCloseHandle instead.
func LockFile ¶
func LockFile(fd FileHandle, lockType LockType) error
LockFile locks a file handle
func TryLockFile ¶
func TryLockFile(fd FileHandle, lockType LockType) error
TryLockFile attempts to lock a file handle
func UnlockAndCloseHandle ¶
func UnlockAndCloseHandle(fd FileHandle)
UnlockAndClose unlocks and closes a file handle
Types ¶
type FileHandle ¶
type FileHandle = fileHandle
func OpenLock ¶
func OpenLock(path string, readOnly bool) (FileHandle, error)
OpenLock opens a file for locking WARNING: This is the underlying file locking primitive of the OS; because closing FileHandle releases the lock, it is not suitable for use if there is any chance of two concurrent goroutines attempting to use the same lock. Most users should use the higher-level operations from internal/staging_lockfile or pkg/lockfile.
type LockType ¶
type LockType byte
Source Files ¶
rawfilelock.go rawfilelock_unix.go
- Version
- v1.59.0 (latest)
- Published
- Jul 14, 2025
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 2 days ago –
Tools for package owners.