]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
6 months agoxalloc.h: add new functions: xstrappend, xstrputc, xstrvfappend, and xstrfappend
Masatake YAMATO [Tue, 21 Nov 2023 13:19:29 +0000 (22:19 +0900)] 
xalloc.h: add new functions: xstrappend, xstrputc, xstrvfappend, and xstrfappend

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agolsfd: (refactor) make the code comparing struct lock objects reusable
Masatake YAMATO [Wed, 15 Nov 2023 19:03:23 +0000 (04:03 +0900)] 
lsfd: (refactor) make the code comparing struct lock objects reusable

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agolslocks: add a missing "break;" in a switch/case statement
Masatake YAMATO [Wed, 15 Nov 2023 10:45:53 +0000 (19:45 +0900)] 
lslocks: add a missing "break;" in a switch/case statement

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agolslocks: (preparation) add a fd number to the lock struct when loading lock info...
Masatake YAMATO [Wed, 15 Nov 2023 10:41:09 +0000 (19:41 +0900)] 
lslocks: (preparation) add a fd number to the lock struct when loading lock info from /proc/$pid/fdinfo/$fd

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agolslocks: (refactor) use a tree for storing lock information extracted from /proc...
Masatake YAMATO [Wed, 15 Nov 2023 10:35:00 +0000 (19:35 +0900)] 
lslocks: (refactor) use a tree for storing lock information extracted from /proc/$pid/fdinfo/$fd

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agolslocks: (refactor) make the data structure for storing lock information replacable
Masatake YAMATO [Wed, 15 Nov 2023 08:04:04 +0000 (17:04 +0900)] 
lslocks: (refactor) make the data structure for storing lock information replacable

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agoMerge branch 'PR/libsmartcols-filter' of github.com:karelzak/util-linux-work
Karel Zak [Thu, 23 Nov 2023 11:51:38 +0000 (12:51 +0100)] 
Merge branch 'PR/libsmartcols-filter' of github.com:karelzak/util-linux-work

* 'PR/libsmartcols-filter' of github.com:karelzak/util-linux-work: (88 commits)
  meson: remove scols filter sample
  tests: use array keys in more robust way
  lsblk: update after rebase
  tests: add libsmartcols filter tests
  libsmartcols: (sample) fix error message
  tests: use scols_column_set_properties() in 'fromfile' sample
  libsmartcols: improve and fix scols_column_set_properties()
  libsmartcols: (samples) remove filter.c
  libsmartcols: add filter support to 'fromfile' sample
  libsmartcols: fix filter param copying
  tests: don't keep bison messages in tests
  autotools: use stamp file to build filter parser, improve portability
  meson: use bison --defines=HEADER
  libsmartcols: fix typo in parser tokens
  libsmartcols: add scols-filter.5 man page
  libsmartcols: (filter) add upper case EQ,NE,LE,LT,GT and GE operators
  ci: packit: add flex
  meson: fix copy & past error
  libsmartcols: build filter scanner and parser header files too
  meson: add missing scols sample
  ...

6 months agoMerge branch 'irqtop-fix-sort' of https://github.com/nbuwe/util-linux
Karel Zak [Thu, 23 Nov 2023 10:36:48 +0000 (11:36 +0100)] 
Merge branch 'irqtop-fix-sort' of https://github.com/nbuwe/util-linux

* 'irqtop-fix-sort' of https://github.com/nbuwe/util-linux:
  irqtop: fix numeric sorting

6 months agomeson: remove scols filter sample
Karel Zak [Thu, 23 Nov 2023 10:32:37 +0000 (11:32 +0100)] 
meson: remove scols filter sample

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agotests: use array keys in more robust way
Karel Zak [Thu, 23 Nov 2023 10:08:17 +0000 (11:08 +0100)] 
tests: use array keys in more robust way

Let's use while-loop to support arbitrary key and to avoid fragile
quotes for strings .

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoMerge branch 'unused' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 23 Nov 2023 09:41:47 +0000 (10:41 +0100)] 
Merge branch 'unused' of https://github.com/t-8ch/util-linux

* 'unused' of https://github.com/t-8ch/util-linux:
  treewide: explicitly mark unused arguments

6 months agoMerge branch 'undefined' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 23 Nov 2023 09:40:18 +0000 (10:40 +0100)] 
Merge branch 'undefined' of https://github.com/t-8ch/util-linux

* 'undefined' of https://github.com/t-8ch/util-linux:
  lsfd: avoid undefined behavior

6 months agolsblk: add hint that partition start is in sectors
Karel Zak [Wed, 22 Nov 2023 11:12:01 +0000 (12:12 +0100)] 
lsblk: add hint that partition start is in sectors

