on_lock Event
Fires when the OS needs to lock or unlock the range of bytes of a file.
Syntax
class FUSELockEventParams(object): @property def path() -> str: ... @property def file_context() -> int: ... @property def lock_type() -> int: ... @property def lock_start() -> int: ... @property def lock_len() -> int: ... @property def cmd() -> int: ... @property def lock_owner() -> int: ... @property def lock_pid() -> int: ... @lock_pid.setter def lock_pid(value) -> None: ... @property def result() -> int: ... @result.setter def result(value) -> None: ... # In class FUSE: @property def on_lock() -> Callable[[FUSELockEventParams], None]: ... @on_lock.setter def on_lock(event_hook: Callable[[FUSELockEventParams], None]) -> None: ...
Remarks
This event fires when the OS needs to lock or unlock the range of bytes of the file, identified by either Path or FileContext. Local locking is performed by the system and your application needs to handle this even when it needs to perform an operation over the network.
LockType identifies whether the range is to be locked or unlocked. It can be one of the following:
FUSE_RDLCK | 0x0000 | Read lock should be acquired.
Other applications may read from the locked range but not write to it. The constant is the same as F_RDLCK constant in Linux. |
FUSE_WRLCK | 0x0001 | Write lock should be acquired.
No other application may write to the locked range. The constant is the same as F_WRLCK constant in Linux. |
FUSE_UNLCK | 0x0002 | The lock should be released.
The constant is the same as F_UNLCK constant in Linux. |
LockStart and LockLen specify the starting position and the length of the block to be locked or unlocked. Cmd can be one of
FUSE_GETLK | 0x0005 | The lock owner is to be retrieved.
This command is not used in Windows. In Linux, the PID of the lock owner must be returned. The constant is the same as F_GETLK constant in Linux. |
FUSE_SETLK | 0x0006 | Set lock.
If the lock cannot be set immediately, return immediately with an error (EAGAIN and EACCES are recommended). The constant is the same as F_SETLK constant in Linux. |
FUSE_SETLKW | 0x0007 | Set lock and wait.
If the lock cannot be set immediately, wait until this becomes possible. The constant is the same as F_SETLKW constant in Linux. |
Windows:
LockOwner, and LockPid parameters are not used and are set to 0.
Linux:
This event fires for a POSIX style lock. For additional information about LockOwner and other parameters, please, refer to http://libfuse.github.io/doxygen/structfuse__operations.html#a1c3fff5cf0c1c2003d117e764b9a76fd.
if Cmd is F_GETLK, the event handler should place the PID of the owner process to the LockPid parameter.
The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a negative error code value (e.g. -ENOENT to indicate that the file does not exist) to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.