]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
9 months 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>
10 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

10 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

10 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

10 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>
10 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.

10 months agolsfd: avoid undefined behavior
Thomas Weißschuh [Sun, 19 Nov 2023 16:21:25 +0000 (17:21 +0100)] 
lsfd: avoid undefined behavior

Passing a pointer to a different datatype to tfind() then were inserted
evokes undefines behavior.
This triggers UBSAN as shown below.

Instead pass the proper structs.

```
../misc-utils/lsfd.c:513:27: runtime error: member access within misaligned address 0x7ffe9ee6495c for type 'struct proc', which requires 8 byte alignment
0x7ffe9ee6495c: note: pointer points here
  1a 1a 1a 1a 01 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  d0 49 e6 9e fe 7f 00 00
              ^
    #0 0x56159cfa4a3b in proc_tree_compare ../misc-utils/lsfd.c:513
    #1 0x7f9dd4d2d743 in __tfind (/usr/lib/libc.so.6+0x10f743) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #2 0x56159cfa4ac3 in get_proc ../misc-utils/lsfd.c:518
    #3 0x56159cfe217b in anon_pidfd_get_name ../misc-utils/lsfd-unkn.c:203
    #4 0x56159cfe1040 in unkn_fill_column ../misc-utils/lsfd-unkn.c:93
    #5 0x56159cfaaa37 in fill_column ../misc-utils/lsfd.c:1178
    #6 0x56159cfaaac5 in convert_file ../misc-utils/lsfd.c:1193
    #7 0x56159cfaac4f in convert ../misc-utils/lsfd.c:1212
    #8 0x56159cfb2b54 in main ../misc-utils/lsfd.c:2317
    #9 0x7f9dd4c45ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #10 0x7f9dd4c45d89 in __libc_start_main (/usr/lib/libc.so.6+0x27d89) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #11 0x56159cfa3c34 in _start (util-linux/build-meson/lsfd+0x41c34) (BuildId: 35fece1a205f96a2dbfe7a0e93b658530de675c4)
```

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
10 months agotreewide: explicitly mark unused arguments
Thomas Weißschuh [Sun, 19 Nov 2023 16:27:40 +0000 (17:27 +0100)] 
treewide: explicitly mark unused arguments

The autotools build used -Wno-unused-parameter to silence these warnings
for a few files. On meson however this configuration was not duplicated
leading to persistent warnings, preventing the usage of -Werror.

Instead of having to maintain the exceptions in two buildsystems, mark
the exceptions directly in the source code.

Afterward clean up autotools to not use -Wno-unused-parameter anymore.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
10 months agoMerge branch 'authors' of https://github.com/t-8ch/util-linux
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

10 months agoMerge branch 'cfdisk/resize-out-of-order' of https://github.com/t-8ch/util-linux
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

10 months agoAUTHORS: add tools contributed by myself
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>
10 months agocfdisk: properly handle out-of-order partitions during resize
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>
10 months agolibfdisk: add fdisk_partition_get_max_size
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>
10 months agolibfdisk: fix typo in debug message
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>
10 months agolsblk: add separate MAJ and MIN columns
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>
10 months agolibsmartcols: accept no data for custom wrapping cells
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>
10 months agoMerge branch 'fincore-err' of https://github.com/t-8ch/util-linux
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

10 months agotests: (lsfd::column-xmode) ignore "rwx" mappings
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>
10 months agofincore: (tests) also use nosize error file
Thomas Weißschuh [Mon, 13 Nov 2023 20:05:59 +0000 (21:05 +0100)] 
fincore: (tests) also use nosize error file

Link: https://lore.kernel.org/util-linux/b8cafd0d89878949705782312dfe800ec2779035.camel@physik.fu-berlin.de/
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
10 months agolibuuid: avoid truncate clocks.txt to improve performance
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>
10 months agoMerge branch 'lslocks--per-process' of https://github.com/masatake/util-linux
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

10 months agoMerge branch 'master' of https://github.com/ffontaine/util-linux
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

