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>
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>
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>
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>
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>
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>
* 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>