summaryrefslogtreecommitdiffstats
path: root/misc-utils/lslocks.c
diff options
context:
space:
mode:
authorKarel Zak2015-11-25 14:17:22 +0100
committerKarel Zak2015-11-25 14:17:22 +0100
commit0e756daeb64ab62a8e9296e5156e17bb5cf6720a (patch)
tree3c659781890f34cc4874c8de3425c68b04d5f4c8 /misc-utils/lslocks.c
parentagetty: don't ignore netlink on select() (diff)
downloadkernel-qcow2-util-linux-0e756daeb64ab62a8e9296e5156e17bb5cf6720a.tar.gz
kernel-qcow2-util-linux-0e756daeb64ab62a8e9296e5156e17bb5cf6720a.tar.xz
kernel-qcow2-util-linux-0e756daeb64ab62a8e9296e5156e17bb5cf6720a.zip
lslocks: use stuff from lib/procutils
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lslocks.c')
-rw-r--r--misc-utils/lslocks.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
index 35ca5c75a..389a3e42f 100644
--- a/misc-utils/lslocks.c
+++ b/misc-utils/lslocks.c
@@ -45,6 +45,7 @@
#include "list.h"
#include "closestream.h"
#include "optutils.h"
+#include "procutils.h"
/* column IDs */
enum {
@@ -119,28 +120,6 @@ static void disable_columns_truncate(void)
}
/*
- * Return a PID's command name
- */
-static char *get_cmdname(pid_t id)
-{
- FILE *fp;
- char path[PATH_MAX], *ret = NULL;
-
- sprintf(path, "/proc/%d/comm", id);
- if (!(fp = fopen(path, "r")))
- return NULL;
-
- if (!fgets(path, sizeof(path), fp))
- goto out;
-
- path[strlen(path) - 1] = '\0';
- ret = xstrdup(path);
-out:
- fclose(fp);
- return ret;
-}
-
-/*
* Associate the device's mountpoint for a filename
*/
static char *get_fallback_filename(dev_t dev)
@@ -285,7 +264,7 @@ static int get_local_locks(struct list_head *locks)
* to the list, no need to worry now.
*/
l->pid = strtos32_or_err(tok, _("failed to parse pid"));
- l->cmdname = get_cmdname(l->pid);
+ l->cmdname = proc_get_command_name(l->pid);
if (!l->cmdname)
l->cmdname = xstrdup(_("(unknown)"));
break;