]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslocks: add info about OFD
authorKarel Zak <kzak@redhat.com>
Fri, 13 Apr 2018 09:22:21 +0000 (11:22 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Jul 2018 14:06:37 +0000 (16:06 +0200)
It seems users are confused by PID -1 and missing path. This patch add
more information about OFD locks to the man page and "undefined" to
the COMMAND column.

References: http://austingroupbugs.net/view.php?id=768
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1527102
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lslocks.8
misc-utils/lslocks.c

index 09b8d418143ad16141389a0a3154a4f4f58a6659..5c7fb6f9e70d3d52e610e11c184ab7fb4cc66ff4 100644 (file)
@@ -12,6 +12,11 @@ lslocks \- list local system locks
 .SH DESCRIPTION
 .B lslocks
 lists information about all the currently held file locks in a Linux system.
+.sp
+Note that lslocks also lists OFD (Open File Description) locks, these locks are
+not associated with any process (PID is -1).  OFD locks are associated with the
+open file description on which they are acquired.  This lock type is available
+since Linux 3.15, see \fBfcntl\fR(2) for more details.
 
 .SH OPTIONS
 .TP
@@ -51,7 +56,7 @@ Display help text and exit.
 .IP "COMMAND"
 The command name of the process holding the lock.
 .IP "PID"
-The process ID of the process which holds the lock.
+The process ID of the process which holds the lock or -1 for OFDLCK.
 .IP "TYPE"
 The type of lock; can be FLOCK (created with \fBflock\fR(2)), POSIX
 (created with \fBfcntl\fR(2) and \fBlockf\fR(3)) or OFDLCK (created with fcntl(2).
index a1a7ab676ce87ee531748113ce0d0ea7e88193dd..fe15ff5304f770ed2b3061f0289f6710b4f02e11 100644 (file)
@@ -276,12 +276,15 @@ static int get_local_locks(struct list_head *locks)
                        case 4: /* PID */
                                /*
                                 * If user passed a pid we filter it later when adding
-                                * to the list, no need to worry now.
+                                * to the list, no need to worry now. OFD locks use -1 PID.
                                 */
                                l->pid = strtos32_or_err(tok, _("failed to parse pid"));
-                               l->cmdname = proc_get_command_name(l->pid);
-                               if (!l->cmdname)
-                                       l->cmdname = xstrdup(_("(unknown)"));
+                               if (l->pid > 0) {
+                                       l->cmdname = proc_get_command_name(l->pid);
+                                       if (!l->cmdname)
+                                               l->cmdname = xstrdup(_("(unknown)"));
+                               } else
+                                       l->cmdname = xstrdup(_("(undefined)"));
                                break;
 
                        case 5: /* device major:minor and inode number */