Skip to content



lock - locks a file or an entire filesystem.


The lock syscall is used to set, reset or test for the presence of a lock on a file or an entire filesystem. It can be used to prevent concurrent access to a file by multiple processes. When a lock is set, other processes are prevented from accessing the file until the lock is released. The lock allows synchronizing the access to the file and this may improve performance if multiple processes need to use the same data. However, the lock syscall itself prevents the access to a file and should be used only when absolutely necessary, otherwise it can cause performance degradation and even deadlocks.


  • fd:int[K] - a file descriptor that must be open for reading or writing
  • cmd:int[K] - specifies the operation to be performed. This can be F_SETLK, F_SETLKW or F_GETLK
  • lock:struct flock[K] - points to a struct flock which contains the members l_type, l_whence, l_start, l_len and l_pid.

Available Tags

  • K - Originated from kernel-space.






The kernel function do_fcntl is the entry point for the fcntl syscall, one of the primary system calls for file control. Specifically, it handles the lock operation, which is used for locking files and filesystems.

Example Use Case

The lock syscall can be used to ensure file access by multiple processes is mutually exclusive and can improve performance when working with the same data.


If the lock is not properly released, due to a crash or program being terminated, it can cause a deadlock and all following processes will be blocked.

  • fcntl - gathers generic information about the fcntl syscall.
  • read - triggers when a number of bytes was read from a file descriptor.
  • write - triggers when a number of bytes was written to a file descriptor.

This document was automatically generated by OpenAI and needs review. It might not be accurate and might contain errors. The authors of Tracee recommend that the user reads the "events.go" source file to understand the events and their arguments better.