| 1 |
.\" Copyright 1994-1995, Daniel Quinlan <[email protected]> |
| 2 |
.\" Copyright 2002-2017, Michael Kerrisk <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: GPL-3.0-or-later |
| 6 |
.\" |
| 7 |
.TH proc_locks 5 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
/proc/locks \- current file locks and leases |
| 10 |
.SH DESCRIPTION |
| 11 |
.TP |
| 12 |
.I /proc/locks |
| 13 |
This file shows current file locks |
| 14 |
(\c |
| 15 |
.BR flock (2) |
| 16 |
and |
| 17 |
.BR fcntl (2)) |
| 18 |
and leases |
| 19 |
(\c |
| 20 |
.BR fcntl (2)). |
| 21 |
.IP |
| 22 |
An example of the content shown in this file is the following: |
| 23 |
.IP |
| 24 |
.in +4n |
| 25 |
.EX |
| 26 |
1: POSIX ADVISORY READ 5433 08:01:7864448 128 128 |
| 27 |
2: FLOCK ADVISORY WRITE 2001 08:01:7864554 0 EOF |
| 28 |
3: FLOCK ADVISORY WRITE 1568 00:2f:32388 0 EOF |
| 29 |
4: POSIX ADVISORY WRITE 699 00:16:28457 0 EOF |
| 30 |
5: POSIX ADVISORY WRITE 764 00:16:21448 0 0 |
| 31 |
6: POSIX ADVISORY READ 3548 08:01:7867240 1 1 |
| 32 |
7: POSIX ADVISORY READ 3548 08:01:7865567 1826 2335 |
| 33 |
8: OFDLCK ADVISORY WRITE \-1 08:01:8713209 128 191 |
| 34 |
.EE |
| 35 |
.in |
| 36 |
.IP |
| 37 |
The fields shown in each line are as follows: |
| 38 |
.RS |
| 39 |
.IP [1] 5 |
| 40 |
The ordinal position of the lock in the list. |
| 41 |
.IP [2] |
| 42 |
The lock type. |
| 43 |
Values that may appear here include: |
| 44 |
.RS |
| 45 |
.TP |
| 46 |
.B FLOCK |
| 47 |
This is a BSD file lock created using |
| 48 |
.BR flock (2). |
| 49 |
.TP |
| 50 |
.B OFDLCK |
| 51 |
This is an open file description (OFD) lock created using |
| 52 |
.BR fcntl (2). |
| 53 |
.TP |
| 54 |
.B POSIX |
| 55 |
This is a POSIX byte-range lock created using |
| 56 |
.BR fcntl (2). |
| 57 |
.RE |
| 58 |
.IP [3] |
| 59 |
Among the strings that can appear here are the following: |
| 60 |
.RS |
| 61 |
.TP |
| 62 |
.B ADVISORY |
| 63 |
This is an advisory lock. |
| 64 |
.TP |
| 65 |
.B MANDATORY |
| 66 |
This is a mandatory lock. |
| 67 |
.RE |
| 68 |
.IP [4] |
| 69 |
The type of lock. |
| 70 |
Values that can appear here are: |
| 71 |
.RS |
| 72 |
.TP |
| 73 |
.B READ |
| 74 |
This is a POSIX or OFD read lock, or a BSD shared lock. |
| 75 |
.TP |
| 76 |
.B WRITE |
| 77 |
This is a POSIX or OFD write lock, or a BSD exclusive lock. |
| 78 |
.RE |
| 79 |
.IP [5] |
| 80 |
The PID of the process that owns the lock. |
| 81 |
.IP |
| 82 |
Because OFD locks are not owned by a single process |
| 83 |
(since multiple processes may have file descriptors that |
| 84 |
refer to the same open file description), |
| 85 |
the value \-1 is displayed in this field for OFD locks. |
| 86 |
(Before Linux 4.14, |
| 87 |
.\" commit 9d5b86ac13c573795525ecac6ed2db39ab23e2a8 |
| 88 |
a bug meant that the PID of the process that |
| 89 |
initially acquired the lock was displayed instead of the value \-1.) |
| 90 |
.IP [6] |
| 91 |
Three colon-separated subfields that identify the major and minor device |
| 92 |
ID of the device containing the filesystem where the locked file resides, |
| 93 |
followed by the inode number of the locked file. |
| 94 |
.IP [7] |
| 95 |
The byte offset of the first byte of the lock. |
| 96 |
For BSD locks, this value is always 0. |
| 97 |
.IP [8] |
| 98 |
The byte offset of the last byte of the lock. |
| 99 |
.B EOF |
| 100 |
in this field means that the lock extends to the end of the file. |
| 101 |
For BSD locks, the value shown is always |
| 102 |
.IR EOF . |
| 103 |
.RE |
| 104 |
.IP |
| 105 |
Since Linux 4.9, |
| 106 |
.\" commit d67fd44f697dff293d7cdc29af929241b669affe |
| 107 |
the list of locks shown in |
| 108 |
.I /proc/locks |
| 109 |
is filtered to show just the locks for the processes in the PID |
| 110 |
namespace (see |
| 111 |
.BR pid_namespaces (7)) |
| 112 |
for which the |
| 113 |
.I /proc |
| 114 |
filesystem was mounted. |
| 115 |
(In the initial PID namespace, |
| 116 |
there is no filtering of the records shown in this file.) |
| 117 |
.IP |
| 118 |
The |
| 119 |
.BR lslocks (8) |
| 120 |
command provides a bit more information about each lock. |
| 121 |
.SH SEE ALSO |
| 122 |
.BR proc (5) |