]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
6 months agoMerge branch 'master' of https://github.com/AntonMoryakov/util-linux
Karel Zak [Thu, 16 Jan 2025 16:07:59 +0000 (17:07 +0100)] 
Merge branch 'master' of https://github.com/AntonMoryakov/util-linux

* 'master' of https://github.com/AntonMoryakov/util-linux:
  sys-utils: fix add NULL check for mnt_fs_get_target return value

6 months agolsfd: remove C++ comment
Karel Zak [Thu, 16 Jan 2025 16:06:19 +0000 (17:06 +0100)] 
lsfd: remove C++ comment

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoMerge branch 'patch-2' of https://github.com/hmaarrfk/util-linux
Karel Zak [Thu, 16 Jan 2025 16:02:51 +0000 (17:02 +0100)] 
Merge branch 'patch-2' of https://github.com/hmaarrfk/util-linux

* 'patch-2' of https://github.com/hmaarrfk/util-linux:
  refactor things to avoid an other header.
  Include errno.h within lsfd.c

6 months agorefactor things to avoid an other header.
Mark Harfouche [Tue, 14 Jan 2025 16:25:19 +0000 (11:25 -0500)] 
refactor things to avoid an other header.

6 months agosys-utils: fix add NULL check for mnt_fs_get_target return value
AntonMoryakov [Tue, 14 Jan 2025 15:06:49 +0000 (18:06 +0300)] 
sys-utils: fix add NULL check for mnt_fs_get_target return value

The static analyzer flagged a potential issue: the return value of
mnt_fs_get_target(fs) could be NULL, but it was dereferenced without
a check. This could lead to undefined behavior.

Added a NULL check before using the tgt pointer. If tgt is NULL,
the current iteration is skipped.

ChanChanges:
- Added if (!tgt) check before using tgt.

Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
6 months agoMerge branch 'PR/libblkid-save-memleak' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 14 Jan 2025 09:31:58 +0000 (10:31 +0100)] 
Merge branch 'PR/libblkid-save-memleak' of https://github.com/karelzak/util-linux-work

* 'PR/libblkid-save-memleak' of https://github.com/karelzak/util-linux-work:
  libblkid: fix potential memory leaks

6 months agoMerge branch 'PR/non-linux' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 14 Jan 2025 09:31:32 +0000 (10:31 +0100)] 
Merge branch 'PR/non-linux' of https://github.com/karelzak/util-linux-work

* 'PR/non-linux' of https://github.com/karelzak/util-linux-work:
  Fix non-Linux build

6 months agoMerge branch 'PR/hardlink-mem-issues2' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 14 Jan 2025 09:31:17 +0000 (10:31 +0100)] 
Merge branch 'PR/hardlink-mem-issues2' of https://github.com/karelzak/util-linux-work

* 'PR/hardlink-mem-issues2' of https://github.com/karelzak/util-linux-work:
  hardlink: fix memory corruption in read buffers

6 months agoMerge branch 'login-respect-dollar-home' of https://github.com/poettering/util-linux
Karel Zak [Tue, 14 Jan 2025 09:24:35 +0000 (10:24 +0100)] 
Merge branch 'login-respect-dollar-home' of https://github.com/poettering/util-linux

* 'login-respect-dollar-home' of https://github.com/poettering/util-linux:
  login: actually honour $HOME for chdir()

6 months agoInclude errno.h within lsfd.c
Mark Harfouche [Mon, 13 Jan 2025 23:07:20 +0000 (18:07 -0500)] 
Include errno.h within lsfd.c

This is needed for ENOSYS to be defined

libgcc:           14.2.0

```
2025-01-13T22:59:57.1752408Z misc-utils/lsfd.c: In function 'kcmp':
2025-01-13T22:59:57.1762407Z misc-utils/lsfd.c:66:9: error: 'errno' undeclared (first use in this function)
2025-01-13T22:59:57.1762947Z    66 |         errno = ENOSYS;
2025-01-13T22:59:57.1770931Z       |         ^~~~~
2025-01-13T22:59:57.1771263Z misc-utils/lsfd.c:40:1: note: 'errno' is defined in header '<errno.h>'; did you forget to '#include <errno.h>'?
2025-01-13T22:59:57.1771555Z    39 | #include <sys/syscall.h>
2025-01-13T22:59:57.1771767Z   +++ |+#include <errno.h>
2025-01-13T22:59:57.1771955Z    40 |
2025-01-13T22:59:57.1772231Z misc-utils/lsfd.c:66:9: note: each undeclared identifier is reported only once for each function it appears in
2025-01-13T22:59:57.1772507Z    66 |         errno = ENOSYS;
2025-01-13T22:59:57.1772684Z       |         ^~~~~
2025-01-13T22:59:57.1779860Z misc-utils/lsfd.c:66:17: error: 'ENOSYS' undeclared (first use in this function)
2025-01-13T22:59:57.1780285Z    66 |         errno = ENOSYS;
2025-01-13T22:59:57.1780499Z       |                 ^~~~~~
2025-01-13T22:59:57.2204441Z   CC       misc-utils/lsfd-lsfd-decode-file-flags.o
2025-01-13T22:59:57.2803898Z make[2]: *** [Makefile:13624: misc-utils/lsfd-lsfd.o]
```

