]>
git.ipfire.org Git - thirdparty/util-linux.git/log
Karel Zak [Thu, 2 Nov 2023 13:11:22 +0000 (14:11 +0100)]
libsmartcols: improve parser error messages
* remove T_ prefix for tokens in error message (the error message is generated
by bison)
* use rename T_NAME to T_HOLDER to be consistent with library API
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 2 Nov 2023 12:44:32 +0000 (13:44 +0100)]
libsmartcols: prefer float in filter expression
Reported-by: Masatake YAMATO <yamato@redhat.com>
Addresses: https://github.com/util-linux/util-linux/pull/2531#discussion_r1373797202
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 2 Nov 2023 12:22:00 +0000 (13:22 +0100)]
lsfd: use SCOLS_JSON_FLOAT
* use a new SCOLS_JSON_FLOAT
* add "float" to the columns description
* add space before '?' operator
Reported-by: Masatake YAMATO <yamato@redhat.com>
Addresses: https://github.com/util-linux/util-linux/pull/2531#issuecomment-
1780164195
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 2 Nov 2023 12:18:08 +0000 (13:18 +0100)]
libsmartcols: fix filter parser initialization
Addresses: https://github.com/util-linux/util-linux/pull/2531#discussion_r1372360666
Reported-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 2 Nov 2023 11:42:55 +0000 (12:42 +0100)]
lsfd: fix memory leak in append_filter_expr()
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 31 Oct 2023 11:56:21 +0000 (12:56 +0100)]
libsmartcols: accept also '/' in column name for filters
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 31 Oct 2023 11:47:10 +0000 (12:47 +0100)]
libsmartcols: accept '%:-' in column name for filters
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 31 Oct 2023 11:44:36 +0000 (12:44 +0100)]
lsblk: make sure all line data are deallocated
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 27 Oct 2023 11:12:07 +0000 (13:12 +0200)]
libsmartcols: add filter API docs
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 27 Oct 2023 09:58:00 +0000 (11:58 +0200)]
libsmartcols: cleanup datafunc() API
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 27 Oct 2023 09:42:15 +0000 (11:42 +0200)]
libsmartcols: don't directly access struct members
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 25 Oct 2023 10:25:37 +0000 (12:25 +0200)]
lsblk: ignore duplicate lines for counters
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 23 Oct 2023 20:34:18 +0000 (22:34 +0200)]
libsmartcols: (filter) normalize param strings
Let's ignore space at the beginning and end of the string. It's
possible that filling functions in applications use extra space to
align data in columns. We need to ignore it.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 9 Oct 2023 11:58:53 +0000 (13:58 +0200)]
libsmartcols: (filter) cleanup __filter_new_node()
Reported-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 9 Oct 2023 11:56:24 +0000 (13:56 +0200)]
libsmartcols: (filter) fix regex deallocation
Reported-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 9 Oct 2023 11:41:06 +0000 (13:41 +0200)]
libsmartcols: (filter) use also rpmatch() for boolean
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 9 Oct 2023 11:21:45 +0000 (13:21 +0200)]
libsmartcols: (filter) improve holder use
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 5 Oct 2023 18:21:20 +0000 (20:21 +0200)]
libsmartcols: (filter) support period in identifier
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 5 Oct 2023 18:09:15 +0000 (20:09 +0200)]
lsfd: keep filter-only columns hidden
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 4 Oct 2023 16:42:44 +0000 (18:42 +0200)]
meson: update for libsmartcols filter
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 4 Oct 2023 15:26:16 +0000 (17:26 +0200)]
libsmartcols: (filter) improve holder status
Split "fetched" and "empty" filter param status.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 2 Oct 2023 17:52:40 +0000 (19:52 +0200)]
lsfd: use filter and counters from libsmartcols
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 2 Oct 2023 17:41:26 +0000 (19:41 +0200)]
libsmartcols: accept apostrophe as quote for strings in filter
lsfd supports "abc" as well as 'abc'.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 2 Oct 2023 16:19:00 +0000 (18:19 +0200)]
lsblk: report all unknown columns in filter
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 27 Sep 2023 12:14:44 +0000 (14:14 +0200)]
lsblk: define cell data-types, use raw data for SIZEs
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 27 Sep 2023 12:00:38 +0000 (14:00 +0200)]
libsmartcols: introduce column type
Now the column can define JSON-type, this commit introduces data-type.
This type is hint for filters and counters how to convert strings from
cells to raw data.
If the conversion from string is not possible, then application can
define callback for this purpose (aka. "datafunc"), this function has
to return the raw data as a void pointer.
This solution allows to use human readable things in cells (e.g.
"123MiB"), but filters and counters can still use the original data.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 27 Sep 2023 10:47:15 +0000 (12:47 +0200)]
libsmartcols: Export internally used types to API
We anticipate a need for improved interaction between applications and
the library in certain scenarios. For instance, when a table contains
strings that cannot be readily converted from strings to numbers
(e.g., strings like "15.3MiB") but the application possesses data in a
more suitable format.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 27 Sep 2023 09:26:23 +0000 (11:26 +0200)]
lsblk: rename sortdata to rawdata
We can use the data for another purpose too.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 26 Sep 2023 12:51:34 +0000 (14:51 +0200)]
lsblk: always set column type
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 26 Sep 2023 12:45:13 +0000 (14:45 +0200)]
lsblk: support normalized column names on command line
For example column name "LOG-SEC" is possible to use as LOG_SEC in
some output formats and in filter expressions.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 26 Sep 2023 12:44:02 +0000 (14:44 +0200)]
libsmartcols: search also by normalized column names (aka 'shellvar' name)
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 26 Sep 2023 11:18:42 +0000 (13:18 +0200)]
libsmartcols: make sure counter is initialized
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 26 Sep 2023 10:52:32 +0000 (12:52 +0200)]
lsblk: add scols counters support
* add --ct-filter <expr> to restrict the next next counters
* add --ct <name>[:<param>:func] to define counter. The counter
assigned to the previously specified filter, if no filter specified
then it's applied to all output lines.
Examples:
$ lsblk --ct "number of block devices"
...
Summary:
21 number of block devices
The filter uses default count() function and is applied to
all lines.
$ lsblk --ct-filter 'TRAN=="nvme"' --ct "number of NVMEs"
...
Summary:
4 number of NVMEs
The filter is restricted by filter.
$ lsblk --bytes
--ct-filter 'TRAN=="sata" && TYPE=="disk"'
--ct "size of all SATAs disks":SIZE:sum
...
Summary:
320083771392 size of all SATAs disks
The counter uses sum() built-in function for specified column (SIZE)
and is restricted by filter.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 26 Sep 2023 10:43:01 +0000 (12:43 +0200)]
libsmartcols: implement filter based counters
* add support for empty filter; the result of the empty expression is
always "true"
* Filter can hold arbitrary number of counters
* A counter is based on a built-in function. Now supported are count, max, min and sum functions.
* The default function is "count" (count lines)
* It's possible to assign column (param) to the counter, for example count sum
of all data in the column
* The param is used in the same way as params in the filter (and
initialized in the same way)
Based on Masatake YAMATO's work on lsfd.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 26 Sep 2023 08:17:22 +0000 (10:17 +0200)]
lsblk: split filter allocation and initialization
A small refactoring to parse filters during getopt_long() time.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 25 Sep 2023 11:19:49 +0000 (13:19 +0200)]
lsblk: fix in-tree filtering
The function device_to_scols() is used recursively (for children).
It's impossible leave the function on filter status=false, it's
necessary to continue in the tree.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 20 Sep 2023 12:34:09 +0000 (14:34 +0200)]
lsblk: add --highlight
The new option can colorize lines specified by scols query. The
columns (in the expression) does not have to be in the output.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 20 Sep 2023 12:07:39 +0000 (14:07 +0200)]
lsblk: add --filter
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 20 Sep 2023 11:47:43 +0000 (13:47 +0200)]
libsmartcols: (filter) Add on-demand data filler
When dealing with really large data sets, we need to reduce overhead
by filtering out unnecessary lines. The traditional approach, using:
lstool | grep <expr>
requires the tool to read all data from the system and then filter out
(and throw away) a lot of data.
The filter-filler now allows us to use an empty line. The filter will
request data through a callback, and when a line passes the filter,
the application can fill in the rest of the columns.
For example, in a query like "FOO > 10 && BAR < 10," libsmartcols will
never ask for "BAR" if "FOO" is smaller than 10. This means the
application doesn't have to gather additional columns.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 19 Sep 2023 09:15:15 +0000 (11:15 +0200)]
libsmartcols: Add --highlight option to filter sample
This commit demonstrates another example of how to use the filter. It
also enables testing of two filters for the same table to ensure that
Bison and Flex generate a reentrant parser.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 14 Sep 2023 09:55:03 +0000 (11:55 +0200)]
libsmartcols: (filter) add regular expression operators
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 13 Sep 2023 11:06:06 +0000 (13:06 +0200)]
libsmartcols: (filter) move struct filter_param
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 13 Sep 2023 10:54:18 +0000 (12:54 +0200)]
libsmartcols: (filter) move struct filter_expr
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 13 Sep 2023 09:59:13 +0000 (11:59 +0200)]
libsmartcols: (filter) support empty values
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 13 Sep 2023 09:28:36 +0000 (11:28 +0200)]
libsmartcols: (filter) improve scols_filter_assign_column()
* make it more usable with scols_filter_next_holder() and avoid name
* make it usable with only with name
* fix return codes
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 12 Sep 2023 19:16:37 +0000 (21:16 +0200)]
libsmartcols: support SCOLS_JSON_FLOAT in print API
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 12 Sep 2023 12:22:40 +0000 (14:22 +0200)]
libsmartcols: (filter) add ability to cast data
* add FLOAT type for JSON
JSON standard does not care and everything is number, but for libsmartcols
it would be better to differentiate between the types.
* add functions to cast data in the filter param
* cast data from scols rows
* cast data in the filter expression if necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 12 Sep 2023 12:14:50 +0000 (14:14 +0200)]
include/strutils: add ul_strtold()
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 7 Sep 2023 08:53:21 +0000 (10:53 +0200)]
libsmartcols: (filter) cleanup function arguments
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 7 Sep 2023 08:24:03 +0000 (10:24 +0200)]
libsmartcols: (filter) implement data basic operators
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Sep 2023 11:43:37 +0000 (13:43 +0200)]
libsmartcols (filter) fetch data from columns
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Sep 2023 10:51:16 +0000 (12:51 +0200)]
libsmartcols: (filter) param data refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Sep 2023 09:52:39 +0000 (11:52 +0200)]
libsmartcols: (filter) make holders API more generic
The internal implementation is generic (can hold something else than
only column name). Let's make the API also generic. Maybe later we can
support something else than only column names in expressions
(e.g. env.variables ?).
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Sep 2023 09:43:23 +0000 (11:43 +0200)]
libsmartcols: (filter) cleanup data types
* split placeholders (e.g. column name) and data types
* make data type enums independent on params
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Sep 2023 08:57:42 +0000 (10:57 +0200)]
libsmartcols: (filter) implement logical operators
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Sep 2023 08:54:53 +0000 (10:54 +0200)]
libsmartcols: (filter) evaluate params
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Sep 2023 08:45:45 +0000 (10:45 +0200)]
libsmartcols: update gitignore
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Sep 2023 07:51:25 +0000 (09:51 +0200)]
libsmartcols: (filter) split code
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 31 Aug 2023 15:41:04 +0000 (17:41 +0200)]
libsmartcols: add API to join filter and columns
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 31 Aug 2023 11:55:16 +0000 (13:55 +0200)]
autotools: check for flex in autogen.sh
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 31 Aug 2023 11:47:50 +0000 (13:47 +0200)]
libsmartcols: add parser header files
The header files are generated by bison and flex, but it seems that it's
expected that developer generate it only rarely and manually. So, it
seems better to keep it in git.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 8 Aug 2023 10:19:26 +0000 (12:19 +0200)]
libsmartcols: add filter sample
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 8 Aug 2023 10:18:56 +0000 (12:18 +0200)]
libsmartcols: improve filter integration, use JSON to dump
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 8 Aug 2023 10:16:23 +0000 (12:16 +0200)]
lib/jsonwrt: add support for float numbers
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 8 Aug 2023 10:15:50 +0000 (12:15 +0200)]
autotools: fix AC_PROG_LEX use
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 20 Jul 2023 21:08:07 +0000 (23:08 +0200)]
libsmartcols: introduce basic files for filter implementation
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 20 Nov 2023 10:03:39 +0000 (11:03 +0100)]
Merge branch 'authors' of https://github.com/t-8ch/util-linux
* 'authors' of https://github.com/t-8ch/util-linux:
AUTHORS: add tools contributed by myself
Karel Zak [Mon, 20 Nov 2023 10:03:18 +0000 (11:03 +0100)]
Merge branch 'cfdisk/resize-out-of-order' of https://github.com/t-8ch/util-linux
* 'cfdisk/resize-out-of-order' of https://github.com/t-8ch/util-linux:
cfdisk: properly handle out-of-order partitions during resize
libfdisk: add fdisk_partition_get_max_size
libfdisk: fix typo in debug message
Thomas Weißschuh [Wed, 15 Nov 2023 21:18:04 +0000 (22:18 +0100)]
AUTHORS: add tools contributed by myself
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Thomas Weißschuh [Tue, 14 Nov 2023 16:53:29 +0000 (17:53 +0100)]
cfdisk: properly handle out-of-order partitions during resize
Fixes #2580
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Thomas Weißschuh [Tue, 14 Nov 2023 16:53:21 +0000 (17:53 +0100)]
libfdisk: add fdisk_partition_get_max_size
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Thomas Weißschuh [Wed, 18 Oct 2023 08:58:46 +0000 (10:58 +0200)]
libfdisk: fix typo in debug message
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Karel Zak [Tue, 14 Nov 2023 11:50:38 +0000 (12:50 +0100)]
lsblk: add separate MAJ and MIN columns
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 14 Nov 2023 11:46:49 +0000 (12:46 +0100)]
libsmartcols: accept no data for custom wrapping cells
Don't re-use previously used 'rc' variable, otherwise empty cell will
be interpreted as error.
Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 14 Nov 2023 09:18:43 +0000 (10:18 +0100)]
Merge branch 'fincore-err' of https://github.com/t-8ch/util-linux
* 'fincore-err' of https://github.com/t-8ch/util-linux:
fincore: (tests) also use nosize error file
Masatake YAMATO [Tue, 14 Nov 2023 02:21:22 +0000 (11:21 +0900)]
tests: (lsfd::column-xmode) ignore "rwx" mappings
This change fixes the issue about lsfd reported in
https://marc.info/?l=util-linux-ng&m=
169972678725084 &w=2
column-xmode test case assumes an executable file has only
one "x" mapping like:
% pmap $$ | grep ${SHELL##*/}
1292343 : zsh
0000562386c1c000 92K r---- zsh
0000562386c33000 716K r-x-- zsh <<
0000562386ce6000 88K r---- zsh
0000562386cfc000 8K r---- zsh
0000562386cfe000 24K rw--- zsh
However, this assumption is wrong on Sparc64:
% pmap $$
1490470 : zsh
0000010000000000 792K r-x-- zsh <<
00000100001fe000 8K r---- zsh
0000010000200000 32K rwx-- zsh <<
Two "x" mappings are found.
As a result, the original test case failed.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Thomas Weißschuh [Mon, 13 Nov 2023 20:05:59 +0000 (21:05 +0100)]
Goldwyn Rodrigues [Tue, 10 Oct 2023 23:08:59 +0000 (18:08 -0500)]
libuuid: avoid truncate clocks.txt to improve performance
Instead of explicitly truncating clocks.txt file, pad with
whitespaces in the end of file.
This is done to improve performance of libuuid on xfs
filesystems. Instead of truncating the file, pad it with whitespaces.
This is anyways used as a failsafe method in case truncate fails.
The reason why this regression was introduced was because of:
869ae85dae64 ("xfs: flush new eof page on truncate to avoid post-eof corruption")
An attempt to move the clocks.txt to /run (tmpfs) has been attempted before
[1] and with commit
ab2e7dd17 ("libuuid: move clock state file from
/var/lib to /var/run"). The latter was reverted.
[1] https://www.spinics.net/lists/util-linux-ng/msg17331.html
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Karel Zak [Mon, 13 Nov 2023 09:36:16 +0000 (10:36 +0100)]
Merge branch 'lslocks--per-process' of https://github.com/masatake/util-linux
* 'lslocks--per-process' of https://github.com/masatake/util-linux:
lslocks: (man) update the note about OFDLCK
lslocks: (test) add a case for OFDLCK type locks
lslocks: use information extracted from "locks: " column of /proc/$pid/fdinfo/*
lslocks: (refactor) lift up the code destroying the lock list for future extension
lslocks: rename functions for future extension
lslocks: refactor the code reading /proc/locks
lslocks: (refactor) remove 'pid' global variable
lslocks: (man) document LEASE type
lslocks: (test) add a case
Karel Zak [Mon, 13 Nov 2023 09:34:39 +0000 (10:34 +0100)]
Merge branch 'master' of https://github.com/ffontaine/util-linux
* 'master' of https://github.com/ffontaine/util-linux:
libuuid/src/gen_uuid.c: fix cs_min declaration
Masatake YAMATO [Sun, 12 Nov 2023 17:26:53 +0000 (02:26 +0900)]
lslocks: (man) update the note about OFDLCK
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Sun, 12 Nov 2023 16:43:36 +0000 (01:43 +0900)]
lslocks: (test) add a case for OFDLCK type locks
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Thu, 9 Nov 2023 22:08:45 +0000 (07:08 +0900)]
lslocks: use information extracted from "locks: " column of /proc/$pid/fdinfo/*
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Sun, 12 Nov 2023 15:30:32 +0000 (00:30 +0900)]
lslocks: (refactor) lift up the code destroying the lock list for future extension
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Sun, 12 Nov 2023 15:25:51 +0000 (00:25 +0900)]
lslocks: rename functions for future extension
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Thu, 9 Nov 2023 21:14:36 +0000 (06:14 +0900)]
lslocks: refactor the code reading /proc/locks
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Sun, 12 Nov 2023 18:03:03 +0000 (03:03 +0900)]
lslocks: (refactor) remove 'pid' global variable
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Sun, 12 Nov 2023 17:21:43 +0000 (02:21 +0900)]
lslocks: (man) document LEASE type
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Sat, 11 Nov 2023 17:39:22 +0000 (02:39 +0900)]
lslocks: (test) add a case
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Fabrice Fontaine [Tue, 7 Nov 2023 17:43:57 +0000 (18:43 +0100)]
libuuid/src/gen_uuid.c: fix cs_min declaration
Define cs_min through a define and not a const int to avoid the
following build failure with -O0 raised since version 2.39 and
https://github.com/util-linux/util-linux/commit/
2fa4168c8bc9d5438bc1dfadda293c7c21b6fa59 :
libuuid/src/gen_uuid.c: In function 'uuid_generate_time_generic':
libuuid/src/gen_uuid.c:536:33: error: initializer element is not constant
THREAD_LOCAL int cache_size = cs_min;
^~~~~~
For consistency, also use define for cs_max and cs_factor
Fixes:
- http://autobuild.buildroot.org/results/
2f80a5cdb523cc3c8c0f3693607a1be036b2ae98
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Karel Zak [Wed, 8 Nov 2023 11:35:30 +0000 (12:35 +0100)]
Merge branch 'lsfd--tty' of https://github.com/masatake/util-linux
* 'lsfd--tty' of https://github.com/masatake/util-linux:
tests: (lsfd) add a case testing NAME, SOURCE, ENDPOINTS, and PTMX.TTY-INDEX columns of pts fds
tests: (test_mkfds::pty) add a new factory
lsfd: fill ENDPOINTS column for pty devices
lsfd: add attach_xinfo and get_ipc_class methods to cdev_ops
lsfd: add PTMX.TTY-INDEX column
lsfd: utilize /proc/tty/drivers for filling SOURCE column of tty devices
lsfd: make the order of calling finalize_* and initialize_* consistent
Karel Zak [Tue, 7 Nov 2023 10:21:07 +0000 (11:21 +0100)]
Merge branch 'lslocks--man-missing-fields' of https://github.com/masatake/util-linux
* 'lslocks--man-missing-fields' of https://github.com/masatake/util-linux:
lslocks: (man) add missing fields
Masatake YAMATO [Mon, 6 Nov 2023 20:30:33 +0000 (05:30 +0900)]
lslocks: (man) add missing fields
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Karel Zak [Mon, 6 Nov 2023 10:40:27 +0000 (11:40 +0100)]
libmount: fix possible NULL dereference [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Masatake YAMATO [Fri, 3 Nov 2023 20:22:21 +0000 (05:22 +0900)]
tests: (lsfd) add a case testing NAME, SOURCE, ENDPOINTS, and PTMX.TTY-INDEX columns of pts fds
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Fri, 3 Nov 2023 19:38:52 +0000 (04:38 +0900)]
tests: (test_mkfds::pty) add a new factory
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Wed, 1 Nov 2023 17:47:35 +0000 (02:47 +0900)]
lsfd: fill ENDPOINTS column for pty devices
An example output:
$ ./lsfd -o+ENDPOINTS -Q '(COMMAND =~ "tmux") and ((SOURCE == "ptmx") or (SOURCE =~ "pts:.*"))'
COMMAND PID USER ASSOC XMODE TYPE SOURCE MNTID INODE NAME ENDPOINTS
tmux: client
3717086 yamato 0 rw---- CHR pts:9 27 12 /dev/pts/9
2143274 ,xfce4-terminal,34rw
tmux: client
3717086 yamato 1 rw---- CHR pts:9 27 12 /dev/pts/9
2143274 ,xfce4-terminal,34rw
tmux: client
3717086 yamato 2 rw---- CHR pts:9 27 12 /dev/pts/9
2143274 ,xfce4-terminal,34rw
tmux: server
3717088 yamato 5 rw---m CHR pts:9 27 12 /dev/pts/9
2143274 ,xfce4-terminal,34rw
tmux: server
3717088 yamato 8 rw---m CHR ptmx 24 208 tty-index=16
3717089 ,zsh,0rw
3717089 ,zsh,1rw
3717089 ,zsh,2rw
3717089 ,zsh,10rw
$ ./lsfd -o+ENDPOINTS -Q '(PID ==
3717089 ) and (FD == 0)'
COMMAND PID USER ASSOC XMODE TYPE SOURCE MNTID INODE NAME ENDPOINTS
zsh
3717089 yamato 0 rw---- CHR pts:16 27 19 /dev/pts/16
3717088 ,tmux: server,8rw
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Wed, 1 Nov 2023 17:42:27 +0000 (02:42 +0900)]
lsfd: add attach_xinfo and get_ipc_class methods to cdev_ops
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Wed, 1 Nov 2023 15:44:20 +0000 (00:44 +0900)]
lsfd: add PTMX.TTY-INDEX column
tty-index field in /proc/$pid/fdinfo/$fd is the data source of
the column. The value is helpful for looking up the conterpart
of /dev/ptmx.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Wed, 1 Nov 2023 15:05:12 +0000 (00:05 +0900)]
lsfd: utilize /proc/tty/drivers for filling SOURCE column of tty devices
The original code referenced /proc/devices using major numbers as keys to obtain
the name of the device driver corresponding to a file descriptor.
However, it turnes out that some drivers share a same major number;
there are cases that a key is not unique.
Character devices:
1 mem
4 /dev/vc/0
4 tty
4 ttyS
...
About tty-related devices, /proc/tty/drivers is better information
source; both major and minor numbers can be used as keys:
/dev/tty /dev/tty 5 0 system:/dev/tty
/dev/console /dev/console 5 1 system:console
/dev/ptmx /dev/ptmx 5 2 system
/dev/vc/0 /dev/vc/0 4 0 system:vtmaster
usbserial /dev/ttyUSB 188 0-511 serial
dbc_serial /dev/ttyDBC 242 0-63 serial
serial /dev/ttyS 4 64-95 serial
pty_slave /dev/pts 136 0-
1048575 pty:slave
pty_master /dev/ptm 128 0-
1048575 pty:master
unknown /dev/tty 4 1-63 console
This commit extracts the second column of the /proc/tty/drivers as
driver names after removing "/dev": tty, console, ptmx, ...
With the orinal code:
# lsfd -n -p 1789 -Q '(FD == 25)'
systemd-logind 1789 root 25 rw- CHR /dev/vc/0:6 432 25 /dev/tty6
--------------------------------------------^^^^^^^^^^^
With this commit:
# ./lsfd -n -p 1789 -Q '(FD == 25)'
systemd-logind 1789 root 25 rw---- CHR tty:6 432 25 /dev/tty6
----------------------------------------------^^^^^
Signed-off-by: Masatake YAMATO <yamato@redhat.com>