]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
23 months agoMerge branch 'PR/libmount-utab-external' of github.com:karelzak/util-linux-work
Karel Zak [Tue, 5 Dec 2023 10:09:38 +0000 (11:09 +0100)] 
Merge branch 'PR/libmount-utab-external' of github.com:karelzak/util-linux-work

* 'PR/libmount-utab-external' of github.com:karelzak/util-linux-work:
  tests: make mount/special more robust
  tests: add missing file and improve options-missing test
  libmount: test utab options after helper call
  libmount: add missing utab options after helper call
  libmount: add private mnt_optstr_get_missing()

23 months agoMerge branch 'unshare-maps' of https://github.com/arachsys-prs/util-linux
Karel Zak [Tue, 5 Dec 2023 10:08:57 +0000 (11:08 +0100)] 
Merge branch 'unshare-maps' of https://github.com/arachsys-prs/util-linux

* 'unshare-maps' of https://github.com/arachsys-prs/util-linux:
  unshare: Add --map-users=all and --map-groups=all
  unshare: Set uid and gid maps directly when run as root
  unshare: Support multiple ID ranges for user and group maps

23 months agoMerge branch 'unblockable-kill' of https://github.com/arachsys-prs/util-linux
Karel Zak [Tue, 5 Dec 2023 10:08:15 +0000 (11:08 +0100)] 
Merge branch 'unblockable-kill' of https://github.com/arachsys-prs/util-linux

* 'unblockable-kill' of https://github.com/arachsys-prs/util-linux:
  unshare: don't try to reset the disposition of SIGKILL

23 months agoMerge branch 'kraj/basename' of https://github.com/kraj/util-linux
Karel Zak [Tue, 5 Dec 2023 10:06:57 +0000 (11:06 +0100)] 
Merge branch 'kraj/basename' of https://github.com/kraj/util-linux

* 'kraj/basename' of https://github.com/kraj/util-linux:
  login-utils: include libgen.h for basename API

23 months agoMerge branch 'audit-arch/alpha' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 5 Dec 2023 10:01:25 +0000 (11:01 +0100)] 
Merge branch 'audit-arch/alpha' of https://github.com/t-8ch/util-linux

* 'audit-arch/alpha' of https://github.com/t-8ch/util-linux:
  audit-arch: add support for alpha

23 months agoMerge branch 'libblkid/wipe-all' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 5 Dec 2023 09:51:43 +0000 (10:51 +0100)] 
Merge branch 'libblkid/wipe-all' of https://github.com/t-8ch/util-linux

* 'libblkid/wipe-all' of https://github.com/t-8ch/util-linux:
  libfdisk: use new blkid_wipe_all helper
  libblkid: introduce blkid_wipe_all

23 months agotests: make mount/special more robust
Karel Zak [Fri, 1 Dec 2023 10:45:10 +0000 (11:45 +0100)] 
tests: make mount/special more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agounshare: don't try to reset the disposition of SIGKILL
Chris Webb [Mon, 4 Dec 2023 18:15:14 +0000 (18:15 +0000)] 
unshare: don't try to reset the disposition of SIGKILL

If the child process is killed with SIGKILL, don't attempt to reset the
disposition of SIGKILL (which can't be caught or ignored anyway) before
self-signalling. This caused a misleading 'sigprocmask unblock failed'
error instead of dying with the same SIGKILL status as the child.

Fixes: https://github.com/util-linux/util-linux/issues/2614
Signed-off-by: Chris Webb <chris@arachsys.com>
2 years agologin-utils: include libgen.h for basename API
Khem Raj [Mon, 4 Dec 2023 03:59:46 +0000 (19:59 -0800)] 
login-utils: include libgen.h for basename API

musl has removed the non-prototype declaration of basename from string.h [1] which now results in build errors with clang-17+ compiler

include libgen.h for using the posix declaration of the funciton.

Fixes

../util-linux-2.39.2/login-utils/su-common.c:847:20: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  847 |                 shell_basename = basename(shell);
      |                                  ^

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 years agolibmount: fix fsconfig value unescaping
Karel Zak [Fri, 1 Dec 2023 10:10:50 +0000 (11:10 +0100)] 
libmount: fix fsconfig value unescaping

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoaudit-arch: add support for alpha
Thomas Weißschuh [Fri, 1 Dec 2023 08:45:21 +0000 (09:45 +0100)] 
audit-arch: add support for alpha

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agotests: add missing file and improve options-missing test
Karel Zak [Thu, 30 Nov 2023 09:25:45 +0000 (10:25 +0100)] 
tests: add missing file and improve options-missing test

* remove optional ID= field (not on systems without statx())
* add missing tests/expected/mount/special-missing-options
* make sure utab is created
* use udevadm settle to wait for systemd

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'ci/meson-werror' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 30 Nov 2023 10:28:21 +0000 (11:28 +0100)] 
Merge branch 'ci/meson-werror' of https://github.com/t-8ch/util-linux