6 months agologin: actually honour $HOME for chdir()
Lennart Poettering [Thu, 9 Jan 2025 22:57:32 +0000 (23:57 +0100)] 
login: actually honour $HOME for chdir()

When login is almost done it chdir()'s into the user's home directory.
It currently uses pwd->pw_dir, i.e the home dir actually assigned to the
user.

OTOH it explicitly allows overriding HOME (see comment in
init_environ()), and explicitly imports PAM's env vars (which quite
possibly contain $HOME) into its env block.

This patch makes sure that HOME is *properly* overridable via the env
var and via PAM: it actually honours it for the chdir().

(Background: I am working on a PAM module that under some conditions
would like to redirect the home dir to some other dir, and while I can
nicely set $HOME from the PAM module, it has not as much as effect as I
wish, because whie the rest of userspace respects it login so far didn't
and leaves the user in the wrong dir).

6 months agohardlink: fix memory corruption in read buffers
Karel Zak [Mon, 13 Jan 2025 11:06:23 +0000 (12:06 +0100)] 
hardlink: fix memory corruption in read buffers

The size of the eq->buf_a and eq->buf_b buffers depends on the
readsize setting. This setting is modified by ul_fileeq_set_size(), so
the buffers need to be resized accordingly. Deallocating is
sufficient, as they will be allocated later with the correct size.

Addresses: https://github.com/util-linux/util-linux/issues/3330
Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoFix non-Linux build
Samuel Thibault [Sun, 12 Jan 2025 15:39:44 +0000 (16:39 +0100)] 
Fix non-Linux build

This fixes non-Linux builds, by:

- making sfdisk discard option conditioned by availability of BLKDISCARD
- defining and using blkid_probe_get_buffer only if O_DIRECT is
  available
- always building src/fs_statmount.c and src/tab_listmount.c, they
  already contain proper conditions to make them void if support is not
  available.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
6 months agolibblkid: fix potential memory leaks
Karel Zak [Mon, 13 Jan 2025 10:26:06 +0000 (11:26 +0100)] 
libblkid: fix potential memory leaks

Addresses: https://github.com/util-linux/util-linux/pull/3356
Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoRevert "libmount: exec mount helpers with posixly correct argument order"
Karel Zak [Mon, 13 Jan 2025 09:43:26 +0000 (10:43 +0100)] 
Revert "libmount: exec mount helpers with posixly correct argument order"

The change is not backwardly compatible, see https://github.com/util-linux/util-linux/issues/3355

This reverts commit 2d680b72ac61644e4ba177e6569d8ca13580c248.

6 months agoMerge branch 'PR/libmount-statmount' of https://github.com/karelzak/util-linux-work
Karel Zak [Thu, 9 Jan 2025 10:13:49 +0000 (11:13 +0100)] 
Merge branch 'PR/libmount-statmount' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-statmount' of https://github.com/karelzak/util-linux-work: (40 commits)
  libmount: map unsupported LISTMOUNT_REVERSE to ENOSYS
  findmnt: add --id and --uniq-id options
  findmnt: improve --help output
  findmnt: improve reliability of match testing
  libmount: add mnt_table_find_[uniq]_id() function
  findmnt: add UNIQ-ID column
  findmnt: add docs for --kernel
  tests: add findmnt --kernel=listmount
  libmount:  fix mnt_fs_match_target()
  libmount: improve fs->stmnt_done mask use
  libmount: improve how library generates fs->optstr
  findmnt: add --kernel=listmount
  findmnt: add optional argument to --kernel
  meson: fix after rebase
  libmount: remove unnecessary include
  test_sysinfo; fix fsopen() ifdef
  libmount: Add integer type headers to private header file
  libmount: use __unused__ for dummy get_mnt_id()
  libmount: update tests
  include/mount-api-utils: fix typo
  ...

6 months agomount: print info and warning messages
Karel Zak [Tue, 3 Dec 2024 18:16:11 +0000 (19:16 +0100)] 
mount: print info and warning messages

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: read all types of kernel messages
Karel Zak [Tue, 3 Dec 2024 17:56:41 +0000 (18:56 +0100)] 
libmount: read all types of kernel messages

Previously, libmount only read error messages from fsopen() file
descriptor. This commit improves the library to read all messages
and keep them in their original format ("<type> <mesg>") in the library mount context.
Applications can now read all messages by using mnt_context_get_mesgs().

Furthermore, private functions have been implemented to include new
library-specific messages in the log. Currently, these messages are
only managed in mnt_context_get_excode(), but it would be beneficial
to relocate them to the appropriate locations where errors are
triggered.

In the future, mnt_context_get_excode() should only be utilized by
basic applications that require an one error message. For more
critical purposes (e.g. mount(8)), it will be recommended to utilize
the messages array.

