Karel Zak [Mon, 2 May 2022 13:45:30 +0000 (15:45 +0200)]
Merge branch 'add/fslastblock' of https://github.com/alberand/util-linux
* 'add/fslastblock' of https://github.com/alberand/util-linux:
blkid: add tests for FSLASTBLOCK tag
blkid: add image for btrfs testing
libblkid: add FSLASTBLOCK implementation for xfs, ext and btrfs
libblkid: add FSLASTBLOCK field interface showing area occupied by fs
Karel Zak [Mon, 2 May 2022 10:57:13 +0000 (12:57 +0200)]
more: avoid infinite loop on --squeeze
The command 'echo | more -s' ends in infinite loop if exit-on-EOF is
disabled (default now). We need to call more_key_command() to ask for
user's reaction.
Fixes: https://github.com/util-linux/util-linux/issues/1669 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 2 May 2022 10:15:32 +0000 (12:15 +0200)]
Merge branch 'meson' of https://github.com/neheb/util-linux
* 'meson' of https://github.com/neheb/util-linux:
meson: make libpam optional
meson: fix tzname check
meson: fix isnan check
meson: add _GNU_SOURCE for sighandler_t
meson: fix environ search
meson: fix cpu_set_t test
meson: don't use run
meson: fix compilation without systemd
The btrfs is one of the popular filesystem which is supported by
blkid. However, the image for 'low-probe' tests was missing. Add
115M BTRFS default image (mkfs.btrfs btrfs.img).
libfdisk: (gpt) Add UUID for Marvell Armada 3700 Boot partition
This GPT UUID is used by BootROM on Marvell Armada 3700 SoC. BootROM
searches for GPT partition with this UUID on attached SATA disk and loads
bootloader from it.
Marvell Armada 3700 SoC is used e.g. on popular EspressoBIN SBC board which
has relatively solid Linux support.
Information about SATA booting and this GPT partition is currently
documented only in development version of ARM Trusted-Firmware-A
documentation:
Warner Losh [Fri, 29 Apr 2022 21:29:44 +0000 (15:29 -0600)]
BSD: Use byteswap.h and endian.h defined macos when present
Newer versions of FreeBSD will have a glibc compatible
byteswap.h. Currently, this file assumes that FreeBSD requires
bswap{16,32,64} to always be defined. This isn't the case when we're
using the byteswap.h file (which is enabled by HAVE_BYTESWAP_H
define). Assume that if byteswap.h and endian.h are present, then the
proper macros are defined. Otherwise, assume that sys/endian.h is
present and paper over the small differences between the BSDs for this
file.
libblkid: add FSLASTBLOCK field interface showing area occupied by fs
Add interface to let filesystem set FSLASTBLOCK which is basically
total number of fsblocks (area occupied by fs). Enable that field in
the 'superblocks' sample.
Enze Li [Wed, 20 Apr 2022 09:37:01 +0000 (17:37 +0800)]
eject: update file provenance of DRIVER_SENSE in the comments
The location where the macro DRIVER_SENSE is defined has been placed in
include/scsi/sg.h in the kernel upstream, but the comment was not
updated in time. This patch updates the contents of this comment.
Karel Zak [Thu, 21 Apr 2022 09:41:00 +0000 (11:41 +0200)]
libmount: cleanup UID and GIR parsing, add tests
* parse_uid_numeric() and parse_gid_numeric() assumes zero terminated
strings, so do not require size. The function ul_strtou64() already
checks that the number is terminated by \0
Which take a user, group, and mode, respectively, and set them on the
target after mounting
This is vaguely similar to tmpfs(5)'s [ug]id= and mode= options,
but we POSIX-parse the user- and group names
Oft requested in systemd/zram-generator, since a common use-case
is to use it to create /tmp or an equivalent directory that needs
to be a=rwx,o+t (or a user's private temp that needs to be owned
by them) ‒ this is impossible without terrible hacks, cf.
https://github.com/systemd/zram-generator/issues/150,
https://github.com/systemd/zram-generator/issues/146, &c.
This started off as a Set{User,Group,Mode}= systemd mount unit,
but was poetterung into libmount options:
https://github.com/systemd/systemd/pull/22889
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 20 Apr 2022 12:42:32 +0000 (14:42 +0200)]
dmesg: fix --since and --until
Now --since and --until requires any time field in the output (e.g.
--ctime,-T), it means "dmesg --since '1 day ago'" doesn't work, but
"dmesg -T --since '1 day ago'" works as expected.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2076829 Signed-off-by: Karel Zak <kzak@redhat.com>
lib/pty: Put master PTY into non-blocking mode and buffer its output to avoid deadlock
If we filled the script->child buffer before the child had a chance to read any
input, we'd sleep forever in write_all(pty->master), and the child would sleep
forever in write(1<pty->slave>)
By putting the master PTY in non-blocking mode, we can poll(pty->master,
POLLOUT) and keep supplying more data as the child reads from the buffer
Enze Li [Fri, 15 Apr 2022 05:55:10 +0000 (13:55 +0800)]
build-sys: add blkpr to gitignore
Since this commit 627428a95692 ("blkpr: add block persistent
reservations command"), we introduced blkpr, but the compiled generated
binary file is not added to the gitignore, so let's do it.
Karel Zak [Tue, 19 Apr 2022 09:38:57 +0000 (11:38 +0200)]
lib/strutils: improve strtoul_or_err() for negative numbers
Let's use the same code for strtoul_or_err() and strtol_or_err() as we
already use for strtoxXX_or_err() functions. It resolves issue with
negative numbers.
This problem has been discovered by "./eject -x -1 -v" where -x is
based on strtoul_or_err(), but accepts negative number (-1).
Reported-by: Enze Li <lienze@kylinos.cn> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 19 Apr 2022 09:14:38 +0000 (11:14 +0200)]
Merge branch 'meson-static' of https://github.com/eli-schwartz/util-linux
* 'meson-static' of https://github.com/eli-schwartz/util-linux:
meson: fix typoed copy-paste error that override other dependencies to blkid
meson: pass the correct absolute path to config.h
meson: fix static builds creating conflicting targets
Karel Zak [Tue, 19 Apr 2022 09:10:30 +0000 (11:10 +0200)]
Merge branch 'lsfd-ipc-fifo' of https://github.com/masatake/util-linux
* 'lsfd-ipc-fifo' of https://github.com/masatake/util-linux:
test: (lsfd) add a case for testing ENDPOINTS column of FIFOs
test: (lsfd) extend test_mkfds to manage optional file descriptors
lsfd: fill ENDPOINTS column for FIFOs
lsfd: add ENDPOINTS column
lsfd: move xstrappend and xstrputc to lsfd.h
lsfd: add basic code for tracking IPC endpoints
lsfd: add static modifier to nodev_table
lsfd: delete __unused__ attribute for an used parameter
Karel Zak [Tue, 19 Apr 2022 07:44:07 +0000 (09:44 +0200)]
libblkid: check fsync() return code
Since 39f5af25982d8b0244000e92a9d0e0e6557d0e17 libblkid uses
O_NONBLOCK. Now it's more obvious that check fsync() (and close())
return value after write() is always a good idea ...
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2074486 Signed-off-by: Karel Zak <kzak@redhat.com>
Eli Schwartz [Thu, 14 Apr 2022 14:55:29 +0000 (10:55 -0400)]
meson: pass the correct absolute path to config.h
When building util-linux as a subproject inside another project (using
dependency fallback to get e.g. libuuid), `-include config.h` will not
work because it is generated private to util-linux. Build the project
argument using the path to the current build dir instead.
Meson has a global option -Ddefault_library which determines whether to
build all generic libraries as static, shared, or both. When creating a
library of the same name twice, once with library() and once with either
shared_library() or static_library(), some values for -Ddefault_library
will result in a fatal configuration error because multiple rules try to
create libXXX.a or libXXX.so
The reason for creating these additional copies of the library is in
order to optionally build some programs as both "prog" and "prog.static"
(and the latter is, of course, static). So depending on the
default_library value may not be desirable.
Enze Li [Wed, 13 Apr 2022 07:53:50 +0000 (15:53 +0800)]
build-sys: add gnu global outputs to gitignore
Some people like to use gnu global to browse code, so we add the global
output files to gitignore, which is safe because no function-related
code is changed.
Eli Schwartz [Wed, 13 Apr 2022 01:50:57 +0000 (21:50 -0400)]
meson: validate the return code of subprocess commands
run_command() has an unfortunate early design quirk in that it doesn't
error when the command itself errors. Recent versions of Meson warn if
you do not explicitly specify whether the return code matters by passing
`check:` to it; this prevents building util-linux (including as a
subproject) with --fatal-meson-warnings.
Eli Schwartz [Wed, 13 Apr 2022 01:25:01 +0000 (21:25 -0400)]
meson: declare the minimum required version of meson itself
Features from Meson 0.53.0 are used, so declare this as required to
prevent people from trying to use older versions and getting strange
errors. Instead, Meson will tell them they need that version.
Karel Zak [Mon, 11 Apr 2022 09:25:30 +0000 (11:25 +0200)]
Merge branch 'lsfd-filter-empty-string' of https://github.com/masatake/util-linux
* 'lsfd-filter-empty-string' of https://github.com/masatake/util-linux:
lsfd: (filter): parse "" in filter expression correctly
lsfd: (filter): fix a codeing style of if/else
lsfd: use /proc/$PID/map_files as the fallback information source
The original code scanning /proc/$PID/maps assumed two things; an entry
of the file contains a path started from '/' if a file is mapped, and
stat(2) works well with the path in the entry.
A mmap'ed socket breaks the former assumption.
tcpdump/lipcap does mmap an AF_PACKET socket to its address space!
A file is deleted after mapping breaks the latter assumption.
With this change, lsfd utilizes dentries under /proc/$PID/map_files
for gathering information of the mapped file in the case that the
assumptions are broken.
Private anonymous mappings are skipped to avoid wasting CPU time.
Example output:
# ./lsfd -p 1541379 -Q '(ASSOC == "shm")'
COMMAND PID USER ASSOC MODE TYPE SOURCE MNTID INODE NAME
tcpdump 1541379 tcpdump shm rw- SOCK sockfs 0 114535087 PACKET:[114535087]
# ./lsfd -Q '(ASSOC == "shm") and DELETED' | head -2
COMMAND PID USER ASSOC MODE TYPE SOURCE MNTID INODE NAME
systemd-resolve 870 systemd-resolve shm r-- REG dm-0 0 1180413 /var/lib/sss/mc/passwd (deleted)
NOTE: CAP_SYS_ADMIN capability is required to access map_files.
See proc(5) for more details.
zhenwei pi [Thu, 16 Sep 2021 03:29:01 +0000 (11:29 +0800)]
blkpr: add block persistent reservations command
Linux kernel block layer supports PR (persistent reservations) ioctl
on a block device. Typically SCSI and NVMe disk support PR feature,
and blkpr could operation on them.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
lsns unconditionally uses NS_GET_NSTYPE since version 2.38 and
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/?id=de72df79d72fa906e71e2ac922d8745ff22deee5
which is only available since kernel 4.11 and
https://github.com/torvalds/linux/commit/e5ff5ce6e20ee22511398bb31fb912466cf82a36
resulting in the following build failure:
sys-utils/lsns.c: In function 'add_namespace_for_nsfd':
sys-utils/lsns.c:719:25: error: 'NS_GET_NSTYPE' undeclared (first use in this function)
719 | clone_type = ioctl(fd, NS_GET_NSTYPE);
| ^~~~~~~~~~~~~
So add an option to allow the user to disable lsns
test: (lsfd) extend test_mkfds to manage optional file descriptors
This change may need to test ENDPOINTS column of lsfd.
The core part of test_mkfds command could close pre-specified file
descriptors opened by a factory. However, it could not handle file
descriptors optionally opened.
With this change, the core part can close such optionally opened file
descriptors.
Karel Zak [Mon, 4 Apr 2022 13:59:36 +0000 (15:59 +0200)]
tests: make libmount tests more portable
git tree on macbook:
...
warning: the following paths have collided (e.g. case-sensitive paths
on a case-insensitive filesystem) and only one from the same
colliding group is in the working tree:
It seems better to use original solution and depend on HAVE_DIRFD
and HAVE_OPENAT, because libblkid and another tools are compiled
on non-Linux targets too.
The test cases assumed the file descriptor #3 was not occupied. As
reported in #1637, the assumption was wrong. This new code assigns
the file descriptor #3 explicitly with dup2 as the other test cases
did.