* 'ci/meson-werror' of https://github.com/t-8ch/util-linux:
  ci: enable -Werror for meson

2 years agounshare: Add --map-users=all and --map-groups=all
Chris Webb [Thu, 23 Nov 2023 14:06:02 +0000 (14:06 +0000)] 
unshare: Add --map-users=all and --map-groups=all

Accept the special value 'all' for --map-users and --map-groups,
configuring a pass-through mapping of every user or group ID available
in the parent user namespace.

These are invaluable for scripting tests, for example when you want to
remap users leaving groups unchanged, remap groups leaving users unchanged,
or create a pass-through user namespace which maps the same users and
groups as its parent but has no capabilities in that parent namespace.

In the root user namespace, 'all' is equivalent to '0:0:4294967295', but
in child namespaces it may represent a fragmented mapping corresponding
to multiple --map-users or --map-groups options.

Signed-off-by: Chris Webb <chris@arachsys.com>
2 years agounshare: Set uid and gid maps directly when run as root
Chris Webb [Thu, 23 Nov 2023 13:14:58 +0000 (13:14 +0000)] 
unshare: Set uid and gid maps directly when run as root

The newuidmap and newgidmap setuid helpers provided by shadow don't allow
root to set up arbitrary mappings without explicit wildcard configuration
in /etc/subuid and /etc/subgid, and are an unnecessary dependency when
unshare is run privileged.

ID-mapped mount already knows how to create uid/gid maps directly for new
user namespaces, so teach unshare to do the same thing when run as root.
Continue to use the setuid helpers when we are not sufficiently privileged
to do the job ourselves.

Signed-off-by: Chris Webb <chris@arachsys.com>
2 years agounshare: Support multiple ID ranges for user and group maps
Chris Webb [Thu, 23 Nov 2023 12:24:58 +0000 (12:24 +0000)] 
unshare: Support multiple ID ranges for user and group maps

Accept multiple --map-users and --map-groups options to specify disjoint ID
ranges to map inside a user namespace. This was already supported by mount
--map-groups and --map-users, but paradoxically not by unshare itself.

Factor out the hole-punching logic which removes single-ID mappings set
with --map-user and --map-group from range mappings set with --map-users
and --map-groups. add_single_map_range() now performs this fixup for
every given range before prepending the single-ID mapping.

Signed-off-by: Chris Webb <chris@arachsys.com>
2 years agolibfdisk: use new blkid_wipe_all helper
Thomas Weißschuh [Wed, 29 Nov 2023 18:51:49 +0000 (19:51 +0100)] 
libfdisk: use new blkid_wipe_all helper

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolibblkid: introduce blkid_wipe_all
Thomas Weißschuh [Wed, 29 Nov 2023 18:51:37 +0000 (19:51 +0100)] 
libblkid: introduce blkid_wipe_all

This helper makes the common task of wiping all signatures easier.

Fixes #2592
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolibmount: test utab options after helper call
Thomas Weißschuh [Wed, 29 Nov 2023 18:15:47 +0000 (19:15 +0100)] 
libmount: test utab options after helper call

See #2607

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolibmount: add missing utab options after helper call
Karel Zak [Wed, 29 Nov 2023 11:37:52 +0000 (12:37 +0100)] 
libmount: add missing utab options after helper call

