dir_plan9.go
dir_plan9.go - Overview
This file implements directory locking for Plan 9 operating systems. It uses exclusive file access via os.ModeExclusive
for locking and a PID file for advisory information. Read-only mode is not supported.
directoryLockGuard
- Purpose: Holds a lock on a directory for Plan 9.
- Fields:
- f:
*os.File
- File handle on the directory, which we've locked. - path:
string
- The absolute path to our PID file.
- f:
acquireDirectoryLock
- Purpose: Acquires a lock on the directory by creating an exclusive-use PID file.
- Parameters:
- dirPath:
string
- The path to the directory to lock. - pidFileName:
string
- The name of the PID file. - readOnly:
bool
- Indicates whether to acquire a read-only lock (not supported on Plan 9).
- dirPath:
- Returns:
*directoryLockGuard
- A pointer to the directoryLockGuard struct on success.error
- An error if the lock could not be acquired.
directoryLockGuard.release
- Purpose: Releases the lock by deleting the PID file and closing the file handle.
- Parameters: None
- Returns:
error
- An error, if any.
openDir
- Purpose: Opens a directory for syncing.
- Parameters:
- path:
string
- The path to the directory.
- path:
- Returns:
*os.File
- A pointer to the opened file.error
- An error, if any.
syncDir
- Purpose: Ensures the directory entry for the file is synced.
- Parameters:
- dir:
string
- The directory to sync.
- dir:
- Returns:
error
- An error, if any.
isLocked
- Purpose: Checks if an error indicates that a file is locked.
- Parameters:
- err:
error
- The error to check.
- err:
- Returns:
bool
- True if the error indicates the file is locked, false otherwise.