]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lsfd: use TYPE column to show cooked file types
authorMasatake YAMATO <yamato@redhat.com>
Sat, 3 Sep 2022 15:25:15 +0000 (00:25 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 9 Sep 2022 17:29:20 +0000 (02:29 +0900)
commitbe019f664db6eef7f2df38d31f1627d74a82fe65
tree756251eea48a0273962493f513ea79716196533b
parent4cd4ed189a5112c8b64359fdde253f51113f126f
lsfd: use TYPE column to show cooked file types

lsfd has two exclusive requirements:

A. show quickly understandable information in limited display area, and
B. provide primitive raw information for post-process tools.

For the purpose A, summarizing information is nice. However, the
summarized information is not suitable for tools.

To satisfy the both requirements, I plan introducing new fields
with a new convention.

STTYPE represents the type information returned from stat(2).
TYPE is the same as STTYPE but two exceptions; TYPE is filled with
PROTONAME value if the target fd is a socket, or with AINODECLASS
value if the target fd is a anonymous inode.

Below an example output:

    $ ./lsfd -o COMMAND,TYPE,STTYPE,NAME -Q '(TYPE != STTYPE)'  | head
    COMMAND                TYPE STTYPE NAME
    systemd         UNIX-STREAM   SOCK UNIX-STREAM:[25493]
    systemd         UNIX-STREAM   SOCK UNIX-STREAM:[25493]
    systemd                UNIX   SOCK UNIX:[31445]
    systemd           eventpoll   UNKN anon_inode:[eventpoll]
    systemd            signalfd   UNKN anon_inode:[signalfd]
    systemd             inotify   UNKN anon_inode:inotify
    systemd             timerfd   UNKN anon_inode:[timerfd]
    systemd           eventpoll   UNKN anon_inode:[eventpoll]
    systemd             inotify   UNKN anon_inode:inotify

STTYPE, column for tools, is printed only when the column is specified
with -o option.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 files changed:
misc-utils/lsfd-file.c
misc-utils/lsfd-sock.c
misc-utils/lsfd-unkn.c
misc-utils/lsfd.1.adoc
misc-utils/lsfd.c
misc-utils/lsfd.h
tests/expected/lsfd/column-ainodeclass
tests/expected/lsfd/column-type [new file with mode: 0644]
tests/expected/lsfd/mkfds-pidfd
tests/expected/lsfd/mkfds-socketpair
tests/ts/lsfd/column-ainodeclass
tests/ts/lsfd/column-type [new file with mode: 0755]
tests/ts/lsfd/mkfds-mapped-packet-socket
tests/ts/lsfd/mkfds-pidfd
tests/ts/lsfd/mkfds-socketpair