From: Karel Zak Date: Fri, 13 Apr 2018 09:22:21 +0000 (+0200) Subject: lslocks: add info about OFD X-Git-Tag: v2.32.1~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=88b630f71de5f91bb6ea504c5bb0cffd222f0de5;p=thirdparty%2Futil-linux.git lslocks: add info about OFD 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 --- diff --git a/misc-utils/lslocks.8 b/misc-utils/lslocks.8 index 09b8d41814..5c7fb6f9e7 100644 --- a/misc-utils/lslocks.8 +++ b/misc-utils/lslocks.8 @@ -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). diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c index a1a7ab676c..fe15ff5304 100644 --- a/misc-utils/lslocks.c +++ b/misc-utils/lslocks.c @@ -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 */