Reported-by: Dusty Mabe <dustymabe@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoirqtop: fix numeric sorting
Valery Ushakov [Wed, 22 Nov 2023 00:56:19 +0000 (03:56 +0300)] 
irqtop: fix numeric sorting

qsort(3) requires three-way result like that from strcmp(3),
not an std::less like boolean.

6 months agolsblk: update after rebase
Karel Zak [Mon, 20 Nov 2023 21:26:33 +0000 (22:26 +0100)] 
lsblk: update after rebase

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agotests: add libsmartcols filter tests
Karel Zak [Mon, 20 Nov 2023 21:15:31 +0000 (22:15 +0100)] 
tests: add libsmartcols filter tests

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: (sample) fix error message
Karel Zak [Mon, 20 Nov 2023 21:14:39 +0000 (22:14 +0100)] 
libsmartcols: (sample) fix error message

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agotests: use scols_column_set_properties() in 'fromfile' sample
Karel Zak [Mon, 20 Nov 2023 13:58:08 +0000 (14:58 +0100)] 
tests: use scols_column_set_properties() in 'fromfile' sample

The library already can read column properties from a column separated
string. Let's use it in 'fromfile' sample to avoid duplicate code and
to test this function too.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: improve and fix scols_column_set_properties()
Karel Zak [Mon, 20 Nov 2023 13:56:58 +0000 (14:56 +0100)] 
libsmartcols: improve and fix scols_column_set_properties()

* fix typos and copy & past bug
* add support for data types

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: (samples) remove filter.c
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months ago libsmartcols: add filter support to 'fromfile' sample
Karel Zak [Mon, 20 Nov 2023 11:38:43 +0000 (12:38 +0100)] 
 libsmartcols: add filter support to 'fromfile' sample

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: fix filter param copying
Karel Zak [Mon, 20 Nov 2023 11:36:39 +0000 (12:36 +0100)] 
libsmartcols: fix filter param copying

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agotests: don't keep bison messages in tests
Karel Zak [Tue, 14 Nov 2023 08:31:31 +0000 (09:31 +0100)] 
tests: don't keep bison messages in tests

Bison generates the 'syntax error' messages and depends on
the Bison version. For example, the current bison uses

        lsfd: failed to parse "(": syntax error, unexpected end of file

But the old version:

        lsfd: failed to parse "(": syntax error, unexpected $end

We do not control these strings, so it's better not to save them to our tests.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoautotools: use stamp file to build filter parser, improve portability
Karel Zak [Mon, 13 Nov 2023 13:16:03 +0000 (14:16 +0100)] 
autotools: use stamp file to build filter parser, improve portability

* use .stamp files to generate .c and .h by only one flex and bison call

* use bison --defines=HEADER rather than --header=, the --header is
  supported also by old bison version (like common bison 3.0.4)

* make sure there is defined dependence between the scanner and parser
  .c and .h files (scanner need header from parser and vice-versa)

* distribute .stamp files to avoid flex and bison for people who use
  sources from tarball (we distribute generated source files)

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agomeson: use bison --defines=HEADER
Karel Zak [Mon, 13 Nov 2023 13:12:07 +0000 (14:12 +0100)] 
meson: use bison --defines=HEADER

It's more backwardly compatible than --header=.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: fix typo in parser tokens
Karel Zak [Wed, 8 Nov 2023 11:33:25 +0000 (12:33 +0100)] 
libsmartcols: fix typo in parser tokens

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: add scols-filter.5 man page
Karel Zak [Wed, 8 Nov 2023 10:56:22 +0000 (11:56 +0100)] 
libsmartcols: add scols-filter.5 man page

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: (filter) add upper case EQ,NE,LE,LT,GT and GE operators
Karel Zak [Wed, 8 Nov 2023 10:42:11 +0000 (11:42 +0100)] 
libsmartcols: (filter) add upper case EQ,NE,LE,LT,GT and GE operators

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoci: packit: add flex
Karel Zak [Mon, 6 Nov 2023 21:34:49 +0000 (22:34 +0100)] 
ci: packit: add flex

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agomeson: fix copy & past error
Karel Zak [Mon, 6 Nov 2023 21:16:47 +0000 (22:16 +0100)] 
meson: fix copy & past error

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: build filter scanner and parser header files too
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agomeson: add missing scols sample
Karel Zak [Mon, 6 Nov 2023 20:44:09 +0000 (21:44 +0100)] 
meson: add missing scols sample

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agogithub: fix build with clang and in ubuntu build-root
Karel Zak [Fri, 3 Nov 2023 08:30:38 +0000 (09:30 +0100)] 
github: fix build with clang and in ubuntu build-root

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agotests: update lsfd broken filter test
Karel Zak [Thu, 2 Nov 2023 13:17:33 +0000 (14:17 +0100)] 
tests: update lsfd broken filter test

