]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: replace "socket:" in NAME of SOCKET with its protoname
authorMasatake YAMATO <yamato@redhat.com>
Sun, 9 May 2021 01:49:25 +0000 (10:49 +0900)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:53 +0000 (11:01 +0200)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd-sock.c

index ebc6625e810ccf406265a71cfba9453e0b3ad84a..96d624ab644388a3402de3420cbc8d624af66f7f 100644 (file)
@@ -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,