Commit graph

23 commits

Author SHA1 Message Date
Masatake YAMATO
c0f84bd12d lsfd: introduce is_opened_file macro
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-11-23 16:42:11 +09:00
Masatake YAMATO
e193602afd lsfd: <breaking comaptiblity> move PROTONAME column to SOCK. column namespace
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-10-03 21:52:17 +09:00
Masatake YAMATO
86a7e471bd lsfd: introduce SOCK. column namespace
lsfd has many columns already. We will add more in the future.
e.g. --help output is too long.

Groping columns is one of the ways to improve the usability of lsfd.
As the first step, this change introduces the "SOCK." column namespace.

Conceptually SOCKNETNS, SOCKSTATE, and SOCKTYPE migrate to the
namespace.  At the implementation level, they are renamed to
SOCK.NETNS, SOCK.STATE, and SOCK.TYPE.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-10-03 21:52:17 +09:00
Masatake YAMATO
b36499456b lsfd: cosmetic change, delete whitespaces 2022-10-02 05:18:20 +09:00
Masatake YAMATO
45d61bffb2 lsfd: add SOCKLISTENING column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-10-02 05:16:54 +09:00
Masatake YAMATO
7b50bd25f4 lsfd: add new columns: SOCKNETNS, SOCKSTATE, and SOCKTYPE as stubs
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-09-24 21:09:15 +09:00
Masatake YAMATO
0ee16e4334 lsfd: facilitate the way to attach extra info loaded from /proc/net/* to sockets
Files under /proc/net/ like unix, tcp, udp, etc. provides extra
information about sockets. To unitize these information in
lsfd, this change adds stub for loading the information form
/proc/net/* and attaching it to struct file presenting sockets.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-09-24 21:09:05 +09:00
Masatake YAMATO
f3609f0ac5 lsfd: use NAME column to show cooked file names
This change splits the NAME column
into cooked NAME column and raw KNAME column.

KNAME represents the type information extracted from /proc/$pid/fd or
/proc/$pid/map_files. NAME is the same as KNAME but humans friendly
and talkative if a special handler is implemented for the type of the
file.

Currently only pidfd has such a handler.

Below an example output:

    $ ./lsfd -o TYPE,STTYPE,KNAME,NAME -Q '(TYPE == "pidfd")'
     TYPE STTYPE KNAME              NAME
    pidfd   UNKN anon_inode:[pidfd] pid=4661 comm=dbus-broker nspid=4661
    pidfd   UNKN anon_inode:[pidfd] pid=4924 comm=dbus-broker nspid=4924

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-09-12 21:46:54 +09:00
Masatake YAMATO
be019f664d 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>
2022-09-10 02:29:20 +09:00
Karel Zak
174ab64af2 lsfd: don't use 'long int' for file data
Let's always assume positions, offsets, etc.. as 64-bit numbers.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-06 11:01:54 +02:00
Karel Zak
99ce42501c lsfd: split new_file(), remove map_file_data
Don't initialize entire 'struct file' in one step. It seems better to
use different ways according to file source (map, symlink, etc.).

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-06 11:01:54 +02:00
Masatake YAMATO
618db96498 lsfd: rename DEVNAME column to SOURCE
Reflecting the review comment:

    maybe rename DEVNAME to SOURCE as we have here things like 'devtmpfs' etc.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:54 +02:00
Masatake YAMATO
eb5fc0a0f3 lsfd: remove redundant "nodev:" prefix from DEVNAME column
Reflecting the review comment:

    remove "nodev:" from DEVNAME

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:54 +02:00
Karel Zak
34f3fd1ad8 lsfd: add reference to proc from file
* add to file struct reference to process
* add file to the list of the process' files in new_file()

This makes things more straightforward.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-06 11:01:54 +02:00
Karel Zak
f9fa97d395 lsfd: cleanup new file initialization
Don't use new_<class>() functions if we have already have
file_class callbacks.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-06 11:01:54 +02:00
Karel Zak
2d95dc093b lsfd: use 'new_' prefix when we allocate something
It's more readable than rather than 'make_'.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-06 11:01:54 +02:00
Masatake YAMATO
1e9880a85b lsfd: fill PROTONAME field of file for mmap'ed socket
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:53 +02:00
Masatake YAMATO
63f3938581 lsfd: add MAPLEN column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:53 +02:00
Masatake YAMATO
a500de3400 lsfd: introduce DEVNAME column and use it as default
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:53 +02:00
Masatake YAMATO
cb6a617d9b lsfd: replace "socket:" in NAME of SOCKET with its protoname
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:53 +02:00
Masatake YAMATO
2dfe2e4d1b lsfd: add PROTONAME column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:53 +02:00
Masatake YAMATO
14e16696ff lsfd: move file_class variants after their constructors
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:53 +02:00
Masatake YAMATO
2da06d3cd0 lsfd: add stubs for sockets and files of unknown type
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:53 +02:00