Karel Zak [Mon, 20 Nov 2023 11:53:56 +0000 (12:53 +0100)]
libsmartcols: (samples) remove filter.c
It seems better to use fromfile.c sample where we do not have
hardcoded table data, but it's possible to use data from files (see
tests/ts/libsmartcols/files) as already used in in our tests.
Karel Zak [Mon, 6 Nov 2023 20:45:10 +0000 (21:45 +0100)]
libsmartcols: build filter scanner and parser header files too
* if .c and .h generated in the same time then bison does not duplicate
declarations from .h in .c
* it seems better to generate everything and exclude header files from
git
* the patch excludes autotools YACC support, we need reentrant parser
with some cool features from bison; autotools assumes POSIX
compatibility for YACC (bison -y), we do not need it.
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.
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.
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.
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.
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.
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.
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.
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 ?).
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.
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.
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