The public function mnt_context_get_excode() has been modified to use
the new functionality and provide messages in a backwardly compatible
way.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoInclude/strutils: xstrncpy() returns the number of copied bytes
Karel Zak [Tue, 3 Dec 2024 17:53:04 +0000 (18:53 +0100)] 
Include/strutils: xstrncpy() returns the number of copied bytes

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: map unsupported LISTMOUNT_REVERSE to ENOSYS
Karel Zak [Wed, 8 Jan 2025 09:51:02 +0000 (10:51 +0100)] 
libmount: map unsupported LISTMOUNT_REVERSE to ENOSYS

For testing purposes, report the missing LISTMOUNT_REVERSE as missing
in the complete listmount() function.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agofindmnt: add --id and --uniq-id options
Karel Zak [Mon, 11 Nov 2024 14:39:07 +0000 (15:39 +0100)] 
findmnt: add --id and --uniq-id options

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agofindmnt: improve --help output
Karel Zak [Mon, 11 Nov 2024 14:05:59 +0000 (15:05 +0100)] 
findmnt: improve --help output

The current help output is quite lengthy. It would be beneficial to
organize it into sections, such as data sources, data filters, and
options. This would make it easier for users to navigate and
understand the available features.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agofindmnt: improve reliability of match testing
Karel Zak [Mon, 11 Nov 2024 13:52:53 +0000 (14:52 +0100)] 
findmnt: improve reliability of match testing

The "match" is defined if a string or void data is defined for the
matching function. It is necessary to test both variants instead of
relying solely on get_match(), which only returns string data.

This patch introduces the is_defined_match() macro to hide this detail
in the code and make it more readable.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: add mnt_table_find_[uniq]_id() function
Karel Zak [Mon, 11 Nov 2024 11:45:00 +0000 (12:45 +0100)] 
libmount: add mnt_table_find_[uniq]_id() function

Addresses: https://github.com/util-linux/util-linux/issues/3275
Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agofindmnt: add UNIQ-ID column
Karel Zak [Mon, 11 Nov 2024 11:44:06 +0000 (12:44 +0100)] 
findmnt: add UNIQ-ID column

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agofindmnt: add docs for --kernel
Karel Zak [Thu, 10 Oct 2024 12:22:39 +0000 (14:22 +0200)] 
findmnt: add docs for --kernel

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agotests: add findmnt --kernel=listmount
Karel Zak [Wed, 2 Oct 2024 10:35:48 +0000 (12:35 +0200)] 
tests: add findmnt --kernel=listmount

* add listmount() and statmount() check to test_sysinfo
* check for statmount fields by findmnt

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: fix mnt_fs_match_target()
Karel Zak [Wed, 2 Oct 2024 10:15:40 +0000 (12:15 +0200)] 
libmount:  fix mnt_fs_match_target()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: improve fs->stmnt_done mask use
Karel Zak [Mon, 23 Sep 2024 14:39:24 +0000 (16:39 +0200)] 
libmount: improve fs->stmnt_done mask use

It is possible that one field in the libmnt_fs struct requires
fetching multiple statmount fields using multiple STATMOUNT_* mask
items. This requires changes to the way the fs->stmnt_done mask is
used.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: improve how library generates fs->optstr
Karel Zak [Mon, 23 Sep 2024 14:34:52 +0000 (16:34 +0200)] 
libmount: improve how library generates fs->optstr

* add missing STATMOUNT_* items
* reuse merging code

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agofindmnt: add --kernel=listmount
Karel Zak [Mon, 16 Sep 2024 10:16:16 +0000 (12:16 +0200)] 
findmnt: add --kernel=listmount

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agofindmnt: add optional argument to --kernel
Karel Zak [Mon, 16 Sep 2024 09:36:41 +0000 (11:36 +0200)] 
findmnt: add optional argument to --kernel

The number of methods for reading mount nodes from the kernel is
increasing. We need a way to specify the method on the findmnt(1)
command line.

Currently, findmnt only supports the "mountinfo" method. Another
method will be added in a separate commit.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agomeson: fix after rebase
Karel Zak [Mon, 16 Sep 2024 09:33:39 +0000 (11:33 +0200)] 
meson: fix after rebase

6 months agolibmount: remove unnecessary include
Karel Zak [Wed, 21 Aug 2024 18:28:45 +0000 (20:28 +0200)] 
libmount: remove unnecessary include

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agotest_sysinfo; fix fsopen() ifdef
Karel Zak [Wed, 21 Aug 2024 13:26:07 +0000 (15:26 +0200)] 
test_sysinfo; fix fsopen() ifdef

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: Add integer type headers to private header file
Karel Zak [Wed, 21 Aug 2024 13:16:24 +0000 (15:16 +0200)] 
libmount: Add integer type headers to private header file

