Lock Event

Fires when the OS needs to lock or unlock the range of bytes of a file.

Syntax

// FUSELockEventArgs carries the FUSE Lock event's parameters.
type FUSELockEventArgs struct {...}

func (args *FUSELockEventArgs) Path() string
func (args *FUSELockEventArgs) FileContext() int32
func (args *FUSELockEventArgs) LockType() int32
func (args *FUSELockEventArgs) LockStart() int64
func (args *FUSELockEventArgs) LockLen() int64
func (args *FUSELockEventArgs) Cmd() int32
func (args *FUSELockEventArgs) LockOwner() int64
func (args *FUSELockEventArgs) LockPid() int32
func (args *FUSELockEventArgs) SetLockPid(value int32)
func (args *FUSELockEventArgs) Result() int32
func (args *FUSELockEventArgs) SetResult(value int32)

// FUSELockEvent defines the signature of the FUSE Lock event's handler function.
type FUSELockEvent func(sender *FUSE, args *FUSELockEventArgs)

func (obj *FUSE) GetOnLockHandler() FUSELockEvent
func (obj *FUSE) SetOnLockHandler(handlerFunc FUSELockEvent)

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_RDLCK0x0000Read 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_WRLCK0x0001Write 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_UNLCK0x0002The 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_GETLK0x0005The 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_SETLK0x0006Set 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_SETLKW0x0007Set 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.

Copyright (c) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS FUSE 2020 Go Edition - Version 20.0 [Build 8348]