From: Masatake YAMATO Date: Sun, 9 May 2021 01:49:25 +0000 (+0900) Subject: lsfd: replace "socket:" in NAME of SOCKET with its protoname X-Git-Tag: v2.38-rc1~144^2~143 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb6a617d9b9c93146d97e5c2251881dc26f3617d;p=thirdparty%2Futil-linux.git lsfd: replace "socket:" in NAME of SOCKET with its protoname Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd-sock.c b/misc-utils/lsfd-sock.c index ebc6625e81..96d624ab64 100644 --- a/misc-utils/lsfd-sock.c +++ b/misc-utils/lsfd-sock.c @@ -39,6 +39,7 @@ static bool sock_fill_column(struct proc *proc __attribute__((__unused__)), int column_id, size_t column_index) { + char *str = NULL; struct sock *sock = (struct sock *)file; switch(column_id) { case COL_TYPE: @@ -50,9 +51,22 @@ static bool sock_fill_column(struct proc *proc __attribute__((__unused__)), if (scols_line_set_data(ln, column_index, sock->protoname)) err(EXIT_FAILURE, _("failed to add output data")); return true; + case COL_NAME: + if (sock->protoname + && file->name && strncmp(file->name, "socket:", 7) == 0) { + xasprintf(&str, "%s:%s", sock->protoname, file->name + 7); + break; + } + return false; default: return false; } + + if (!str) + err(EXIT_FAILURE, _("failed to add output data")); + if (scols_line_refer_data(ln, column_index, str)) + err(EXIT_FAILURE, _("failed to add output data")); + return true; } struct file *make_sock(const struct file_class *class,