We use uintX_t in many places in the library, and it seems useful to
include inttypes.h and stdint.h to have access to the PRI* macros everywhere.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: use __unused__ for dummy get_mnt_id()
Karel Zak [Wed, 21 Aug 2024 08:56:50 +0000 (10:56 +0200)] 
libmount: use __unused__ for dummy get_mnt_id()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: update tests
Karel Zak [Wed, 21 Aug 2024 08:04:02 +0000 (10:04 +0200)] 
libmount: update tests

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoinclude/mount-api-utils: fix typo
Karel Zak [Wed, 21 Aug 2024 07:17:08 +0000 (09:17 +0200)] 
include/mount-api-utils: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: ifdef STATMOUNT_* in sample
Karel Zak [Tue, 20 Aug 2024 19:24:23 +0000 (21:24 +0200)] 
libmount: ifdef STATMOUNT_* in sample

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: ifdef STATX_MNT_ID_UNIQUE
Karel Zak [Tue, 20 Aug 2024 19:10:17 +0000 (21:10 +0200)] 
libmount: ifdef STATX_MNT_ID_UNIQUE

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: ifdef listmount and statmount stuff
Karel Zak [Mon, 19 Aug 2024 10:59:10 +0000 (12:59 +0200)] 
libmount: ifdef listmount and statmount stuff

* introduce mnt_fs_try_statmount() macro to simplify mnt_fs_fetch_statmount() calls

* define dummy API functions when HAVE_STATMOUNT_API undefined

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: fix typo in symbols list
Karel Zak [Thu, 15 Aug 2024 09:27:49 +0000 (11:27 +0200)] 
libmount: fix typo in symbols list

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: (docs) add missing api indexes
Karel Zak [Thu, 15 Aug 2024 09:19:30 +0000 (11:19 +0200)] 
libmount: (docs) add missing api indexes

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: add listmount() sample
Karel Zak [Thu, 15 Aug 2024 09:08:52 +0000 (11:08 +0200)] 
libmount: add listmount() sample

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: add support for listmount()
Karel Zak [Thu, 15 Aug 2024 08:26:31 +0000 (10:26 +0200)] 
libmount: add support for listmount()

The new listmount() syscall returns a list of unique mount IDs (just
uint64_t per node, nothing else). It makes it very fast and efficient.

* libmount supports two scenarios:

 - fetch the whole mount table by mnt_table_fetch_listmount(); this is
   an alternative to mnt_table_parse_file()

 - on demand; this mode is an extension to the current functionality,
   when enabled by mnt_table_enable_listmount(), then mnt_table_next_fs()
   will ask the kernel for data by listmount.

   If mnt_table_next_fs() iterates on the mount table in reverse order
   (MNT_ITER_BACKWARD), then it reads mount nodes from the kernel in
   reverse order too.

   The advantage of the on-demand mode is that on machines with a huge
   mount table (thousands of nodes), we can work with only a subset of
   the table (usually the last few nodes with the most recently
   mounted filesystems), and the kernel does not have to compose a complete
   huge table. This should be an improvement over the mountinfo file.

The default is to read 512 nodes (IDs) by one listmount() call. This
size can be altered by mnt_table_listmount_set_stepsiz(). The default
size should be large enough for usual Linux machines.

It's also possible to set a sub-tree by mnt_table_listmount_set_id()
and a namespace by mnt_table_listmount_set_ns().

If libmnt_statmnt (on-demand statmount()) is assigned to the table,
then all filesystems in the table are automatically assigned to this
statmount() setup too. This allows for a completely on-demand
scenario.

tb = mnt_new_table();
sm = mnt_new_statmnt();

mnt_table_refer_statmnt(tb, sm); /* enable statmount() */
mnt_table_enable_listmount(tb, 1); /* enable listmount() */

while (mnt_table_next_fs(tb, itr, &fs) == 0) {
if (strcmp("vfat", mnt_fs_get_fstype(fs)) == 0)
print("%s", mnt_fs_get_fs_options(fs));
}

In this example, mnt_table_next_fs() serves as the frontend for
listmount() and mnt_fs_get_...() serves as the frontend for
statmount(). The fs-options are read from kernel only for "vfat"
filesystems.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoinclude/timeutils: add time_diff()
Karel Zak [Tue, 6 Aug 2024 12:07:43 +0000 (14:07 +0200)] 
include/timeutils: add time_diff()

Eliminate redundant code and define time_diff() only once.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: fix __table_insert_fs()
Karel Zak [Thu, 15 Aug 2024 07:49:06 +0000 (09:49 +0200)] 
libmount: fix __table_insert_fs()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: add support for statmount()
Karel Zak [Wed, 14 Aug 2024 15:10:45 +0000 (17:10 +0200)] 
libmount: add support for statmount()

* introduce libmnt_statmnt object to store statmount mask and buffer
  (etc.)

* add API for libmnt_fs to retrieve data from the kernel using
  statmount()

* support on-demand statmount() from old mnt_fs_get_...() functions

* allow libmnt_statmnt to be shared and reused between libmnt_fs
  instances

* allow libmnt_statmnt to be assigned and used for filesystems in the
  table (assign libmnt_statmnt to the table to make it usable for all
  filesystems).

* allow temporary disabling of fetching data from the kernel to avoid
  unwanted recursion in certain use-cases

* support namespaces for statmount() based on the libmnt_fs namespace
  ID setting

* allow user-defined statmount masks to overwrite the default