* empty filter is valid in the new implementation

* expression without operators (for example -Q 'FD') is valid. The
  library check is the cell is non-empty in this case.

* update error messages

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: improve parser error messages
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>
6 months agolibsmartcols: prefer float in filter expression
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>
6 months agolsfd: use SCOLS_JSON_FLOAT
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>
6 months agolibsmartcols: fix filter parser initialization
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>
6 months agolsfd: fix memory leak in append_filter_expr()
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>
6 months agolibsmartcols: accept also '/' in column name for filters
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>
6 months agolibsmartcols: accept '%:-' in column name for filters
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>
6 months agolsblk: make sure all line data are deallocated
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>
6 months agolibsmartcols: add filter API docs
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>
6 months agolibsmartcols: cleanup datafunc() API
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>
6 months agolibsmartcols: don't directly access struct members
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>
6 months agolsblk: ignore duplicate lines for counters
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>
6 months agolibsmartcols: (filter) normalize param strings
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>
6 months agolibsmartcols: (filter) cleanup __filter_new_node()
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>
6 months agolibsmartcols: (filter) fix regex deallocation
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>
6 months agolibsmartcols: (filter) use also rpmatch() for boolean
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>
6 months agolibsmartcols: (filter) improve holder use
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>
6 months agolibsmartcols: (filter) support period in identifier
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>
6 months agolsfd: keep filter-only columns hidden
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>
6 months agomeson: update for libsmartcols filter
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>
6 months agolibsmartcols: (filter) improve holder status
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>
6 months agolsfd: use filter and counters from libsmartcols
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>
6 months agolibsmartcols: accept apostrophe as quote for strings in filter
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>
6 months agolsblk: report all unknown columns in filter
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>
6 months agolsblk: define cell data-types, use raw data for SIZEs
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>
6 months agolibsmartcols: introduce column type
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>
6 months agolibsmartcols: Export internally used types to API
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>
6 months agolsblk: rename sortdata to rawdata
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>
6 months agolsblk: always set column type
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>
6 months agolsblk: support normalized column names on command line
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>
6 months agolibsmartcols: search also by normalized column names (aka 'shellvar' name)
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>
6 months agolibsmartcols: make sure counter is initialized
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>
6 months agolsblk: add scols counters support
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>
6 months agolibsmartcols: implement filter based counters
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>
6 months agolsblk: split filter allocation and initialization
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>
6 months agolsblk: fix in-tree filtering
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>
6 months agolsblk: add --highlight
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>
6 months agolsblk: add --filter
Karel Zak [Wed, 20 Sep 2023 12:07:39 +0000 (14:07 +0200)] 
lsblk: add --filter

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: (filter) Add on-demand data filler
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>
6 months agolibsmartcols: Add --highlight option to filter sample
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>
6 months agolibsmartcols: (filter) add regular expression operators
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>
6 months agolibsmartcols: (filter) move struct filter_param
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>
6 months agolibsmartcols: (filter) move struct filter_expr
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>
6 months agolibsmartcols: (filter) support empty values
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>
6 months agolibsmartcols: (filter) improve scols_filter_assign_column()
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>
6 months agolibsmartcols: support SCOLS_JSON_FLOAT in print API
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>
6 months agolibsmartcols: (filter) add ability to cast data
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>
6 months agoinclude/strutils: add ul_strtold()
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>
6 months agolibsmartcols: (filter) cleanup function arguments
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>
6 months agolibsmartcols: (filter) implement data basic operators
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>
6 months agolibsmartcols (filter) fetch data from columns
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>
6 months agolibsmartcols: (filter) param data refactoring
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>
6 months agolibsmartcols: (filter) make holders API more generic
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>
6 months agolibsmartcols: (filter) cleanup data types
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>
6 months agolibsmartcols: (filter) implement logical operators
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>
6 months agolibsmartcols: (filter) evaluate params
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>
6 months agolibsmartcols: update gitignore
Karel Zak [Tue, 5 Sep 2023 08:45:45 +0000 (10:45 +0200)] 
libsmartcols: update gitignore

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibsmartcols: (filter) split code
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>
6 months agolibsmartcols: add API to join filter and columns
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>
6 months agoautotools: check for flex in autogen.sh
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>
6 months agolibsmartcols: add parser header files
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>
6 months agolibsmartcols: add filter sample
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>
6 months agolibsmartcols: improve filter integration, use JSON to dump
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>
6 months agolib/jsonwrt: add support for float numbers
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>
6 months agoautotools: fix AC_PROG_LEX use
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>
6 months agolibsmartcols: introduce basic files for filter implementation
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>