10 months agolslocks: (man) update the note about OFDLCK
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>
10 months agolslocks: (test) add a case for OFDLCK type locks
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>
10 months agolslocks: use information extracted from "locks: " column of /proc/$pid/fdinfo/*
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>
10 months agolslocks: (refactor) lift up the code destroying the lock list for future extension
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>
10 months agolslocks: rename functions for future extension
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>
10 months agolslocks: refactor the code reading /proc/locks
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>
10 months agolslocks: (refactor) remove 'pid' global variable
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>
10 months agolslocks: (man) document LEASE type
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>
10 months agolslocks: (test) add a case
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>
10 months agolibuuid/src/gen_uuid.c: fix cs_min declaration
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>
10 months agoMerge branch 'lsfd--tty' of https://github.com/masatake/util-linux
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

10 months agoMerge branch 'lslocks--man-missing-fields' of https://github.com/masatake/util-linux
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

10 months agolslocks: (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>
10 months agolibmount: fix possible NULL dereference [coverity scan]
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>
10 months agotests: (lsfd) add a case testing NAME, SOURCE, ENDPOINTS, and PTMX.TTY-INDEX columns...
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>
10 months agotests: (test_mkfds::pty) add a new factory
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>
10 months agolsfd: fill ENDPOINTS column for pty devices
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>
10 months agolsfd: add attach_xinfo and get_ipc_class methods to cdev_ops
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>
10 months agolsfd: add PTMX.TTY-INDEX column
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>
10 months agolsfd: utilize /proc/tty/drivers for filling SOURCE column of tty devices
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>
10 months agomeson: install wall executable with group 'tty'
Christian Hesse [Thu, 2 Nov 2023 10:37:33 +0000 (11:37 +0100)] 
meson: install wall executable with group 'tty'

... for proper permissions.

10 months agomeson: install write executable with group 'tty'
Christian Hesse [Tue, 31 Oct 2023 07:38:15 +0000 (08:38 +0100)] 
meson: install write executable with group 'tty'

... to fix:

write: effective gid does not match group of /dev/pts/3

10 months agoMerge branch 'PR/losetup-lost' of github.com:karelzak/util-linux-work
Karel Zak [Thu, 2 Nov 2023 10:34:39 +0000 (11:34 +0100)] 
Merge branch 'PR/losetup-lost' of github.com:karelzak/util-linux-work

* 'PR/losetup-lost' of github.com:karelzak/util-linux-work:
  loopdev: report lost loop devices

10 months agoMerge branch 'libblkid/enum' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 2 Nov 2023 10:34:20 +0000 (11:34 +0100)] 
Merge branch 'libblkid/enum' of https://github.com/t-8ch/util-linux

* 'libblkid/enum' of https://github.com/t-8ch/util-linux:
  libblkid: make enum libblkid_endianness lowercase

10 months agolibmount: improve mnt_table_next_child_fs()
Karel Zak [Thu, 2 Nov 2023 09:41:03 +0000 (10:41 +0100)] 
libmount: improve mnt_table_next_child_fs()

The function utilizes the struct libmnt_itr to iterate through the mountinfo file
but neglects the direction specified by the iterator. This a bug. The application
must manage the direction, as, for instance, umount(8) requires the children of
the mountpoint in reverse order.

Fixes: https://github.com/util-linux/util-linux/issues/2552
Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agodocs: add SPDX to boilerplate.c
Karel Zak [Wed, 1 Nov 2023 13:58:57 +0000 (14:58 +0100)] 
docs: add SPDX to boilerplate.c

Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agodisk-utils: add SPDX and Copyright notices
Karel Zak [Wed, 1 Nov 2023 13:47:41 +0000 (14:47 +0100)] 
disk-utils: add SPDX and Copyright notices

Explicitly state the license (usually GPL-2.0-or-later; our default)
and include copyright statements in all files to prevent false positive
reports from license analysis tools. Add also add SPDX-License-Identifier
tag to all files.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agoinclude/audit-arch: add missing SPDX
Karel Zak [Wed, 1 Nov 2023 12:56:01 +0000 (13:56 +0100)] 
include/audit-arch: add missing SPDX

Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agosetterm: avoid restoring flags from uninitialized memory
Chris Hofstaedtler [Tue, 31 Oct 2023 13:52:26 +0000 (14:52 +0100)] 
setterm: avoid restoring flags from uninitialized memory

Depending on the used compiler and flags, previously either F_SETFL was called
with 0 or with a random value. Never with the intended previous flags.

[kzak@redhat.com: - tiny coding style change]

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Tested-by: Emanuele Rocca <ema@debian.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agoloopdev: report lost loop devices
Junxiao Bi [Wed, 25 Oct 2023 20:36:03 +0000 (13:36 -0700)] 
loopdev: report lost loop devices

If a /dev/loopX is lost because someone might have removed it by mistake,
future losetup operations on that loop device will fail and losetup
--all and --list will not report the devices (although kernel still
uses it).

Since /sysfs still have the loop device intact, detect that and report it.

Changes:

* --list and --all add "(lost)" after device node path

  # losetup
  NAME              SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE    DIO LOG-SEC
  /dev/loop0 (lost)         0      0         0  0 /root/l0.img   0     512

  # losetup -a
  /dev/loop0 (lost): []: (/root/l0.img)

* use /sys to get devno rather than stat()

* report warning after failed operation

  # losetup -d /dev/loop0
  losetup: /dev/loop0: detach failed: No such file or directory
  losetup: device node /dev/loop0 (7:0) is lost. You may use mknod(1) to recover it.

* fix copy & past bugs in some API comments

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agolsfd: make the order of calling finalize_* and initialize_* consistent
Masatake YAMATO [Tue, 31 Oct 2023 23:18:11 +0000 (08:18 +0900)] 
lsfd: make the order of calling finalize_* and initialize_* consistent

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agolibblkid: make enum libblkid_endianness lowercase
Thomas Weißschuh [Tue, 31 Oct 2023 19:55:14 +0000 (20:55 +0100)] 
libblkid: make enum libblkid_endianness lowercase

As discussed in #2548

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agoMerge branch 'refine-the-choice-of-stream-related-functions-in-usage' of https:/...
Karel Zak [Wed, 25 Oct 2023 09:37:21 +0000 (11:37 +0200)] 
Merge branch 'refine-the-choice-of-stream-related-functions-in-usage' of https://github.com/masatake/util-linux

* 'refine-the-choice-of-stream-related-functions-in-usage' of https://github.com/masatake/util-linux:
  Make the ways of using output stream consistent in usage()
  Use fputs instead of fprintf if possible

11 months agoMerge branch 'umount/recursive-bind' of https://github.com/t-8ch/util-linux
Karel Zak [Wed, 25 Oct 2023 09:34:43 +0000 (11:34 +0200)] 
Merge branch 'umount/recursive-bind' of https://github.com/t-8ch/util-linux

* 'umount/recursive-bind' of https://github.com/t-8ch/util-linux:
  umount: handle bindmounts during --recursive
  mount: (tests) don't create /dev/nul

11 months agotests: fix memory leak in scols fromfile
Karel Zak [Tue, 24 Oct 2023 18:13:29 +0000 (20:13 +0200)] 
tests: fix memory leak in scols fromfile

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agoMake the ways of using output stream consistent in usage()
Masatake YAMATO [Tue, 24 Oct 2023 17:21:45 +0000 (02:21 +0900)] 
Make the ways of using output stream consistent in usage()

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
11 months agoUse fputs instead of fprintf if possible
Masatake YAMATO [Tue, 24 Oct 2023 16:41:58 +0000 (01:41 +0900)] 
Use fputs instead of fprintf if possible

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
11 months agolibsmartcols: fix uninitialized local variable in sample
Karel Zak [Mon, 23 Oct 2023 13:20:47 +0000 (15:20 +0200)] 
libsmartcols: fix uninitialized local variable in sample

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: add wrap-zero test
Karel Zak [Mon, 23 Oct 2023 12:47:35 +0000 (14:47 +0200)] 
libsmartcols: add wrap-zero test

* modify samples/fromfile.c to use scols_wrapzero_nextchunk() callback
  if "wrapzero" specified for the test colum
* add col-wrapzero and data-string-zero to define the column and zero
  separated data

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: support \x?? for data by samples/fromfile.c
Karel Zak [Mon, 23 Oct 2023 12:35:21 +0000 (14:35 +0200)] 
libsmartcols: support \x?? for data by samples/fromfile.c

The test (sample) binary already supports \n in strings to covert it
to the real line-break. It seem more generic to use \x?? (hex) to
support arbitrary byte in the column data.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: add new functions to API docs
Karel Zak [Mon, 23 Oct 2023 11:37:51 +0000 (13:37 +0200)] 
libsmartcols: add new functions to API docs

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agofindmnt: use zero to separate lines in multi-line cells
Karel Zak [Thu, 19 Oct 2023 11:42:08 +0000 (13:42 +0200)] 
findmnt: use zero to separate lines in multi-line cells

Fixes: https://github.com/util-linux/util-linux/issues/2533
Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: improve cell data preparation for non-wrapping cases
Karel Zak [Mon, 23 Oct 2023 19:33:38 +0000 (21:33 +0200)] 
libsmartcols: improve cell data preparation for non-wrapping cases

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: add --{export,raw,json} to wrap sample
Karel Zak [Thu, 19 Oct 2023 10:42:35 +0000 (12:42 +0200)] 
libsmartcols: add --{export,raw,json} to wrap sample

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: make calculation more robust
Karel Zak [Thu, 19 Oct 2023 09:23:20 +0000 (11:23 +0200)] 
libsmartcols: make calculation more robust

* add debug messages
* make columns stat debug more compact
* default to zero if data undefined
* fix "extreme" column enlarging

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: reset cell wrapping if all done
Karel Zak [Thu, 19 Oct 2023 08:48:59 +0000 (10:48 +0200)] 
libsmartcols: reset cell wrapping if all done

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolsblk: use zero to separate lines in multi-line cells
Karel Zak [Wed, 18 Oct 2023 10:29:17 +0000 (12:29 +0200)] 
lsblk: use zero to separate lines in multi-line cells

Fixes: https://github.com/util-linux/util-linux/issues/2533
Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: add support for zero separated wrap data
Karel Zak [Wed, 18 Oct 2023 10:28:40 +0000 (12:28 +0200)] 
libsmartcols: add support for zero separated wrap data

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: add scols_cell_refer_memory()
Karel Zak [Wed, 18 Oct 2023 08:20:12 +0000 (10:20 +0200)] 
libsmartcols: add scols_cell_refer_memory()

* allow to use non-string data
* use memcpy() rather than strdup() for data

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: always print vertical symbol
Karel Zak [Thu, 12 Oct 2023 21:15:06 +0000 (23:15 +0200)] 
libsmartcols: always print vertical symbol

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: multi-line cells refactoring
Karel Zak [Thu, 12 Oct 2023 20:38:43 +0000 (22:38 +0200)] 
libsmartcols: multi-line cells refactoring

* move data wrapping code to column.c
* do data wrapping on one place when copy cell data to buffer
* use table cursor in affected functions
* calculate tree ASCII-art to wrapped data
* mark wrap_chunksize() callback as deprecated; library calculates
  the size itself from real data

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolibsmartcols: add table cursor
Karel Zak [Thu, 12 Oct 2023 09:57:10 +0000 (11:57 +0200)] 
libsmartcols: add table cursor

The cursor makes it simple for callbacks to access information about
the current cell, line and column. It will reduce number of necessary
arguments for callbacks.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolib/mbsalign: calculate size of decoded string
Karel Zak [Thu, 12 Oct 2023 20:12:58 +0000 (22:12 +0200)] 
lib/mbsalign: calculate size of decoded string

The "safe" encoding replaces each unsafe byte with \x<hex>, the new
function mbs_safe_decoded_size() calculates the original size of the
string.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolib/buffer: make buffer usable for non-string data
Karel Zak [Tue, 10 Oct 2023 17:35:34 +0000 (19:35 +0200)] 
lib/buffer: make buffer usable for non-string data

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agolib/strutils: add ul_next_string()
Karel Zak [Wed, 11 Oct 2023 10:37:40 +0000 (12:37 +0200)] 
lib/strutils: add ul_next_string()

The function jumps to the next string in buffer where strings are
separated by \0.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agoMerge branch 'master' of https://github.com/Connor-GH/util-linux
Karel Zak [Mon, 23 Oct 2023 10:50:22 +0000 (12:50 +0200)] 
Merge branch 'master' of https://github.com/Connor-GH/util-linux

* 'master' of https://github.com/Connor-GH/util-linux:
  Fix man page for col to correct documentation error
  Update col.c to fix option mistake

11 months agoMerge branch 'libblkid/vxfs/cleanup' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:47:19 +0000 (12:47 +0200)] 
Merge branch 'libblkid/vxfs/cleanup' of https://github.com/t-8ch/util-linux

* 'libblkid/vxfs/cleanup' of https://github.com/t-8ch/util-linux:
  libblkid: (vxfs) simplify prober
  libblkid: (superblocks) add helper blkid32_to_cpu()
  libblkid: (vxfs) use hex escape for magic
  libblkid: (vxfs) add test files

11 months agoMerge branch 'wdctl/sysfs' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:37:19 +0000 (12:37 +0200)] 
Merge branch 'wdctl/sysfs' of https://github.com/t-8ch/util-linux

* 'wdctl/sysfs' of https://github.com/t-8ch/util-linux:
  wdctl: use only sysfs if sufficient

11 months agoMerge branch 'libmount/null-api' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:35:57 +0000 (12:35 +0200)] 
Merge branch 'libmount/null-api' of https://github.com/t-8ch/util-linux

* 'libmount/null-api' of https://github.com/t-8ch/util-linux:
  libmount: guard against sysapi == NULL

11 months agoMerge branch 'PR/lscpu-caches-sep' of github.com:karelzak/util-linux-work
Karel Zak [Mon, 23 Oct 2023 10:35:34 +0000 (12:35 +0200)] 
Merge branch 'PR/lscpu-caches-sep' of github.com:karelzak/util-linux-work

* 'PR/lscpu-caches-sep' of github.com:karelzak/util-linux-work:
  lscpu: fix caches separator for --parse=<list>

11 months agoMerge branch 'chfn_gecos' of https://github.com/mator/util-linux
Karel Zak [Mon, 23 Oct 2023 10:34:56 +0000 (12:34 +0200)] 
Merge branch 'chfn_gecos' of https://github.com/mator/util-linux

* 'chfn_gecos' of https://github.com/mator/util-linux:
  Use empty libuser config file.

11 months agoMerge branch 'topic-fix-fail-to-find-exfat-volume-label' of https://github.com/Yuezha...
Karel Zak [Mon, 23 Oct 2023 10:32:58 +0000 (12:32 +0200)] 
Merge branch 'topic-fix-fail-to-find-exfat-volume-label' of https://github.com/YuezhangMo/util-linux

* 'topic-fix-fail-to-find-exfat-volume-label' of https://github.com/YuezhangMo/util-linux:
  libblkid: exfat: fix fail to find volume label

11 months agoMerge branch 'misc/fixes' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:29:50 +0000 (12:29 +0200)] 
Merge branch 'misc/fixes' of https://github.com/t-8ch/util-linux

* 'misc/fixes' of https://github.com/t-8ch/util-linux:
  meson: don't try to build test_ca without libcap-ng
  blkpr: store return value of getopt_long in int

11 months agoMerge branch 'meson/int-cmp' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:28:26 +0000 (12:28 +0200)] 
Merge branch 'meson/int-cmp' of https://github.com/t-8ch/util-linux

* 'meson/int-cmp' of https://github.com/t-8ch/util-linux:
  meson: avoid int operation with non-int

11 months agoMerge branch 'path' of https://github.com/stoeckmann/util-linux
Karel Zak [Mon, 23 Oct 2023 10:26:45 +0000 (12:26 +0200)] 
Merge branch 'path' of https://github.com/stoeckmann/util-linux

* 'path' of https://github.com/stoeckmann/util-linux:
  sys-utils/lscpu: Use ul_path_scanf where possible
  lib/path: Set errno in case of fgets failure
  lib/path: fix typos
  lib/path: remove ul_prefix_fopen
  lib/path: set errno in case of error
  lib/path: fix possible out of boundary access

11 months agoMerge branch 'login-simplify' of https://github.com/stoeckmann/util-linux
Karel Zak [Mon, 23 Oct 2023 10:23:51 +0000 (12:23 +0200)] 
Merge branch 'login-simplify' of https://github.com/stoeckmann/util-linux

* 'login-simplify' of https://github.com/stoeckmann/util-linux:
  login: access login.noauth file directly
  login: use xasprintf

11 months agoFix man page for col to correct documentation error
Connor-GH [Sat, 21 Oct 2023 22:58:36 +0000 (17:58 -0500)] 
Fix man page for col to correct documentation error

11 months agoUpdate col.c to fix option mistake
Connor-GH [Sat, 21 Oct 2023 22:55:49 +0000 (17:55 -0500)] 
Update col.c to fix option mistake

11 months agoumount: handle bindmounts during --recursive
Thomas Weißschuh [Tue, 17 Oct 2023 16:06:15 +0000 (18:06 +0200)] 
umount: handle bindmounts during --recursive

Fixes #2551

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agomount: (tests) don't create /dev/nul
Thomas Weißschuh [Tue, 17 Oct 2023 16:01:31 +0000 (18:01 +0200)] 
mount: (tests) don't create /dev/nul

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agowdctl: use only sysfs if sufficient
Thomas Weißschuh [Fri, 13 Oct 2023 14:44:51 +0000 (16:44 +0200)] 
wdctl: use only sysfs if sufficient

Also avoid opening device if nowayout is set.

Opening the device node starts the watchdog.
With 'nowayout' enabled unstoppably.

Also the device node can only be opened once at the same time which can
be problematic.

Prefer to retrieve the information via sysfs which does not have such
problems.

Fixes #2543

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agolibblkid: (vxfs) simplify prober
Thomas Weißschuh [Sat, 14 Oct 2023 10:56:42 +0000 (12:56 +0200)] 
libblkid: (vxfs) simplify prober

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agolibblkid: (superblocks) add helper blkid32_to_cpu()
Thomas Weißschuh [Sat, 14 Oct 2023 10:56:04 +0000 (12:56 +0200)] 
libblkid: (superblocks) add helper blkid32_to_cpu()

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agolibblkid: (vxfs) use hex escape for magic
Thomas Weißschuh [Sat, 14 Oct 2023 10:18:14 +0000 (12:18 +0200)] 
libblkid: (vxfs) use hex escape for magic

It's easier to read and more consistent.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agolibblkid: (vxfs) add test files
Thomas Weißschuh [Sat, 14 Oct 2023 10:14:42 +0000 (12:14 +0200)] 
libblkid: (vxfs) add test files

The test files have been constructed manually from the prober.
While not providing a real test at least they make sure that the
existing logic stays stable.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agolibmount: guard against sysapi == NULL
Thomas Weißschuh [Fri, 13 Oct 2023 08:17:16 +0000 (10:17 +0200)] 
libmount: guard against sysapi == NULL

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
11 months agolscpu: fix caches separator for --parse=<list>
Karel Zak [Thu, 12 Oct 2023 22:03:15 +0000 (00:03 +0200)] 
lscpu: fix caches separator for --parse=<list>

Fixes: https://github.com/util-linux/util-linux/issues/2544
Signed-off-by: Karel Zak <kzak@redhat.com>
11 months agoUse empty libuser config file.
Anatoly Pugachev [Thu, 12 Oct 2023 11:13:02 +0000 (14:13 +0300)] 
Use empty libuser config file.

In case of an absence /etc/libuser.conf, use empty file by pointing
LIBUSER_CONF to /dev/null. This allows chfn/gecos to pass without error.

PS: The "libuser" library is no longer maintained, and it was recommended
by the original author to not use it anymore.