* add a sample program

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoinclude/c: add BIT()
Karel Zak [Wed, 14 Aug 2024 15:03:51 +0000 (17:03 +0200)] 
include/c: add BIT()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: use unique ID in utab
Karel Zak [Wed, 12 Jun 2024 11:14:18 +0000 (13:14 +0200)] 
libmount: use unique ID in utab

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: add API to read ID by statx()
Karel Zak [Wed, 14 Aug 2024 14:28:48 +0000 (16:28 +0200)] 
libmount: add API to read ID by statx()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: Add API to get/set unique IDs
Karel Zak [Tue, 11 Jun 2024 09:55:39 +0000 (11:55 +0200)] 
libmount: Add API to get/set unique IDs

Since the Linux kernel version 6.8, there are two types of IDs
available: the "old" ID used in /proc/self/mountinfo, and a new 64-bit
unique ID that is never recycled. This new ID is provided by the
statx(STATX_MNT_ID_UNIQUE) and statmount() syscalls.

Note that this patch only adds the API for retrieving these unique
IDs, but the backing code has not been implemented yet.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: remember parsed propagation
Karel Zak [Thu, 13 Jun 2024 08:30:24 +0000 (10:30 +0200)] 
libmount: remember parsed propagation

This change allows propagation flags to be retained from another
source, such as statmount().

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: add statmount to features list
Karel Zak [Thu, 18 Jul 2024 09:26:13 +0000 (11:26 +0200)] 
libmount: add statmount to features list

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agolibmount: add mount-api-utils.h to mountP.h
Karel Zak [Mon, 22 Jul 2024 12:12:37 +0000 (14:12 +0200)] 
libmount: add mount-api-utils.h to mountP.h

The new syscalls (statmount and fd-based mount) are already being
utilized in various areas within the library. Therefore, it would be
more efficient to include the syscalls header file in the private main
library header file.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoinclude/mount-api-utils: add statmount and listmount
Karel Zak [Wed, 14 Aug 2024 13:33:44 +0000 (15:33 +0200)] 
include/mount-api-utils: add statmount and listmount

* Make the includes and ifdefs in the file more generic, to cover
  other interfaces besides just HAVE_MOUNTFD_API.

* Add #ifdef HAVE_STATMOUNT_API to the header file.

* Add fallbacks for statmount and listmount masks and flags.

* Add a local definition of the structs mnt_id_req and statmount.

  We do not want to depend on kernel headers for now, as all of this is
  still under development. Installed headers may provide old versions,
  and a solution based on #ifdef will still require local definition of
  the structs.

* Add wrappers for the statmount() and listmount() syscalls.

* Add sys_statmount(), a wrapper for statmount() that reallocates the
  statmount buffer (on EOVERFLOW errno) if it is not large enough.

Note that for now, we are directly using syscalls and do not require
libc support for statmount() and listmount(). The kernel API is very
extensible, as it is based on structs rather than syscall arguments.
Therefore, I doubt we will see any libc support in the near future.

The code uses the "ul_" prefix for locally defined variables and
functions to prevent conflicts with kernel headers and potential
future versions of libc.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agomeson: check for statmount and listmount syscalls
Karel Zak [Wed, 14 Aug 2024 13:31:57 +0000 (15:31 +0200)] 
meson: check for statmount and listmount syscalls

... keep statx stuff on one place.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoautotools: check for statmount and listmount syscalls
Karel Zak [Wed, 14 Aug 2024 13:26:17 +0000 (15:26 +0200)] 
autotools: check for statmount and listmount syscalls

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agoMerge branch 'pam' of https://github.com/kekek2/util-linux
Karel Zak [Wed, 8 Jan 2025 12:35:30 +0000 (13:35 +0100)] 
Merge branch 'pam' of https://github.com/kekek2/util-linux

* 'pam' of https://github.com/kekek2/util-linux:
  meson: add checking build-findfs.
  meson: Fix checking options build-bits.
  meson: Check options for building lib_pam_misc

6 months agoMerge branch 'master' of https://github.com/mjsir911/util-linux
Karel Zak [Wed, 8 Jan 2025 12:29:53 +0000 (13:29 +0100)] 
Merge branch 'master' of https://github.com/mjsir911/util-linux

* 'master' of https://github.com/mjsir911/util-linux:
  Fix table formatting

6 months agoMerge branch 'revise--test-cases' of https://github.com/masatake/util-linux
Karel Zak [Wed, 8 Jan 2025 11:40:30 +0000 (12:40 +0100)] 
Merge branch 'revise--test-cases' of https://github.com/masatake/util-linux

* 'revise--test-cases' of https://github.com/masatake/util-linux:
  tests: (lsfd::mkfds_vsock) skip if diag socket for AF_VSOCK is unavailable
  tests: (test_mkfds::sockdiag) support AF_VSOCK family
  tests: (lsns::filter) skip if /proc/self/uid_map is not writable

6 months agoMerge branch 'meson-disabler' of https://github.com/thesamesam/util-linux
Karel Zak [Wed, 8 Jan 2025 11:39:29 +0000 (12:39 +0100)] 
Merge branch 'meson-disabler' of https://github.com/thesamesam/util-linux

* 'meson-disabler' of https://github.com/thesamesam/util-linux:
  meson: add missing `is_disabler` checks

