Method Fuse.Operations()->lock()


Method lock

mapping(string:int)|int lock(string path, int mode, mapping(string:int) how)

Description

Lock, unlock or test for the existence of record locks (POSIX file locking). The owner of the lock is identified by how->owner

If you only need local file-locking on the computer the filesystem is mounted on you do not need to implement this interface. This is only needed for network filesystems that want locking to work over the network.

The operation mode depends on the mode argument.

Parameter mode
F_SETLK

Acquire a lock (when how->type is F_RDLCK or F_WRLCK) or release a lock (when how->type is F_UNLCK) on the bytes specified by the how->whence, how->start, and how->len fields of lock. If a conflicting lock is held by another process, you should return System.EACCES or System.EAGAIN.

F_SETLKW

Identical to F_SETLK, but if a lock is held on the file, wait for it to be released before returning. You are allowed to return System.EINTR, to signal that the waiting has been interrupted and must be restarted.

F_GETLK

Identical to F_SETLK, but do not actually aquire the lock if it can be aquired. If one or more incompatible locks would prevent this lock being placed, then lock() returns details about one of these locks in the "type", "whence", start, and "len" fields of how and sets the "pid" field to be the PID of the process holding that lock. Then return the mapping.

Parameter how
"owner" : int

Uid of the lock owner (if any).

"type" : int

Type of operation. One of

F_RDLCK

Acquire a read lock.

F_WRLCK

Acquite a write lock.

F_UNLCK

Release a lock.

"whence" : int

How to interpret the "start" field. One of Stdio.SEEK_CUR, Stdio.SEEK_SET or Stdio.SEEK_END.

"start" : int

Start offset of the file path to lock.

"len" : int

Number of bytes starting at "start" to lock.

"pid" : int

Pid of the lock owner (if any).