libmount is able to add missing entry to /run/mount/utab after
external /sbin/mouht.<type> helper execution. This is not enough, it's
possible that the helper write proper entry to the utab, but there is
missing some options expected by libmount (usually because the options
are irrelevant fro the helper.

Reproducer:

 Create a stupid mount.foo which writes x-foo=123 to utab:

   # echo -e '#!/bin/bash\n\n/bin/mount -i "$1" "$2" -o x-foo=123' > /sbin/mount.foo
   # chmod +x /sbin/mount.foo

 Run mount which needs to write x-bar=BAR options to utab and executes
 the helper (due to "-t foo", /dev/sdc1 is ext4):

   # mount -t foo /dev/sdc1 /mnt/test -o x-bar=BAR

 old mount:

   # cat /run/mount/utab
   ID=121 SRC=/dev/sdc1 TARGET=/mnt/test ROOT=/ OPTS=x-foo=123

 fixed mount:

   # cat /run/mount/utab
   ID=121 SRC=/dev/sdc1 TARGET=/mnt/test ROOT=/ OPTS=x-foo=123,x-bar=BAR

Fixes: https://github.com/util-linux/util-linux/issues/2554
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibmount: add private mnt_optstr_get_missing()
Karel Zak [Wed, 29 Nov 2023 11:19:55 +0000 (12:19 +0100)] 
libmount: add private mnt_optstr_get_missing()

The function compares two options strings and returns options which
are missing.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'chsh-getusershell' of https://github.com/thkukuk/util-linux
Karel Zak [Wed, 29 Nov 2023 08:39:41 +0000 (09:39 +0100)] 
Merge branch 'chsh-getusershell' of https://github.com/thkukuk/util-linux

* 'chsh-getusershell' of https://github.com/thkukuk/util-linux:
  chsh: use libeconf to read /etc/shells

2 years agoAdd Phytium FTC310 & FTC664 support
zuoqian [Wed, 29 Nov 2023 02:57:52 +0000 (02:57 +0000)] 
Add Phytium FTC310 & FTC664 support

Signed-off-by: zuoqian <zuoqian2023@gmail.com>
2 years agochsh: use libeconf to read /etc/shells
Thorsten Kukuk [Thu, 23 Nov 2023 13:23:00 +0000 (14:23 +0100)] 
chsh: use libeconf to read /etc/shells

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
2 years agolibmount: accept '\' as escape for options separator
Karel Zak [Tue, 28 Nov 2023 13:40:48 +0000 (14:40 +0100)] 
libmount: accept '\' as escape for options separator

The libmount library can accept any characters as an option value when
the value is quoted (e.g., foo="b,a,r"). However, overlayfs users have
been using '\' as an escape character (e.g., lowerdir=foo\,bar).

Although this escaping mechanism was never officially supported by
libmount/mount, it worked for the old mount(2) API because it kept the
options string unparsed for the mount(2) syscall.

The introduction of the new mount API, which utilizes fsconfig(2) per
option, has brought attention to this issue.

This patch addresses the problem by introducing official support for
'\' as an escape character for options separator.

Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
References: https://lore.kernel.org/all/CAOQ4uxhgUSPkYAV8SJu-SFszkJcVO3-M4DXf46nJUtXODrPk2g@mail.gmail.com/T/#ma8e6cfc1ce7229abc089e03eed99b23b90d701e5
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolosetup: report lost loop devices for finding free loop
Junxiao Bi [Tue, 7 Nov 2023 18:48:06 +0000 (10:48 -0800)] 
losetup: report lost loop devices for finding free loop

commit a6ca0456cc6d("loopdev: report lost loop devices") forgot to
report lost loop device for finding free loop case. With this path,
it will show the following if next free loop device is lost.

 # ./losetup -f
 /dev/loop1 (lost)
 # ./losetup -f /tmp/test.img
 lt-losetup: /tmp/test.img: failed to set up loop device: No such file or directory
 lt-losetup: device node /dev/loop1 (7:1) is lost. You may use mknod(1) to recover it.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
2 years agoci: enable -Werror for meson
Thomas Weißschuh [Fri, 24 Nov 2023 10:38:12 +0000 (11:38 +0100)] 
ci: enable -Werror for meson

Now that all warnings have been eliminated from the meson build, make
sure no new ones are introduced.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoMerge branch 'minor-changes-about-new-filter' of https://github.com/masatake/util...
Karel Zak [Fri, 24 Nov 2023 09:21:58 +0000 (10:21 +0100)] 
Merge branch 'minor-changes-about-new-filter' of https://github.com/masatake/util-linux

* 'minor-changes-about-new-filter' of https://github.com/masatake/util-linux:
  lsfd: (man) document --list-columns as the way to list columns
  lsfd: (man) refer to scols-filter(5)
  libsmartcols: (man) fix typos

2 years agoMerge branch 'lslocks--co-holders' of https://github.com/masatake/util-linux
Karel Zak [Fri, 24 Nov 2023 09:21:36 +0000 (10:21 +0100)] 
Merge branch 'lslocks--co-holders' of https://github.com/masatake/util-linux

* 'lslocks--co-holders' of https://github.com/masatake/util-linux:
  tests: (lslocks) add cases testing HOLDERS column
  tests: (cosmetic,lslocks) trim whitespaces at the end of line
  tests: (test_mkfds::make-regular-file) add a new parameter, "dupfd"
  lslocks: add HOLDERS column
  lslocks: store list_add_tail when storing information extracted from /proc/$pid/fdinfo/$fd
  tests: (test_mkfds) initialize a proper union member
  xalloc.h: add new functions: xstrappend, xstrputc, xstrvfappend, and xstrfappend
  lsfd: (refactor) make the code comparing struct lock objects reusable
  lslocks: add a missing "break;" in a switch/case statement
  lslocks: (preparation) add a fd number to the lock struct when loading lock info from /proc/$pid/fdinfo/$fd
  lslocks: (refactor) use a tree for storing lock information extracted from /proc/$pid/fdinfo/$fd
  lslocks: (refactor) make the data structure for storing lock information replacable

2 years agolibsmartcols: (filter) fix dereferences and leaks [coverity scann]
Karel Zak [Fri, 24 Nov 2023 09:20:54 +0000 (10:20 +0100)] 
libsmartcols: (filter) fix dereferences and leaks [coverity scann]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsfd: (man) document --list-columns as the way to list columns
Masatake YAMATO [Thu, 23 Nov 2023 13:48:52 +0000 (22:48 +0900)] 
lsfd: (man) document --list-columns as the way to list columns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: (man) refer to scols-filter(5)
Masatake YAMATO [Thu, 23 Nov 2023 13:41:38 +0000 (22:41 +0900)] 
lsfd: (man) refer to scols-filter(5)

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolibsmartcols: (man) fix typos
Masatake YAMATO [Thu, 23 Nov 2023 13:36:26 +0000 (22:36 +0900)] 
libsmartcols: (man) fix typos

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lslocks) add cases testing HOLDERS column
Masatake YAMATO [Tue, 21 Nov 2023 19:37:30 +0000 (04:37 +0900)] 
tests: (lslocks) add cases testing HOLDERS column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (cosmetic,lslocks) trim whitespaces at the end of line
Masatake YAMATO [Thu, 23 Nov 2023 13:29:41 +0000 (22:29 +0900)] 
tests: (cosmetic,lslocks) trim whitespaces at the end of line

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (test_mkfds::make-regular-file) add a new parameter, "dupfd"
Masatake YAMATO [Tue, 21 Nov 2023 19:00:50 +0000 (04:00 +0900)] 
tests: (test_mkfds::make-regular-file) add a new parameter, "dupfd"

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolslocks: add HOLDERS column
Masatake YAMATO [Tue, 21 Nov 2023 18:58:51 +0000 (03:58 +0900)] 
lslocks: add HOLDERS column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolslocks: store list_add_tail when storing information extracted from /proc/$pid/fdinf...
Masatake YAMATO [Tue, 21 Nov 2023 19:30:59 +0000 (04:30 +0900)] 
lslocks: store list_add_tail when storing information extracted from /proc/$pid/fdinfo/$fd

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (test_mkfds) initialize a proper union member
Masatake YAMATO [Tue, 21 Nov 2023 18:57:54 +0000 (03:57 +0900)] 
tests: (test_mkfds) initialize a proper union member

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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
  ...

2 years 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

2 years 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>
2 years 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>
2 years 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

2 years 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

2 years 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>
2 years 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.

2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>