6 months agoci: bump coveralls compiler version to gcc 13
Karel Zak [Wed, 8 Jan 2025 10:35:03 +0000 (11:35 +0100)] 
ci: bump coveralls compiler version to gcc 13

coverall CI output:

COMPILER=gcc
COMPILER_VERSION=10
...
Found gcov version: 13.2.0
...
geninfo: ERROR: Incompatible GCC/GCOV version found

Signed-off-by: Karel Zak <kzak@redhat.com>
6 months agomeson: add missing `is_disabler` checks
Sam James [Wed, 8 Jan 2025 06:49:40 +0000 (06:49 +0000)] 
meson: add missing `is_disabler` checks

Noticed this when looking at why the `check` target isn't created
with `-Dauto_features=disabled`. This doesn't fix that but it does
fix a bunch of issues I noticed along the way after a hint from Eli Schwartz.

6 months agotests: (lsfd::mkfds_vsock) skip if diag socket for AF_VSOCK is unavailable
Masatake YAMATO [Mon, 6 Jan 2025 12:04:09 +0000 (21:04 +0900)] 
tests: (lsfd::mkfds_vsock) skip if diag socket for AF_VSOCK is unavailable

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agotests: (test_mkfds::sockdiag) support AF_VSOCK family
Masatake YAMATO [Mon, 6 Jan 2025 12:01:46 +0000 (21:01 +0900)] 
tests: (test_mkfds::sockdiag) support AF_VSOCK family

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agotests: (lsns::filter) skip if /proc/self/uid_map is not writable
Masatake YAMATO [Mon, 6 Jan 2025 08:34:19 +0000 (17:34 +0900)] 
tests: (lsns::filter) skip if /proc/self/uid_map is not writable

On some platforms, lsns::filter test failed with the following
message:

   +test_mkfds: failed to write to /proc/self/uid_map: -1: Operation
   not permitted

This change is to skip the test case on such platforms.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 months agoFix table formatting
M Sirabella [Mon, 6 Jan 2025 06:23:39 +0000 (22:23 -0800)] 
Fix table formatting

asciidoctor-2.0.23 was giving an error:

    asciidoctor: ERROR: fsck.minix.8.adoc: line 29: dropping cells from incomplete row detected end of table

6 months agoMerge branch 'lsfd--vsock' of https://github.com/masatake/util-linux
Karel Zak [Fri, 3 Jan 2025 09:48:25 +0000 (10:48 +0100)] 
Merge branch 'lsfd--vsock' of https://github.com/masatake/util-linux

* 'lsfd--vsock' of https://github.com/masatake/util-linux:
  lsfd: support AF_VSOCK sockets
  tests: (lsfd-functions.bash) add a missing constant
  tests: (lsfd) quote '$' in patterns in a case/esac block

6 months agoMerge branch 'PR/hardlink-mem-issues' of https://github.com/karelzak/util-linux-work
Karel Zak [Fri, 3 Jan 2025 09:44:47 +0000 (10:44 +0100)] 
Merge branch 'PR/hardlink-mem-issues' of https://github.com/karelzak/util-linux-work

* 'PR/hardlink-mem-issues' of https://github.com/karelzak/util-linux-work:
  hardlink: fix memory corruption (size calculation)

6 months agoMerge branch 'PR/fstab-space-notes' of https://github.com/karelzak/util-linux-work
Karel Zak [Fri, 3 Jan 2025 09:43:30 +0000 (10:43 +0100)] 
Merge branch 'PR/fstab-space-notes' of https://github.com/karelzak/util-linux-work

* 'PR/fstab-space-notes' of https://github.com/karelzak/util-linux-work:
  fstab.5 mount.8: add note about field separator

6 months agolibsmartcol docs: Format samples, lists, tables
FeRD (Frank Dana) [Thu, 2 Jan 2025 09:43:27 +0000 (04:43 -0500)] 
libsmartcol docs: Format samples, lists, tables

Use gtk-doc constructs to mark up formatted sections of documentation
so that they display properly in the rendered output.

- Enclose code samples with informalexample+programlisting tags
- Enclose preformatted blocks of text (tables) in same
- Present numbered lists in markdown format (leading 1., 2., etc.)
  so that they're translated into HTML ordered lists

Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
7 months agolsfd: support AF_VSOCK sockets
Masatake YAMATO [Mon, 23 Dec 2024 15:38:25 +0000 (00:38 +0900)] 
lsfd: support AF_VSOCK sockets

Example output:

    # ./lsfd -p 121067 -Q "TYPE == 'AF_VSOCK'"
    COMMAND       PID USER ASSOC  XMODE     TYPE SOURCE MNTID    INODE NAME
    test_mkfds 121067 root     4 rw---- AF_VSOCK sockfs    10 39400798 state=listen type=stream laddr=local:12345
    test_mkfds 121067 root     5 rw---- AF_VSOCK sockfs    10 39400799 state=established type=stream laddr=local:23456 raddr=local:12345
    test_mkfds 121067 root     6 rw---- AF_VSOCK sockfs    10 39400800 state=established type=stream laddr=local:12345 raddr=local:23456

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 months agotests: (lsfd-functions.bash) add a missing constant
Masatake YAMATO [Fri, 27 Dec 2024 04:30:18 +0000 (13:30 +0900)] 
tests: (lsfd-functions.bash) add a missing constant

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 months agotests: (lsfd) quote '$' in patterns in a case/esac block
Masatake YAMATO [Sun, 29 Dec 2024 08:44:29 +0000 (17:44 +0900)] 
tests: (lsfd) quote '$' in patterns in a case/esac block

Suggested by github-advanced-security bot.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 months agomeson: add checking build-findfs.
Alexander Shursha [Mon, 16 Dec 2024 11:46:58 +0000 (14:46 +0300)] 
meson: add checking build-findfs.

On FreeBSD run --auto-features=disabled -Dbuild-libblkid=enabled
-Dprogram-tests=false

builded sbin/findfs

Sponsored by: Future Crew, LLC

7 months agomeson: Fix checking options build-bits.
Alexander Shursha [Mon, 9 Dec 2024 09:59:40 +0000 (12:59 +0300)] 
meson: Fix checking options build-bits.

On FreeBSD run --auto-features=disabled -Dbuild-libblkid=enabled
-Dprogram-tests=false

builded bin/bits

Sponsored by: Future Crew, LLC

7 months agomeson: Check options for building lib_pam_misc
Alexander Shursha [Fri, 6 Dec 2024 13:45:20 +0000 (16:45 +0300)] 
meson: Check options for building lib_pam_misc

On FreeBSD run --auto-features=disabled -Dbuild-libblkid=enabled
-Dprogram-tests=false

meson failure:
meson.build:378:20: ERROR: C shared or static library 'pam_misc' not
found

Sponsored by: Future Crew, LLC

7 months agohardlink: fix memory corruption (size calculation)
Karel Zak [Thu, 26 Dec 2024 11:45:31 +0000 (12:45 +0100)] 
hardlink: fix memory corruption (size calculation)

The current code rounds down the values for readsiz and blocksmax,
which is incorrect. The sizes must be large enough to match the files.

Addresses: https://github.com/util-linux/util-linux/issues/3330
Signed-off-by: Karel Zak <kzak@redhat.com>
7 months agoMerge branch 'lsclocks/ptp' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 26 Dec 2024 11:10:42 +0000 (12:10 +0100)] 
Merge branch 'lsclocks/ptp' of https://github.com/t-8ch/util-linux

* 'lsclocks/ptp' of https://github.com/t-8ch/util-linux:
  lsclocks: fix dynamic clock ids

7 months agoMerge branch 'lsfd--hyperlinks' of https://github.com/masatake/util-linux
Karel Zak [Thu, 26 Dec 2024 11:06:08 +0000 (12:06 +0100)] 
Merge branch 'lsfd--hyperlinks' of https://github.com/masatake/util-linux

* 'lsfd--hyperlinks' of https://github.com/masatake/util-linux:
  lsfd: don't enable hyperlinks for deleted files
  lsfd: enable hyperlinks only for regular files and directories
  lsfd: add --hyperlink command line option
  tests: (test_sysinfo) add a helper to call xgethostname
  lsfd: consolidate add_column()

7 months agoMerge branch 'lscpu_monaka_support' of https://github.com/Emi-Kisanuki/util-linux
Karel Zak [Thu, 26 Dec 2024 11:03:02 +0000 (12:03 +0100)] 
Merge branch 'lscpu_monaka_support' of https://github.com/Emi-Kisanuki/util-linux

* 'lscpu_monaka_support' of https://github.com/Emi-Kisanuki/util-linux:
  lscpu: Add FUJITSU aarch64 MONAKA cpupart

7 months agoMerge branch 'alpha-fincore' of https://github.com/glaubitz/util-linux
Karel Zak [Thu, 26 Dec 2024 11:01:03 +0000 (12:01 +0100)] 
Merge branch 'alpha-fincore' of https://github.com/glaubitz/util-linux

* 'alpha-fincore' of https://github.com/glaubitz/util-linux:
  fincore: Use correct syscall number for cachestat on alpha

7 months agoMerge branch 'alpha-fdisk-bsd' of https://github.com/glaubitz/util-linux
Karel Zak [Thu, 26 Dec 2024 10:58:23 +0000 (11:58 +0100)] 
Merge branch 'alpha-fdisk-bsd' of https://github.com/glaubitz/util-linux

* 'alpha-fdisk-bsd' of https://github.com/glaubitz/util-linux:
  tests: fdisk/bsd: Update expected output for alpha

7 months agofstab.5 mount.8: add note about field separator
Karel Zak [Thu, 26 Dec 2024 10:34:10 +0000 (11:34 +0100)] 
fstab.5 mount.8: add note about field separator

The value of the mount option X-mount.idmap= can contain spaces as
separators between mappings. Unfortunately, this conflicts with the
fstab format where fields are separated by spaces. Using quotes does
not solve this issue because fields are separated before they are
parsed.

This limitation of the fstab parser within libmount is due to backward
compatibility. The fstab format is a de-facto standard and is parsed
by many tools and libraries, including third-party shell scripts. It
would not be practical to introduce any improvements in libmount that
would make fstabs unparseable in other places.

Users must understand that in-field spaces must be escaped by \040.
For example, X-mount.idmap="0:0:1\040500:1000:1".

Addresses: https://github.com/util-linux/util-linux/issues/2829
Signed-off-by: Karel Zak <kzak@redhat.com>
7 months agofincore: Use correct syscall number for cachestat on alpha
John Paul Adrian Glaubitz [Wed, 25 Dec 2024 15:21:13 +0000 (16:21 +0100)] 
fincore: Use correct syscall number for cachestat on alpha

Fixes #3331, #3333

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
7 months agotests: fdisk/bsd: Update expected output for alpha
John Paul Adrian Glaubitz [Wed, 25 Dec 2024 13:08:32 +0000 (14:08 +0100)] 
tests: fdisk/bsd: Update expected output for alpha

Fixes #3332

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
7 months agolscpu: Add FUJITSU aarch64 MONAKA cpupart
Emi, Kisanuki [Tue, 24 Dec 2024 06:27:51 +0000 (06:27 +0000)] 
lscpu: Add FUJITSU aarch64 MONAKA cpupart

Add an entry for FUJITSU aarch64 part MONAKA.

Signed-off-by: Emi, Kisanuki <fj0570is@fujitsu.com>
7 months agolsclocks: fix dynamic clock ids
Thomas Weißschuh [Mon, 23 Dec 2024 23:56:12 +0000 (00:56 +0100)] 
lsclocks: fix dynamic clock ids

Without an explicitly specified clock id, lsclocks would always use
clock id 0 (CLOCK_REALTIME) for the dynamic/PTP clocks.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
7 months agofstrim: fix SYNOPSIS/usage (mandatory fstrim -A|-a|mountpoint)
наб [Mon, 23 Dec 2024 04:54:03 +0000 (05:54 +0100)] 
fstrim: fix SYNOPSIS/usage (mandatory fstrim -A|-a|mountpoint)

7 months agoMerge branch 'gitignore-tests-failures' of https://github.com/LiviaMedeiros/util...
Karel Zak [Mon, 16 Dec 2024 10:44:21 +0000 (11:44 +0100)] 
Merge branch 'gitignore-tests-failures' of https://github.com/LiviaMedeiros/util-linux

* 'gitignore-tests-failures' of https://github.com/LiviaMedeiros/util-linux:
  gitignore: ignore `test/failures`

7 months agotests: add skips when IPv6 is not supported
LiviaMedeiros [Mon, 16 Dec 2024 10:40:37 +0000 (11:40 +0100)] 
tests: add skips when IPv6 is not supported

Before this change on systems with disabled IPv6 (e.g. `CONFIG_IPV6 is
not set` in kernel config), `lsfd/mkfds-tcp6` and `lsfd/mkfds-udp6` were
failing, and `lsfd/option-inet` was hanging forever, making it
impossible to complete the tests.

Signed-off-by: LiviaMedeiros <livia@cirno.name>
Reviewed-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 months agolsfd: don't enable hyperlinks for deleted files
Masatake YAMATO [Fri, 13 Dec 2024 16:16:25 +0000 (01:16 +0900)] 
lsfd: don't enable hyperlinks for deleted files

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 months agolsfd: enable hyperlinks only for regular files and directories
Masatake YAMATO [Fri, 6 Dec 2024 17:17:36 +0000 (02:17 +0900)] 
lsfd: enable hyperlinks only for regular files and directories

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 months agolsfd: add --hyperlink command line option
Karel Zak [Mon, 2 Dec 2024 12:22:10 +0000 (13:22 +0100)] 
lsfd: add --hyperlink command line option

Co-Author: Masatake YAMTO <yamato@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 months agotests: (test_sysinfo) add a helper to call xgethostname
Masatake YAMATO [Fri, 13 Dec 2024 17:28:50 +0000 (02:28 +0900)] 
tests: (test_sysinfo) add a helper to call xgethostname

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 months agolsfd: consolidate add_column()
Karel Zak [Mon, 2 Dec 2024 11:50:29 +0000 (12:50 +0100)] 
lsfd: consolidate add_column()

* use only column IDs in add_column() callers
* don't work with "struct colinfo" in callers
* rename add_column_by_id() to add_hidden_column() as it's very
  special function used only by filters

Signed-off-by: Karel Zak <kzak@redhat.com>
7 months agogitignore: ignore `test/failures`
LiviaMedeiros [Fri, 13 Dec 2024 07:36:41 +0000 (15:36 +0800)] 
gitignore: ignore `test/failures`

7 months agoMerge branch 'do-caps-memory-leak' of https://github.com/maks-mishin/util-linux
Karel Zak [Wed, 11 Dec 2024 18:12:33 +0000 (19:12 +0100)] 
Merge branch 'do-caps-memory-leak' of https://github.com/maks-mishin/util-linux

* 'do-caps-memory-leak' of https://github.com/maks-mishin/util-linux:
  sys-utils: (setpriv): fix potential memory leak