Compare commits

...
Sign in to create a new pull request.

326 commits

Author SHA1 Message Date
Karel Zak
689c03b416 Merge branch 'enosys/locale' of https://github.com/t-8ch/util-linux
Some checks failed
CIFuzz / Fuzzing (i386, address) (push) Has been cancelled
CIFuzz / Fuzzing (x86_64, address) (push) Has been cancelled
CIFuzz / Fuzzing (x86_64, memory) (push) Has been cancelled
CIFuzz / Fuzzing (x86_64, undefined) (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
2023-07-03 12:52:38 +02:00
Karel Zak
6462dbe2ef Merge branch 'clock' of https://github.com/t-8ch/util-linux
* 'clock' of https://github.com/t-8ch/util-linux:
  lsclocks: new util to interact with system clocks
  lib/timeutils: implement timespec formatting
  lib/timeutils: implement nanosecond formatting
  lib/timeutils: constify some arguments
  utmpdump: validate subsecond granularity
2023-07-03 12:47:08 +02:00
Karel Zak
96de80b659 Merge branch 'lsfd--xmode' of https://github.com/masatake/util-linux
* 'lsfd--xmode' of https://github.com/masatake/util-linux:
  lsfd: add 'D' flag for representing deleted files to XMODE column
  lsfd: introduce XMODE column, extensible variant of MODE
  test: (lsfd) add a subcase for testing NAME column for a deleted file
  test: (lsfd) add a case for testing DELETED column
  test: (mkfds) add "make-regular-file" factory
2023-07-03 12:41:04 +02:00
Karel Zak
3e2e4c32e8 Merge branch 'lsfd--misc-tun' of https://github.com/masatake/util-linux
* 'lsfd--misc-tun' of https://github.com/masatake/util-linux:
  tests: (lsfd) add a case testing TUN.IFACE column
  tests: (mkfds) add a factor for opening tun device
  lsfd: add TUN.IFFACE, a column for interfaces behind tun devices
  lsfd: (refactor) move miscdev specific code to cdev_misc_ops
  lsfd: (refactor) make the way to handle character devices extensible
  lsfd: (refactor) introduce a content data type for char devices
2023-07-03 12:38:48 +02:00
Karel Zak
c8e36ed4db Merge branch 'patch-1' of https://github.com/diizzyy/util-linux
* 'patch-1' of https://github.com/diizzyy/util-linux:
  include/bitops.h: Remove bswap* compatibility hack for FreeBSD
2023-07-03 12:36:07 +02:00
Karel Zak
452801e4f6 Merge branch 'wip/rishi/libmount-src-hook-mount-move_setattr-typo' of https://github.com/debarshiray/util-linux
* 'wip/rishi/libmount-src-hook-mount-move_setattr-typo' of https://github.com/debarshiray/util-linux:
  libmount: fix typo
2023-07-03 12:32:42 +02:00
Karel Zak
5098291b2c Merge branch 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https://github.com/debarshiray/util-linux
* 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https://github.com/debarshiray/util-linux:
  libmount: update documentation for MNT_ERR_APPLYFLAGS
2023-07-03 12:30:43 +02:00
Karel Zak
85c9a0af07 Merge branch 'unshare/negative-time-offset' of https://github.com/t-8ch/util-linux
* 'unshare/negative-time-offset' of https://github.com/t-8ch/util-linux:
  unshare: allow negative time offsets
2023-07-03 12:28:54 +02:00
Thomas Weißschuh
95e853892f unshare: allow negative time offsets
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-30 22:36:06 +02:00
Thomas Weißschuh
e9ddea7912 lsclocks: new util to interact with system clocks
Usecases:
* Compare current monotonic time to timestamps reported by systemd
* Validate time namespace operations
* Inspect clock resolutions

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-30 14:12:48 +02:00
Jakub Wilk
a753fb6520 prlimit: reject trailing junk in limits without ":"
Before:

    $ prlimit --verbose --core=1x
    New CORE limit for pid 42: <1:1>

After:

    $ prlimit --verbose --core=1x
    prlimit: failed to parse CORE limit

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2023-06-29 20:13:01 +02:00
Debarshi Ray
5a17b1b626 libmount: update documentation for MNT_ERR_APPLYFLAGS
The implementation using the new FD based mount kernel API (ie.,
fsconfig/fsopen) uses MNT_ERR_APPLYFLAGS for failed mount_setattr(2)
calls, which involves more mount attributes (eg., MOUNT_ATTR_RDONLY,
MOUNT_ATTR_NOSUID, etc.) in addition to the MS_PROPAGATION flags (eg.,
MS_SHARED, MS_UNBINDABLE, etc.).

Note that mount_setattr(2) is part of the new FD based mount kernel API,
and is not used by the classic mount(2) based version.

Fallout from 987d844cdb

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2023-06-29 13:29:01 +02:00
Debarshi Ray
46fe78989d libmount: fix typo
Similar to e80f8e4612 and fallout from
6753e6f691

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2023-06-29 12:26:29 +02:00
Thomas Weißschuh
b9abaae312 lib/timeutils: implement timespec formatting
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-28 14:58:32 +02:00
Thomas Weißschuh
136f4874f4 lib/timeutils: implement nanosecond formatting
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-28 14:58:06 +02:00
Thomas Weißschuh
971244fdc7 lib/timeutils: constify some arguments
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-28 14:57:33 +02:00
Thomas Weißschuh
a8d0195462 utmpdump: validate subsecond granularity
tv_usec is only valid in the range [0, 999999].
If the file contains garbage data replace interpret it as "0" instead.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-28 14:50:49 +02:00
Karel Zak
2b48beb44e include/crc64: add missing license header
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-28 12:41:08 +02:00
Karel Zak
32c7870520 nsenter: avoid NULL pointer dereference [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-28 10:19:34 +02:00
Thomas Weißschuh
d191a7bef8 enosys: enable locale handling
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-27 12:45:37 +02:00
Karel Zak
65c4be5fc2 Merge branch 'cal' of https://github.com/jwilk-forks/util-linux
* 'cal' of https://github.com/jwilk-forks/util-linux:
  cal: fix long option name for -c
  cal: fix error message for bad -c argument
2023-06-27 10:29:59 +02:00
Masatake YAMATO
0cac072b64 tests: (lsfd) add a case testing TUN.IFACE column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 08:28:06 +09:00
Jakub Wilk
618dd71be4 cal: fix long option name for -c 2023-06-26 21:02:13 +02:00
Jakub Wilk
0fb52dabba cal: fix error message for bad -c argument 2023-06-26 21:00:26 +02:00
Jakub Wilk
b1fc5d61f0 lib/strutils: fix typo 2023-06-26 20:00:43 +02:00
Daniel Engberg
214e668c84
include/bitops.h: Remove bswap* compatibility hack for FreeBSD
This is no longer needed on supported versions of FreeBSD and causes build failures
2023-06-26 19:22:16 +02:00
Masatake YAMATO
369007a5b7 tests: (mkfds) add a factor for opening tun device
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Masatake YAMATO
7cbec02a47 lsfd: add TUN.IFFACE, a column for interfaces behind tun devices
An example output:

  # ./lsfd -Q '(SOURCE == "misc:tun")'  -o+TUN.IFACE
  COMMAND             PID       USER ASSOC MODE TYPE   SOURCE MNTID INODE NAME          TUN.IFACE
  qemu-system-x86 2846033       qemu    48  rw-  CHR misc:tun    23   306 iface=vnet89     vnet89
  qemu-system-x86 2865022       qemu    56  rw-  CHR misc:tun    23   306 iface=vnet103   vnet103
  openvpn         3113730 nm-openvpn     7  rw-  CHR misc:tun   588   306 iface=tun0         tun0
  qemu-system-x86 3608136       qemu    36  rw-  CHR misc:tun    23   306 iface=vnet104   vnet104
  qemu-system-x86 3608136       qemu    39  rw-  CHR misc:tun    23   306 iface=vnet105   vnet105
  qemu-system-x86 3608238       qemu    40  rw-  CHR misc:tun    23   306 iface=vnet106   vnet106
  qemu-system-x86 3608238       qemu    43  rw-  CHR misc:tun    23   306 iface=vnet107   vnet107
  qemu-system-x86 3608338       qemu    54  rw-  CHR misc:tun    23   306 iface=vnet108   vnet108
  qemu-system-x86 3608338       qemu    60  rw-  CHR misc:tun    23   306 iface=vnet109   vnet109

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Masatake YAMATO
fb978312aa lsfd: (refactor) move miscdev specific code to cdev_misc_ops
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Masatake YAMATO
8aa5b7c9d0 lsfd: (refactor) make the way to handle character devices extensible
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Masatake YAMATO
1225e6d0fb lsfd: (refactor) introduce a content data type for char devices
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Karel Zak
fb062800be Merge branch 'nsenter-add-parent-ns-option' of https://github.com/igo95862/util-linux
* 'nsenter-add-parent-ns-option' of https://github.com/igo95862/util-linux:
  Add `--user-parent` option to nsenter
2023-06-26 14:04:52 +02:00
Karel Zak
b0d4d09379 cfdisk: fix menu behavior after writing changes
Florian wrote:
  after a successful write, cfdisk remains on the "Write" cursor and
  furthermore when navigating to "Quit" will continue to  show
  "...without writing changes", despite there were writes. This patch
  addresses that.

Based on patch from Florian Zimmermann <florian.zimmermann@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-26 13:27:11 +02:00
Edward Chron
fa6ac102dc dmesg: -r LOG_MAKEPRI needs fac << 3
Submission to Project: util-linux
Open Incident: #2325 at github.com/util-linux/util-linux/issues/2325
Component: util-linux/sys-utils
File: dmesg.c
Code level patch applied against: 2.39 - latest code pulled from
           git.github.com:util-linux/util-linux.git

BUG: The facility field passed to macro from /usr/include/sys/syslog.h
     LOG_MAKEPRI(fac, pri) by dmesg -r needs to have fac argument
     shifted 3 bit to the left to return a valid raw valid. The lower
     3 bits for a raw value are used by the loglevel priority (pri)
     field, so the facility bits can only occupy the bits above the
     bits used to hold the pri field value.

The dmesg -r command produces the incorrect output for the raw value
for the or'ed combination of the facility | loglevel priority that gets
produced by the LOG_MAKEPRI macro. That macro is defined as:

    #define LOG_MAKEPRI(fac, pri) ((fac) | (pri))

which is defined in the current glibc code in /usr/include/sys/syslog.h
and is used only in the dmesg -r (raw output option) command to form the
raw value for facility or'ed with loglevel priority and displayed as:

    <#>[#######.######] ...

where the # in <#> contains the output from the LOG_MAKEPRI macro.

The lower 3 bits are reserved for the loglevel priority 0-7
and the bits above that are for the facility value, so the facility
index should be shifted to the left three bits and or'ed with the
loglevel priority.

In the glibc file: /usr/include/sys/syslog.h the macro LOG_MAKEPRI is
defined as:

        #define LOG_MAKEPRI(fac, pri) ((fac) | (pri)

and returns the wrong facility and loglevel priority values, ideally it
should be defined as:

        #define LOG_MAKEPRI(fac, pri) ((fac << 3) | (pri))

to return the correct raw value.

We checked with glibc developement and the LOG_MAKEPRI macro is correct
as is and can't be changed as it used by *BSD as is so the solution for
dmesg -r is to shift the facility index left by 3 bits as input to the
LOG_MAKEPRI macro. That is what glibc development recommended.
(For reference, see glibc bugzilla Bug 30563)

We can front end the LOG_MAKEPRI macro with a macro that shifts the
facility by the needed 3 bits which we've added to dmesg.c:

    #define LOG_RAW_FAC_PRI(fac, pri) LOG_MAKEPRI((fac << 3), (pri))

This has been tested and works correctly to produce the correct raw
mode value for Facility or'ed together with Loglevel priority.

You can verify that this fix works correctly.

We can test by adding several records to /dev/kmsg like this:

    echo "<14> Test Message Facility 8 Loglevel 6" >> /dev/kmsg
    echo "<15> Test Message Facility 8 Loglevel 7" >> /dev/kmsg
    echo "<30> Test Message Facility 24 Loglevel 6" >> /dev/kmsg
    echo "<31> Test Message Facility 24 Loglevel 7" >> /dev/kmsg

these commands add 4 records to the dmesg buffer. Then when we print the
records by cat'ing /dev/kmsg or using the dmesg command several ways:

    -bash-4.2# cat /dev/kmsg | grep "Test Message Facility"
    14,1114,495317239,-; Test Message Facility 8 Loglevel 6
    15,1115,503340779,-; Test Message Facility 8 Loglevel 7
    30,1116,643374764,-; Test Message Facility 24 Loglevel 6
    31,1117,657165117,-; Test Message Facility 24 Loglevel 7

    -bash-4.2# dmesg -x | grep "Test Message Facility"
    user  :info  : [  495.317239]  Test Message Facility 8 Loglevel 6
    user  :debug : [  503.340779]  Test Message Facility 8 Loglevel 7
    daemon:info  : [  643.374764]  Test Message Facility 24 Loglevel 6
    daemon:debug : [  657.165117]  Test Message Facility 24 Loglevel 7

    -bash-4.2# dmesg -S -x | grep "Test Message Facility"
    user  :info  : [  495.317239]  Test Message Facility 8 Loglevel 6
    user  :debug : [  503.340779]  Test Message Facility 8 Loglevel 7
    daemon:info  : [  643.374764]  Test Message Facility 24 Loglevel 6
    daemon:debug : [  657.165117]  Test Message Facility 24 Loglevel 7

   -bash-4.2# dmesg -S -r | grep "Test Message Facility"
   <14>[  495.317239]  Test Message Facility 8 Loglevel 6
   <15>[  503.340779]  Test Message Facility 8 Loglevel 7
   <30>[  643.374764]  Test Message Facility 24 Loglevel 6
   <31>[  657.165117]  Test Message Facility 24 Loglevel 7

All the above methods agree in their output as expected.
However, running dmesg -r does not agree.

dmesg -r erronously produces:
----------------------------

    -bash-4.2# dmesg -r | grep "Test Message Facility"
    <7>[  495.317239]  Test Message Facility 8 Loglevel 6
    <7>[  503.340779]  Test Message Facility 8 Loglevel 7
    <7>[  643.374764]  Test Message Facility 24 Loglevel 6
    <7>[  657.165117]  Test Message Facility 24 Loglevel 7

However, if we run the dmesg -r command using the new front end macro
LOG_RAW_FAC_PRI(fac, pri) we do get the correct output:

Here is the corrected dmesg -r output:
-------------------------------------

    -bash-4.2# dmesg -r | grep "Test Message Facility"
    <14>[  495.317239]  Test Message Facility 8 Loglevel 6
    <15>[  503.340779]  Test Message Facility 8 Loglevel 7
    <30>[  643.374764]  Test Message Facility 24 Loglevel 6
    <31>[  657.165117]  Test Message Facility 24 Loglevel 7

shifting the facility index value by 3 bits in the LOG_RAW_FAC_PRI macro
provides the correct ouput as shown. All the other commands produce the
same output so now they are all in agreement.

Signed-off-by: Ivan Delalande <colona@arista.com>
Signed-off-by: Edward Chron <echron@arista.com>
2023-06-26 13:27:02 +02:00
Karel Zak
08b35072b9 build-sys: don't call pkg-config --static if unnecessary
Addresses: https://github.com/util-linux/util-linux/issues/2327
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-26 12:48:30 +02:00
Karel Zak
3a4d70419c logger: initialize socket credentials contol union
Addresses: https://github.com/util-linux/util-linux/issues/2336
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-26 11:56:23 +02:00
Karel Zak
0904cff4a5 Merge branch 'unshare/time-msg' of https://github.com/t-8ch/util-linux
* 'unshare/time-msg' of https://github.com/t-8ch/util-linux:
  unshare: fix error message for unexpected time offsets
2023-06-26 11:50:02 +02:00
Karel Zak
ceb13fa9e8 Merge branch 'test/builddir-pwd' of https://github.com/t-8ch/util-linux
* 'test/builddir-pwd' of https://github.com/t-8ch/util-linux:
  tests: (run.sh) detect builddir from working directory
2023-06-26 11:49:43 +02:00
Karel Zak
55b0cc7106 Merge branch 'losetup-errormsg' of https://github.com/t-8ch/util-linux
* 'losetup-errormsg' of https://github.com/t-8ch/util-linux:
  losetup: deduplicate find_unused() logic
  lib/loopdev: consistently return error values from loopcxt_find_unused()
  lib/loopdev: document function return values
2023-06-26 11:49:20 +02:00
Karel Zak
69e7e599c0 Merge branch 'hardlink' of https://github.com/jwilk-forks/util-linux
* 'hardlink' of https://github.com/jwilk-forks/util-linux:
  hardlink: (man) add missing comma
2023-06-26 11:48:43 +02:00
Karel Zak
c0ac6d590a Merge branch 'lsfd--fix-separators-for-json-output-cleanup' of https://github.com/masatake/util-linux
* 'lsfd--fix-separators-for-json-output-cleanup' of https://github.com/masatake/util-linux:
  lsfd: fix specifying wrong JSON typs when building the help message
  tests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode
2023-06-26 11:48:24 +02:00
Karel Zak
c985e0742e Merge branch 'PR/libmount-optstr-sync' of github.com:karelzak/util-linux-work
* 'PR/libmount-optstr-sync' of github.com:karelzak/util-linux-work:
  libmount: add sample to test fs and context relation
  libmount: fix sync options between context and fs structs
2023-06-26 11:45:50 +02:00
Thomas Weißschuh
2da0200327 unshare: fix error message for unexpected time offsets
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 13:28:19 +02:00
Thomas Weißschuh
af9fc22d03 losetup: deduplicate find_unused() logic
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 10:06:21 +02:00
Thomas Weißschuh
3c5402640d lib/loopdev: consistently return error values from loopcxt_find_unused()
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 10:06:21 +02:00
Thomas Weißschuh
af5efcd810 lib/loopdev: document function return values
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 10:04:39 +02:00
Thomas Weißschuh
dc1d0f8dd1 tests: (run.sh) detect builddir from working directory
This makes it easier to run test.sh from the build directory as
everything will work without any parameters irrespective of the build
directories name.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 09:06:47 +02:00
Jakub Wilk
4bcc2ed30d hardlink: (man) add missing comma 2023-06-24 09:24:29 +02:00
igo95862
01a6d803b5
Add --user-parent option to nsenter
When this option is used nsenter will fetch the parent user
namespace from any namespace file descriptors available.

It can be combined with existing `--user` option in which case
the parent user namespace will be fetched from the user namespace
and replace it.

The usecase of this option is when a user namespace that owns
the other type namespaces we want to switch to is not actually
bound to any process. Without using ioctl it is impossible to
acquire namespace file descriptor. For example, bubblewrap
`bwrap` command creates unbinded user namespace when `--dev`
option is used.
2023-06-23 00:26:13 +06:00
Masatake YAMATO
253c991da1 lsfd: fix specifying wrong JSON typs when building the help message
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-23 01:10:04 +09:00
Masatake YAMATO
ee72ea94c5 tests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-23 01:07:04 +09:00
Karel Zak
ae62db7250 Merge branch 'lsfd--fix-separators-for-json-output' of https://github.com/masatake/util-linux
* 'lsfd--fix-separators-for-json-output' of https://github.com/masatake/util-linux:
  lsfd.1.adoc: fix a typo
  lsfd: use ARRAY_STRING and ARRAY_NUMBER json types in some columns
  lsfd: use \n as the separator in INOTIFY.INODES and INOTIFY.INODES.RAW columns
  lsfd: use \n as the separator in EVENTPOLL.TFDS column
  lsfd: (filter) weakly support ARRAY_STRING and ARRAY_NUMBER json types
2023-06-22 14:26:09 +02:00
Karel Zak
6a28c2f90a Merge branch 'coverage-tweaks' of https://github.com/mrc0mmand/util-linux
* 'coverage-tweaks' of https://github.com/mrc0mmand/util-linux:
  ci: collect coverage on _exit() as well
  ci: hide coverage-related stuff begind --enable-coverage
  ci: tweak build dir's ACL when collecting coverage
  ci: fix indentation
2023-06-22 14:19:07 +02:00
Karel Zak
7111160934 Merge branch 'cancel-jobs-on-push' of https://github.com/mrc0mmand/util-linux
* 'cancel-jobs-on-push' of https://github.com/mrc0mmand/util-linux:
  ci: cancel running jobs on push
2023-06-22 14:15:46 +02:00
Karel Zak
cd8f11b7cb libmount: add sample to test fs and context relation
Reerences: https://github.com/util-linux/util-linux/issues/2326
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-22 14:00:46 +02:00
Karel Zak
7b37d5b566 libmount: fix sync options between context and fs structs
Since v2.39 libmount prefers "struct libmnt_optlist" to keep mount options
rather than the original "struct libmnt_fs". This is problem if the
"fs" struct is defined and maintained outside the context.

The library has already a way how to sync "fs" and "optlist", but this
needs to be improved and used more widely. Changes:

* force "fs" from context to always read options from "optlist"

* copy options from "fs" to "optlist" in mnt_context_set_fs()

* internally redirect mnt_fs_* API for options to "optlist" if optlist
  defined

* add simple test to make sure options from different sources are
  always merged together

Addresses: https://github.com/util-linux/util-linux/issues/2326
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-22 13:11:57 +02:00
Frantisek Sumsal
2235cf919a ci: cancel running jobs on push
Let's cancel already running GH Actions jobs when a PR is (force) pushed
to conserve resources and make the CI runs faster thanks to the freed up
queue.
2023-06-22 12:38:53 +02:00
Frantisek Sumsal
b0d003023c ci: collect coverage on _exit() as well
_exit() skips the gcov hooks, so we lose all coverage collected up to
that point. Let's work around this by intercepting _exit() with our
wrapper that calls __gcov_dump() just before _exit().
2023-06-22 12:03:04 +02:00
Frantisek Sumsal
b4b8f8c293 ci: hide coverage-related stuff begind --enable-coverage 2023-06-22 12:03:04 +02:00
Frantisek Sumsal
f5b49efe42 ci: tweak build dir's ACL when collecting coverage
So gcov can create necessary directories/.gcda files even with dropped
privileges.
2023-06-22 12:03:04 +02:00
Rasmus Villemoes
ab7fe95ad7 hwclock: add --vl-read, --vl-clear documentation and bash-completion
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2023-06-22 10:27:36 +02:00
Rasmus Villemoes
76cf1753f4 hwclock: add support for RTC_VL_READ/RTC_VL_CLR ioctls
Implement a way for userspace to query the status of the backup
battery, if supported by the hardware and driver.

The RTC_VL_* bits are a somewhat recent addition (3431ca4837bf, but
really only from b0efe0281234) to the uapi header,
so provide our own definition if the build host's header doesn't.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2023-06-22 10:27:36 +02:00
Masatake YAMATO
14fee76fc1 lsfd.1.adoc: fix a typo
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 15:07:49 +09:00
Masatake YAMATO
42497e7d92 lsfd: use ARRAY_STRING and ARRAY_NUMBER json types in some columns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 14:53:41 +09:00
Masatake YAMATO
c34f86326d lsfd: use \n as the separator in INOTIFY.INODES and INOTIFY.INODES.RAW columns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 14:29:08 +09:00
Masatake YAMATO
92e0e017d8 lsfd: use \n as the separator in EVENTPOLL.TFDS column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 14:29:08 +09:00
Masatake YAMATO
de7e11495b lsfd: (filter) weakly support ARRAY_STRING and ARRAY_NUMBER json types
We will have operators for array types in the future.  Till having
them, we treat the types as STRING. So we can use string operators for
the column having types.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 14:29:08 +09:00
Masatake YAMATO
30ac13fa20 lsfd: add 'D' flag for representing deleted files to XMODE column
Now NAME column doesn't print "(deleted)" markers at the end of
file name.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 09:01:13 +09:00
Masatake YAMATO
92c00d7215 lsfd: introduce XMODE column, extensible variant of MODE
The original MODE column comes from three letters (rwx) may not be
enough for representing various aspects of file descriptors and memory
mappings. We want to add more items in the future.

However, the description of MODE in lsfd(1) doesn't wrote about its
extensibility. Adding more letters to the column can break
compatibility in someone's use case.

This change introduces XMODE column. Unlike MODE, XMODE is declared as
an extensible column in lsfd(1). Currently, it shows the same items as
the MODE column does.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 09:01:13 +09:00
Masatake YAMATO
cb233a3e03 test: (lsfd) add a subcase for testing NAME column for a deleted file
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 09:01:13 +09:00
Masatake YAMATO
9ac2c69dbd test: (lsfd) add a case for testing DELETED column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 09:01:13 +09:00
Masatake YAMATO
251319838d test: (mkfds) add "make-regular-file" factory
With "delete" boolean parameter, you can delete the file just
after making it.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-22 09:01:13 +09:00
Karel Zak
60c81b3272 sfdisk: add hint about duplicate UUIDs when use dump
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-21 10:57:37 +02:00
Frantisek Sumsal
4d34493450 ci: fix indentation 2023-06-20 16:19:42 +02:00
Karel Zak
33e347832e lib: remove pager.c from libcommon
The libcommon is a binary archive to keep compilation and maintenance
simple. The library is not linked as shared or so. The unused symbols
are removed from binaries (for example, by "make install-strip").

But it isn't evident for license analyzers (and some humans) that the
library uses GPL and non-GPL stuff simultaneously. Let's avoid doubts
and keep pager.c (with GPL license) out of the archive

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-20 13:15:45 +02:00
Karel Zak
79feaa6022 lib/ include/: cleanup licence headers
This patch does not change any license of the affected files. Changes:

* add missing SPDX-License-Identifier lines for LGPL

* copy missing license lines from code (lib/) to header files (include/)

* use the same comment formatting

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-20 12:52:35 +02:00
Karel Zak
278f76ae88 lib/color-names: fix licence header
The header file and code uses a different license. Let's use (public
domain) license from code also for the header file.

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-20 12:51:05 +02:00
Todd Zullinger
7293d66314 sys-utils: fix SELinux context example in mount.8
In the description of the context option, the example which shows how to
properly quote is displayed incorrectly on terminals > 80 columns.  This
leaves a seemingly needless '\' in the command, e.g.:

    mount -t tmpfs none /mnt -o \ 'context="system_u:...'

The intent is to display the command properly on terminals <= 80
columns.  Use a literal block to ensure the code is displayed
consistently, regardless of the terminal width.

Connect the blockquote to the previous indented items in the context
option description to ensure it is properly indented.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
2023-06-20 11:27:07 +02:00
Karel Zak
d7f1fc1839 tests: add omitted files
Sorry, forgot in the previous commit ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-19 14:59:15 +02:00
Karel Zak
b11005d90f tests: add user and user=name mount test
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-19 13:45:06 +02:00
Karel Zak
a96b486d17 libmount: always ignore user=<name>
The library (on mount) cares about "user", but has to ignore
"user=name". It works as expected, but only for non-root users. We
need to ignore it also root to be compatible with /sbin/mount.cifs
where some people still use "user=" (rather than "username=").

References: fe0b1e793c
Addresses: https://github.com/util-linux/util-linux/issues/2315
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-19 13:29:42 +02:00
Karel Zak
640e93f480
Merge pull request #2317 from eworm-de/meson-langinfo
meson: check for _NL_TIME_WEEK_1STDAY in langinfo.h
2023-06-17 11:56:48 +02:00
Karel Zak
cd256c9f22
Merge pull request #2318 from mariobl/patch-11
[man] Fix typo in irqtop.1.adoc
2023-06-17 11:52:11 +02:00
Mario Blättermann
123ba32ae7
[man] Fix typo in irqtop.1.adoc 2023-06-16 16:31:47 +02:00
Christian Hesse
17bc58e018 meson: check for _NL_TIME_WEEK_1STDAY in langinfo.h
... which is required for `cal`.

Fixes GH-2316
2023-06-16 11:53:20 +02:00
Karel Zak
44806f659f Merge branch 'ci/gcc-13' of https://github.com/t-8ch/util-linux
* 'ci/gcc-13' of https://github.com/t-8ch/util-linux:
  ci: use clang 16
  ci: build with GCC 13/11
2023-06-14 09:54:25 +02:00
Karel Zak
b9040ac267 Merge branch 'lsfd--inotify' of https://github.com/masatake/util-linux
* 'lsfd--inotify' of https://github.com/masatake/util-linux:
  lsfd: use xstrdup instead of xasprintf(...\"%s\"
  tests: (lsfd) add a case for testing INOTIFY.INODES.RAW column
  tests: (mkfds) add / and /etc/fstab as the monitoring targets to inotify
  lsfd: fill NAME column of inotify files with the information about their monitoring targets
  lsdf: make the code for filling SOURCE, PARTITION, and MAJMIN reusable
2023-06-14 09:53:04 +02:00
Karel Zak
07e7d1c781 Merge branch 'meson-more-conditions' of https://github.com/keszybz/util-linux
* 'meson-more-conditions' of https://github.com/keszybz/util-linux:
  meson: conditionalize waitpid
  meson: add conditionalization for test progs
  meson: implement HAVE_PTY
2023-06-14 09:51:12 +02:00
Zbigniew Jędrzejewski-Szmek
334939a19d meson: conditionalize waitpid
I *think* this mirros what configure.ac does, except that the configuration
option is not implemented.
2023-06-13 21:12:00 +02:00
Zbigniew Jędrzejewski-Szmek
d6418774ab meson: add conditionalization for test progs
This just mirrors what the autotools setup is doing.
2023-06-13 21:12:00 +02:00
Zbigniew Jędrzejewski-Szmek
444753601c meson: implement HAVE_PTY
This conditional was never implemented in the meson config. Under
autotools, it is guarded by availability of headers and an option. I
didn't implement the option here.

Fixes #2310.

'!= false' is used because 'x == 1' is rejected by meson if 'x' is
false. OTOH, 'x != false' seems to work if 'x' is 1.
2023-06-13 21:10:57 +02:00
Masatake YAMATO
157a469671 lsfd: use xstrdup instead of xasprintf(...\"%s\"
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-13 19:21:33 +09:00
Masatake YAMATO
6b58fb5f45 tests: (lsfd) add a case for testing INOTIFY.INODES.RAW column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-13 19:18:54 +09:00
Masatake YAMATO
5e0e9730ca tests: (mkfds) add / and /etc/fstab as the monitoring targets to inotify
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-13 19:18:54 +09:00
Masatake YAMATO
c1a26ac8f1 lsfd: fill NAME column of inotify files with the information about their monitoring targets
# ./lsfd  -p 1  -Q '(TYPE == "inotify") and (FD > 7)'
    COMMAND PID USER ASSOC MODE    TYPE       SOURCE MNTID INODE NAME
    systemd   1 root    11  r-- inotify anon_inodefs    15  1060 inodes=116@dm-0
    systemd   1 root    13  r-- inotify anon_inodefs    15  1060 inodes=299@tmpfs
    systemd   1 root    19  r-- inotify anon_inodefs    15  1060 inodes=41@tmpfs,2@tmpfs,1@tmpfs,96@dm-0
    systemd   1 root    21  r-- inotify anon_inodefs    15  1060 inodes=41@tmpfs,2@tmpfs,1@tmpfs,96@dm-0

In addition, INOTIFY.INODES and INOTIFY.INODES.RAW column are added.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-13 19:18:35 +09:00
Masatake YAMATO
c032850e8f lsdf: make the code for filling SOURCE, PARTITION, and MAJMIN reusable
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-13 19:18:26 +09:00
Thomas Weißschuh
88ad4e7462 libmount: (tests) add helper for option list splitting
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-13 08:27:48 +02:00
Thomas Weißschuh
565eebbc45 meson: build test_mount_optlist
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-13 08:20:15 +02:00
Enze Li
b5fc1d120e build-sys: add enosys and syscalls.h to gitignore
After compiling enosys, the syscalls.h file and the executable enosys are
generated, let's add these two files to the .gitignore file.

Signed-off-by: Enze Li <lienze@kylinos.cn>
2023-06-12 12:47:44 +02:00
Enze Li
c9fbfd99ad build-sys: rearrange gitignore in alphabetical order
Signed-off-by: Enze Li <lienze@kylinos.cn>
2023-06-12 12:47:44 +02:00
Karel Zak
793e8d2ab8 cfdisk: add hint about labels for bootable flag
Addresses: https://github.com/util-linux/util-linux/discussions/2220
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-12 12:34:16 +02:00
Karel Zak
1c8a51701d Merge branch 'libmount/loop-rw' of https://github.com/t-8ch/util-linux
* 'libmount/loop-rw' of https://github.com/t-8ch/util-linux:
  libmount: (optlist) correctly detect ro status
2023-06-12 12:22:02 +02:00
Karel Zak
48554a4165 Merge branch 'lsfd--refactor' of https://github.com/masatake/util-linux
* 'lsfd--refactor' of https://github.com/masatake/util-linux:
  timeutils: add an inline funciton, is_timespecset()
  lsfd: use scols_table_get_column_by_name
2023-06-12 12:18:50 +02:00
Karel Zak
6182debc20 Merge branch 'setuid' of https://github.com/eworm-de/util-linux
* 'setuid' of https://github.com/eworm-de/util-linux:
  meson: install write setgid
  meson: install wall setgid
  meson: install umount setuid
  meson: install mount setuid
  meson: install newgrp setuid
  meson: install su setuid
  meson: install chsh setuid
  meson: install chfn setuid
2023-06-12 12:16:27 +02:00
Karel Zak
ed41386a03 Merge branch 'lsfd--signalfd' of https://github.com/masatake/util-linux
* 'lsfd--signalfd' of https://github.com/masatake/util-linux:
  tests: (lsfd) add a case for testing signalfd related columns
  tests: (mkfds) add a factory to make a signalfd
  lsfd.1.adoc: update for signalfds
  lsfd: print the masks specified in signalfds
2023-06-12 12:15:41 +02:00
Thomas Weißschuh
69e98d12a9 libmount: (optlist) correctly detect ro status
Fixes #2305

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-11 11:52:08 +02:00
Masatake YAMATO
765b4a147b timeutils: add an inline funciton, is_timespecset()
Close #2300.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-11 05:11:08 +09:00
Masatake YAMATO
0cc8e82a49 lsfd: use scols_table_get_column_by_name
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-11 00:19:12 +09:00
Christian Hesse
cee78467be meson: install write setgid
... as this requires elevated privileges.
2023-06-09 15:04:40 +02:00
Christian Hesse
07641fd93c meson: install wall setgid
... as this requires elevated privileges.
2023-06-09 15:04:40 +02:00
Christian Hesse
1cb3c90ca5 meson: install umount setuid
... as this requires elevated privileges.
2023-06-09 15:04:40 +02:00
Christian Hesse
8f49b3693d meson: install mount setuid
... as this requires elevated privileges.
2023-06-09 15:04:40 +02:00
Christian Hesse
cb3dee5a14 meson: install newgrp setuid
... as this requires elevated privileges.
2023-06-09 15:04:40 +02:00
Christian Hesse
fb8c224eae meson: install su setuid
... as this requires elevated privileges.
2023-06-09 15:04:40 +02:00
Christian Hesse
a13574b1de meson: install chsh setuid
... as this requires elevated privileges.
2023-06-09 15:04:40 +02:00
Christian Hesse
60d457f529 meson: install chfn setuid
... as this requires elevated privileges.
2023-06-09 15:04:40 +02:00
Karel Zak
39032646fe Merge branch 'PR/libmount-force-mount2' of github.com:karelzak/util-linux-work
* 'PR/libmount-force-mount2' of github.com:karelzak/util-linux-work:
  libmount: introduce LIBMOUNT_FORCE_MOUNT2={always,never,auto}
2023-06-09 11:50:23 +02:00
Masatake YAMATO
6591ddf6b0 tests: (lsfd) add a case for testing signalfd related columns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-09 07:51:00 +09:00
Masatake YAMATO
4012622ab4 tests: (mkfds) add a factory to make a signalfd
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-08 21:33:06 +09:00
Masatake YAMATO
82e8be5a3d lsfd.1.adoc: update for signalfds
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-08 07:37:01 +09:00
Masatake YAMATO
b22d1e541a lsfd: print the masks specified in signalfds
An example output:

    # ./lsfd -p "$(pidof systemd-journald)" -Q '(TYPE == "signalfd")'

    COMMAND             PID USER ASSOC MODE     TYPE       SOURCE MNTID INODE NAME
    systemd-journal 2382709 root   238  rw- signalfd anon_inodefs    15  1060 mask=USR1,USR2
    systemd-journal 2382709 root   239  rw- signalfd anon_inodefs    15  1060 mask=INT,TERM
    systemd-journal 2382709 root   240  rw- signalfd anon_inodefs    15  1060 mask=35

Using signum_to_signame is suggested by Karel Zak <kzak@redhat.com>.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-08 07:35:20 +09:00
Karel Zak
fd6b4d94ff libmount: introduce LIBMOUNT_FORCE_MOUNT2={always,never,auto}
Let's introduce a stable workaround for use cases where new kernel API
is not ready to use.

The patch does not use "goto enosys" to exit as nothing in the hookset
is initialized yet.

Addresses: https://github.com/util-linux/util-linux/issues/1992
Addresses: https://github.com/util-linux/util-linux/issues/2283
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-07 10:12:29 +02:00
Karel Zak
97d60d6699 Merge branch 'pr/libmount-5.12.0' of github.com:karelzak/util-linux-work
* 'pr/libmount-5.12.0' of github.com:karelzak/util-linux-work:
  libmount: use mount(2) for remount on Linux < 5.14
2023-06-06 10:47:35 +02:00
Karel Zak
0dbf5504dc Merge branch 'lsfd--misc-fix' of https://github.com/masatake/util-linux
* 'lsfd--misc-fix' of https://github.com/masatake/util-linux:
  lsfd: assign a class to the file in new_file()
  lsfd: don't check the value returned from new_file()
2023-06-06 10:46:19 +02:00
Karel Zak
00f254a8f0 Merge branch 'lsfd--timerfd' of https://github.com/masatake/util-linux
* 'lsfd--timerfd' of https://github.com/masatake/util-linux:
  tests: (lsfd/filter) add a case for comparing floating point numbers
  tests: (lsfd) add a case for testing timerfd related columns
  tests: add ts_skip_capability
  tests: (mkfds) add a factory to make a timerfd
  lsfd.1.adoc: write about timerfd
  lsfd: print the detail of the timer associated with a timerfd
  lsfd: (filter) accept floating point numbers in expressions
  lsfd: (filter) support floating point number used in columns
  lsfd: (filter) reduce duplicated code in macro definitions
  lsfd: (filter) improve error message
  lsfd.1.adoc: revise type names for columns
  lsfd.1.adoc: fix typos
  lsfd: adjust coding style
  lsfd: fix a sentence in comment
2023-06-06 10:45:17 +02:00
Karel Zak
71b01d2a37 libmount: use mount(2) for remount on Linux < 5.14
It seems mount_setattr() is supported on Linux < 5.14, but it's without
MOUNT_ATTR_NOSYMFOLLOW. That's problem for remount where we reset all
VFS flags.

The most simple (but not elegant) is to check for kernel version and
fallback to mount(2) on remount.

Addresses: https://github.com/util-linux/util-linux/issues/2283
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-05 12:59:41 +02:00
Karel Zak
7db2e6373b Merge branch 'fix-jfs' of https://github.com/mbroz/util-linux
* 'fix-jfs' of https://github.com/mbroz/util-linux:
  libblkid: jfs - avoid undefined shift
2023-06-05 11:46:11 +02:00
Karel Zak
b7dd45f6c8 Merge branch 'libblkid/bcache-csum' of https://github.com/t-8ch/util-linux
* 'libblkid/bcache-csum' of https://github.com/t-8ch/util-linux:
  libblkid: (bcache) report block size
  libblkid: (bcache) report version
  libblkid: (bcache) report label
  libblkid: (bcache) also calculate checksum over journal buckets
  libblkid: (bcache) extend superblock definition
2023-06-05 11:45:37 +02:00
Karel Zak
57cd868ed1 Merge branch 'fixes' of https://github.com/t-8ch/util-linux
* 'fixes' of https://github.com/t-8ch/util-linux:
  libmount (python) : simplify struct initialization
  lsfd-filter: constify filter logic
  misc: constify some fields
2023-06-05 11:44:30 +02:00
Masatake YAMATO
2beb17a641 lsfd: assign a class to the file in new_file()
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-05 06:41:08 +09:00
Masatake YAMATO
783807a511 lsfd: don't check the value returned from new_file()
The funciton newver returns NULL.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-05 06:41:08 +09:00
Milan Broz
16d8b1e2a6 libblkid: jfs - avoid undefined shift
Fix previous commit 04a0717b0b
to avoid undefined shift if value is exactly 32.

  libblkid/src/superblocks/jfs.c:46:39: runtime error:
  shift exponent 32 is too large for 32-bit type 'unsigned int'

Reproducer found with OSS-Fuzz (issue 59284) running over
cryptsetup project (blkid is used in header init).

Signed-off-by: Milan Broz <gmazyland@gmail.com>
2023-06-04 19:18:57 +02:00
Masatake YAMATO
7816bcb9da tests: (lsfd/filter) add a case for comparing floating point numbers
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 17:19:34 +09:00
Masatake YAMATO
ed59afeefb tests: (lsfd) add a case for testing timerfd related columns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 17:19:34 +09:00
Masatake YAMATO
63feafbae8 tests: add ts_skip_capability
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 17:19:34 +09:00
Masatake YAMATO
baadd080d3 tests: (mkfds) add a factory to make a timerfd
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 17:19:34 +09:00
Masatake YAMATO
50f73920c5 lsfd.1.adoc: write about timerfd
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 17:19:34 +09:00
Masatake YAMATO
188b7d64bb lsfd: print the detail of the timer associated with a timerfd
An example output:

    # ./lsfd -p 1  -Q '(TYPE == "timerfd")' -oCOMMAND,PID,ASSOC,TYPE,INODE,NAME
    COMMAND PID ASSOC    TYPE INODE NAME
    systemd   1    22 timerfd  1060 clockid=monotonic remaining=4625.661834645
    systemd   1    25 timerfd  1060 clockid=realtime remaining=398.164618943
    systemd   1   112 timerfd  1060 clockid=realtime remaining=7537606384.202715161

Added three new columns, TIMERFD.{CLOCKID,TIMERFD.REMAINING,INTERVAL}.
The filter engine works well with them.

An example listing timerfd files expiring within 1.2 seconds.

    # ./lsfd -Q '(TIMERFD.REMAINING > 0.0) && (TIMERFD.REMAINING < 1.2)'
    COMMAND          PID        USER ASSOC MODE    TYPE       SOURCE MNTID INODE NAME
    Xorg           17069         jet    26  rw- timerfd anon_inodefs    15  1060 clockid=monotonic remaining=0.061075544
    systemd-oomd 2382701 systemd-oom     8  rw- timerfd anon_inodefs    15  1060 clockid=monotonic remaining=0.178126915

Using SCOLS_JSON_NUMBER as the data type for TIMERFD.REMAINING and
TIMERFD.INTERVAL columns is suggested by Thomas Weißschuh
<thomas@t-8ch.de>.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 17:18:38 +09:00
Masatake YAMATO
1fa1856471 lsfd: (filter) accept floating point numbers in expressions
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 07:57:02 +09:00
Masatake YAMATO
564d954a86 lsfd: (filter) support floating point number used in columns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 07:40:42 +09:00
Masatake YAMATO
520f03a241 lsfd: (filter) reduce duplicated code in macro definitions
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 07:40:42 +09:00
Masatake YAMATO
70b1623ca6 lsfd: (filter) improve error message
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 07:40:42 +09:00
Masatake YAMATO
0dc26444be lsfd.1.adoc: revise type names for columns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 07:40:42 +09:00
Masatake YAMATO
0a0c726e77 lsfd.1.adoc: fix typos
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 06:32:18 +09:00
Masatake YAMATO
dd458e6585 lsfd: adjust coding style
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 06:32:18 +09:00
Masatake YAMATO
326e4be479 lsfd: fix a sentence in comment
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-04 06:32:18 +09:00
Thomas Weißschuh
9bd8074862 libblkid: (bcache) report block size
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 13:51:36 +02:00
Thomas Weißschuh
1b2efad216 libblkid: (bcache) report version
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 13:51:22 +02:00
Thomas Weißschuh
11d0724f78 libblkid: (bcache) report label
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 13:51:09 +02:00
Thomas Weißschuh
7140635881 libblkid: (bcache) also calculate checksum over journal buckets
Fixes #2291

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 13:50:51 +02:00
Thomas Weißschuh
d2f4b5c83b libblkid: (bcache) extend superblock definition
We will need it for the correct checksum calculation.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 13:28:18 +02:00
Thomas Weißschuh
6f052eaa1e libmount (python) : simplify struct initialization
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 10:25:03 +02:00
Thomas Weißschuh
9b6ad16fd9 lsfd-filter: constify filter logic
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 10:25:03 +02:00
Thomas Weißschuh
37b2b3fa46 misc: constify some fields
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 10:13:59 +02:00
Thomas Weißschuh
ed3fd21fe2 ci: use clang 16
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 09:22:00 +02:00
Thomas Weißschuh
3a14fb35be tests: fix subtests containing spaces in their name
Previously these tests would silently fail to compare
$TS_OUTPUT / $TS_ERRLOG.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-03 09:19:44 +02:00
Thomas Weißschuh
45552ef260 ci: build with GCC 13/11
Newer releases of GCC 13 have reigned in the false positives, so use it
for CI now.
The sanitizer builds are sticking to GCC 11 for now.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-01 15:01:14 +02:00
Thomas Weißschuh
90b12595bb ci: build on old distro
This should help to catch build breaks

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 18:14:28 +02:00
Thomas Weißschuh
edc4e52533 ci: mark source directory as safe
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 18:14:28 +02:00
Thomas Weißschuh
b660e0c4df ci: prevent prompts during installation
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 18:14:28 +02:00
Thomas Weißschuh
d53284bb1e tests: skip broken tests on docker
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 18:14:28 +02:00
Thomas Weißschuh
023e77d26a tests: add ts_skip_docker
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 18:14:28 +02:00
Thomas Weißschuh
a5b093698a tools: (asciidoctor) explicitly require extensions module
This is needed for older versions of asciidoctor.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 18:14:28 +02:00
Thomas Weißschuh
25a70dcb2e build-sys: only pass --failure-level if supported
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 17:31:42 +02:00
Thomas Weißschuh
58c16c8442 build-sys: fix typo in waitpid check
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 17:31:42 +02:00
Thomas Weißschuh
d975467d8f lsfd: (tests) fix typo
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 17:31:42 +02:00
Thomas Weißschuh
ae20b7fb4c blockdev: properly check for BLKGETZONESZ ioctl
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 16:11:46 +02:00
Thomas Weißschuh
754c030f29 blkzone: don't take address of struct blk_zone
Older versions of GCC do not know the warning so they warn about the
unknown ignored warning.

As struct blk_zone is only 64 bytes anyway just copy it.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-31 16:11:46 +02:00
Karel Zak
99e7f7101a Merge branch 'pr/termtype' 2023-05-31 11:03:07 +02:00
Karel Zak
edbd9ee562 Merge branch 'patch-1' of https://github.com/theHenMan/util-linux
* 'patch-1' of https://github.com/theHenMan/util-linux:
  Update fsck.8.adoc
2023-05-31 09:35:05 +02:00
Karel Zak
142738e861 Merge branch 'enosys/compat' of https://github.com/t-8ch/util-linux
* 'enosys/compat' of https://github.com/t-8ch/util-linux:
  test_enosys: fix build on old kernels
2023-05-31 09:30:31 +02:00
Karel Zak
423bf01e7e Merge branch 'patch-1' of https://github.com/nt8r/util-linux
* 'patch-1' of https://github.com/nt8r/util-linux:
  dmesg: make kmsg read() buffer big enough for kernel
2023-05-31 09:28:33 +02:00
Karel Zak
ddf41df9e9 Merge branch 'patch-2' of https://github.com/ThomasKaiser/util-linux
* 'patch-2' of https://github.com/ThomasKaiser/util-linux:
  Fix Blizzard-M2-Max
  Add recent Apple ARM cores
2023-05-31 09:21:11 +02:00
Karel Zak
84a8f5edb2 ttyutils: improve get_terminal_default_type() code
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-31 09:18:06 +02:00
Hennie Botha
565eae0cf4
Update fsck.8.adoc
Typo
2023-05-31 08:45:25 +02:00
Thomas Weißschuh
9ff6f9d9ab test_enosys: fix build on old kernels
Fixes #2277

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-30 20:10:02 +02:00
anteater
efb18899d2
dmesg: make kmsg read() buffer big enough for kernel
otherwise, if the kernel log has an item longer than 1024B, our read() gives EINVAL and we stop reading kmsg
2023-05-29 20:59:11 +00:00
Karel Zak
0c7df652e2 sulogin: use get_terminal_default_type()
Let's reuse the way how agetty initializes $TERM.

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-29 15:11:48 +02:00
Karel Zak
4869b259d6 agetty: use get_terminal_default_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-29 15:11:13 +02:00
Karel Zak
cba97be9fb lib/ttyutils: add get_terminal_default_type()
Based on code from agetty.

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-29 15:10:24 +02:00
Karel Zak
96c8ff27a4 Merge branch 'next' 2023-05-29 14:56:52 +02:00
ThomasKaiser
9bd0ed6fba
Fix Blizzard-M2-Max 2023-05-29 14:47:50 +02:00
ThomasKaiser
e97637ec6f
Add recent Apple ARM cores 2023-05-29 14:42:18 +02:00
Karel Zak
ac2fc8b442 Merge branch 'mount/ntfs-segfault' of https://github.com/t-8ch/util-linux
* 'mount/ntfs-segfault' of https://github.com/t-8ch/util-linux:
  mount: (tests) test mount helper with multiple filesystems
  libmount: (tests) split helper tests
2023-05-29 11:29:19 +02:00
Masatake YAMATO
f271f09bd6 tests: (lsfd) add a case for testing EVENTPOLL.TFDS column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-28 18:01:27 +09:00
Masatake YAMATO
bf416aeca3 tests: (mkfds) add a factory to make an eventpoll fd
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-28 18:01:27 +09:00
Masatake YAMATO
c2e2dd6008 lsfd: print file descriptors targeted by eventpoll files
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-28 18:01:27 +09:00
Masatake YAMATO
3062a58f0b add the "x" wrapper for reallocarray(3)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-28 12:34:21 +09:00
Thomas Weißschuh
36d4e61c65 mount: (tests) test mount helper with multiple filesystems
See #2267

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-25 12:44:19 +02:00
Thomas Weißschuh
63d4806055 libmount: (tests) split helper tests
This splits the test introduced in
commit 06e05eb0f7 ("libmount: don't pass option "defaults" to helper")
into its own subtest.

We will have more subtests.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-25 12:44:19 +02:00
Karel Zak
f94a7760ed libmount: don't call hooks after mount.<type> helper
In case more filesystems are specified (or when libmount follows
/{etc,proc}/filesystems) then the library may try to use and
initialize the new API because for some filesystems, we need
exec(/sbin/mount.<type>) and for another fsopen().

The hooks that use the API have to smart and detect that the mount
operation was done in external /sbin/mount.<type> helper. And in this
case, the new API file descriptors must be ignored.

The exception is propagation flags, mount(8) can set the flags after
exec(/sbin/mount.<type>), for example, "mount -t ntfs --make-private".

Fixes: https://github.com/util-linux/util-linux/issues/2267
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-25 11:58:51 +02:00
Karel Zak
12c616b029 Merge branch 'enosys/arch-check' of https://github.com/t-8ch/util-linux
* 'enosys/arch-check' of https://github.com/t-8ch/util-linux:
  enosys: add support for loongarch
  enosys: only build if AUDIT_ARCH_NATIVE is defined
  meson: require 0.57
  enosys: split audit arch detection into dedicated header
  enosys: add support for sparc
2023-05-24 11:41:59 +02:00
Karel Zak
27675c5c62 Merge branch 'lsfd--sysvipc-shmem' of https://github.com/masatake/util-linux
* 'lsfd--sysvipc-shmem' of https://github.com/masatake/util-linux:
  tests: (lsfd) add a case for testing SOURCE column for SysV shmem mappings
  tests: (mkfds) add a factory to make SysV shmem
  lsfd: add tmpfs as source of sysvipc to the the nodev_table
  lsfd: initialize pagesize in an earlier stage
  lsfd: add "nsfs" to the nodev_table to fill SOURCE column for nsfs files
  lsfd: add a helper function for adding a nodev to the nodev_table
  lsfd: add a whitespace
  lsfd: write more about nsfs in comment
2023-05-24 11:41:42 +02:00
Masatake YAMATO
24a10f06e9 tests: (lsfd) add a case for testing SOURCE column for SysV shmem mappings
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-24 01:41:47 +09:00
Masatake YAMATO
c3f8cba1d4 tests: (mkfds) add a factory to make SysV shmem
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-24 01:41:47 +09:00
Masatake YAMATO
de9ec7ee36 lsfd: add tmpfs as source of sysvipc to the the nodev_table
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-24 01:41:47 +09:00
Masatake YAMATO
c1cb27357c lsfd: initialize pagesize in an earlier stage
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-24 01:02:08 +09:00
Masatake YAMATO
916b44a59a lsfd: add "nsfs" to the nodev_table to fill SOURCE column for nsfs files
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-24 01:02:02 +09:00
Masatake YAMATO
d5ca01c0f4 lsfd: add a helper function for adding a nodev to the nodev_table
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-24 00:49:47 +09:00
Masatake YAMATO
ccd4e14285 lsfd: add a whitespace
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-24 00:49:47 +09:00
Masatake YAMATO
d289149385 lsfd: write more about nsfs in comment
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-24 00:49:47 +09:00
Thomas Weißschuh
c345a4002b enosys: add support for loongarch
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-23 17:24:01 +02:00
Thomas Weißschuh
3e0bbb1222 enosys: only build if AUDIT_ARCH_NATIVE is defined
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-23 17:24:01 +02:00
Thomas Weißschuh
e2cd74462e meson: require 0.57
It is needed for fs.read()

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-23 17:24:01 +02:00
Thomas Weißschuh
29e3f73784 enosys: split audit arch detection into dedicated header
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-23 17:24:01 +02:00
Thomas Weißschuh
fc5018e801 enosys: add support for sparc
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-23 16:35:14 +02:00
Thomas Weißschuh
9d48efbbe7 lsfd: (tests) don't run mqueue test on byteorder mismatch
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-23 14:27:48 +02:00
Thomas Weißschuh
ffdd75ccee waitpid: only build when pidfd_open is available
Fixes #2256

[kzak@redhat.com: - fix UL_BUILD_INIT() use]

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-23 12:31:23 +02:00
Karel Zak
fb889bab8b Merge branch 'meson' of https://github.com/eworm-de/util-linux
* 'meson' of https://github.com/eworm-de/util-linux:
  meson: install symlink for vigr man page
  meson: include bash-completion for write
  meson: include bash-completion for newgrp
2023-05-23 12:18:00 +02:00
Karel Zak
c733db6114 Merge branch 'lsfd--mqueue' of https://github.com/masatake/util-linux
* 'lsfd--mqueue' of https://github.com/masatake/util-linux:
  tests: (lsfd) add cases for POSIX Mqueue
  tests: (mkfds) add mqueue factory
  lsfd: fill ENDPOINTS column of POSIX Mqueue
  lsfd: add a new type "mqueue", a type for POSIX Mqueue
2023-05-23 12:17:18 +02:00
Karel Zak
3429accb62 Merge branch 'agetty/fileutils' of https://github.com/t-8ch/util-linux
* 'agetty/fileutils' of https://github.com/t-8ch/util-linux:
  agetty: include fileutils.h
2023-05-23 12:16:31 +02:00
Christian Hesse
f6fb7fa713 meson: install symlink for vigr man page 2023-05-23 12:15:41 +02:00
Christian Hesse
e1cd4002c8 meson: include bash-completion for write 2023-05-23 12:15:41 +02:00
Christian Hesse
f265b43296 meson: include bash-completion for newgrp 2023-05-23 12:15:41 +02:00
Karel Zak
54e94f8669 libmount: cleanup enosys returns from mount hoop
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-23 12:13:02 +02:00
Karel Zak
99550bf5aa Merge branch 'libmount/mount_setattr' of https://github.com/t-8ch/util-linux
* 'libmount/mount_setattr' of https://github.com/t-8ch/util-linux:
  libmount: check for availability of mount_setattr
2023-05-23 12:06:36 +02:00
Karel Zak
9105d3cdd8 fstab: add hint about systemd reload
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-23 11:34:19 +02:00
Karel Zak
a5eba5046d mount: improve code readability
Static analyzers (e.g., Coverity) have a hard time understanding why
'optarg' is tested for NULL, and later in another place, code assumes
that it's non-NULL. For idmapping, the optarg is required.

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-23 10:47:18 +02:00
Karel Zak
a5e0e06cc2 login: fix memory leak [coverity scan]
Let's use ul_path_read_buffer() to avoid memory allocation.

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-23 10:43:59 +02:00
Karel Zak
fe0b1e793c libmount: don't call mount.<type> helper with usernames
This is v2.39 regression. The "user" mount option is internally
converted to "user=<name>", but this should not be exported to
the mount helpers.

The mount helper accepts the <name> only if specified in mount options
(cifs uses user=). The real username as generated by libmount is not
relevant in this case.

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-22 17:26:55 +02:00
Thomas Weißschuh
51a97767db agetty: include fileutils.h
It is needed to access xreaddir()

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-22 17:11:17 +02:00
Masatake YAMATO
d6850a7611 tests: (lsfd) add cases for POSIX Mqueue
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-22 23:29:19 +09:00
Masatake YAMATO
330555c481 tests: (mkfds) add mqueue factory
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-22 23:29:19 +09:00
Masatake YAMATO
29bcb60ee6 lsfd: fill ENDPOINTS column of POSIX Mqueue
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-22 23:29:19 +09:00
Karel Zak
e2d6f5e30e tests: add optlist tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-22 15:40:38 +02:00
Masatake YAMATO
ad0569880f lsfd: add a new type "mqueue", a type for POSIX Mqueue
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-22 22:25:57 +09:00
Karel Zak
c0267687fd libmount: fix options prepend/insert and merging
* the order of the new options should not be changed
   (for example prepend "a,b,c" to list with "d" has to generate "a,b,c,d", not "c,b,a,d")

 * make sure that  options map is defined when merging options

Fixes: https://github.com/util-linux/util-linux/issues/2238
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-22 15:00:25 +02:00
Karel Zak
096800a0df Merge branch 'agetty-creds' of https://github.com/DaanDeMeyer/util-linux
* 'agetty-creds' of https://github.com/DaanDeMeyer/util-linux:
  Document new systemd credentials support for agetty and login
  login: Initialize noauth from login.noauth credential
  agetty: Load autologin user from agetty.autologin credential
2023-05-22 13:42:48 +02:00
Karel Zak
59dc323560 Merge branch 'map-users' of https://github.com/arachsys-prs/util-linux
* 'map-users' of https://github.com/arachsys-prs/util-linux:
  mount: add --map-users and --map-groups convenience options
2023-05-22 13:36:37 +02:00
Karel Zak
518026915b Merge branch 'ci/openwrt' of https://github.com/t-8ch/util-linux
* 'ci/openwrt' of https://github.com/t-8ch/util-linux:
  ci: add OpenWrt SDK based CI jobs
  enosys: provide a nicer build message for syscalls.h generation
  libsmartcols: (samples): fix format truncation warning
  test_uuidd: make pthread_t formatting more robust
  mkfs.minix: handle 64bit time on 32bit system
  enosys: add support for MIPS, PowerPC and ARC
  enosys: include sys/syscall.h
2023-05-22 13:32:53 +02:00
Karel Zak
f1cd43964d Merge branch 'enosys/speculation' of https://github.com/t-8ch/util-linux 2023-05-22 13:10:31 +02:00
Karel Zak
c8ecfe1e39 Merge branch 'enosys/mips' of https://github.com/t-8ch/util-linux
* 'enosys/mips' of https://github.com/t-8ch/util-linux:
  enosys: add support for MIPS, PowerPC and ARC
2023-05-22 13:09:28 +02:00
Karel Zak
0045193005 Merge branch 'fadvise/big-page' of https://github.com/t-8ch/util-linux
* 'fadvise/big-page' of https://github.com/t-8ch/util-linux:
  fadvise: (test) test with 64k blocks
  fadvise: (test) don't compare fincore page counts
  fadvise: (tests) factor out calls to "fincore"
  fadvise: (test) dynamically calculate expected test values
2023-05-22 13:06:44 +02:00
Karel Zak
3dae5ca16a Merge branch 'test--fix-process-leak' of https://github.com/masatake/util-linux
* 'test--fix-process-leak' of https://github.com/masatake/util-linux:
  lsfd: (tests) fix process leak
2023-05-22 13:04:08 +02:00
Karel Zak
e20944db44 Merge branch 'enosys/include' of https://github.com/t-8ch/util-linux
* 'enosys/include' of https://github.com/t-8ch/util-linux:
  enosys: include sys/syscall.h
2023-05-22 13:01:58 +02:00
Karel Zak
b39f5764b9 Merge branch 'libblkid/const' of https://github.com/t-8ch/util-linux
* 'libblkid/const' of https://github.com/t-8ch/util-linux:
  libblkid: constify cached disk data
2023-05-22 13:00:04 +02:00
Karel Zak
392d864b75 lib/shells: remove space after function name
Cats and ponies die when they see a space after a function name ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-22 12:45:06 +02:00
Karel Zak
f644f33089 lib/shells: initialize free-able variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-22 12:43:53 +02:00
Karel Zak
8128908d32 Merge branch 'econf' of https://github.com/stoeckmann/util-linux
* 'econf' of https://github.com/stoeckmann/util-linux:
  lib/shells: Plug econf memory leak
2023-05-22 12:42:13 +02:00
Karel Zak
ccd06765ce Merge branch 'lsfd--eventfd' of https://github.com/masatake/util-linux
* 'lsfd--eventfd' of https://github.com/masatake/util-linux:
  test_mkfds: avoid "ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’"
  tests: (lsfd) add cases for eventfd
  tests: (mkfds) add eventfd factory
  tests: (mkfds) provide the way to declare the number of extra printing values
  tests: (mkfds) print a whitespace only when the running factory has "report" method
  lsfd: fill ENDPOINTS column for eventfd
  lsfd: add a helper macro, foreach_endpoint
  lsfd: add a helper function, init_endpoint
  lsfd: add a helper function, add_endpoint
  lsfd: add a helper function, new_ipc
  lsfd: add a back pointer as a member of anon_eventfd_data
  lsfd: move a local variable to a narrower scope
  lsfd: add EVENTFD.ID column
  lsfd: delete redundant parentheses surrounding return value
  ldfd: delete unnecessary ';'
  lsfd: choose anon_ops declarative way
2023-05-22 12:39:59 +02:00
Karel Zak
cc665f33f4 Merge branch 'hexdump-one-byte-hex' of https://github.com/tpwo/util-linux
* 'hexdump-one-byte-hex' of https://github.com/tpwo/util-linux:
  hexdump: add new format-strings test case
  hexdump: add '--one-byte-hex' format option
2023-05-22 12:36:45 +02:00
Karel Zak
8a53082787 Merge branch 'allow-disabling-waitpid' of https://github.com/mrc0mmand/util-linux
* 'allow-disabling-waitpid' of https://github.com/mrc0mmand/util-linux:
  build-sys: add --disable-waitpid
2023-05-22 12:32:07 +02:00
Thomas Weißschuh
ced82526a1 enosys: allow CPU speculation
enosys is not a security tool so we can allow the CPU to speculate.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-22 10:00:13 +02:00
Thomas Weißschuh
1bd85b6463 libmount: check for availability of mount_setattr
If mount_setattr is not available but needed fall back to the legacy
mount API.

Fixes #2247

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-22 09:38:07 +02:00
Masatake YAMATO
47035719fc lsfd: (tests) fix process leak
Unifying multiple invocations of kill command and wait command
into two is suggested by Thomas Weißschuh <thomas@t-8ch.de>.

Addresses: https://lore.kernel.org/util-linux/652d32c5-4b33-ce3a-3de7-9ebc064bbdcb@gmail.com/
Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Tested-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-22 06:45:22 +09:00
Thomas Weißschuh
c0f31b79f5 fadvise: (test) test with 64k blocks
This will allow the tests to also pass on systems with 64k pagesizes.

Closes #2249
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-21 21:49:41 +02:00
Thomas Weißschuh
33980996d0 fadvise: (test) don't compare fincore page counts
These depend on the machines pagesize and are therefore not a good
comparision.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-21 21:48:50 +02:00
Thomas Weißschuh
e5009e773f fadvise: (tests) factor out calls to "fincore"
This will make it easier to pass argument later.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-21 21:48:20 +02:00
Thomas Weißschuh
8b36444f44 fadvise: (test) dynamically calculate expected test values
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-21 21:48:12 +02:00
Thomas Weißschuh
06e05eb0f7 libmount: don't pass option "defaults" to helper
"defaults" is only a pseudo-option that expands to other options.
It should not be passed to helpers.

Reported-by: Quentin Rameau <quinq@fifth.space>
Closes: https://lore.kernel.org/util-linux/20230521181814.0b0f2d38.quinq@fifth.space/
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-21 20:02:21 +02:00
Thomas Weißschuh
5f7c4093e2 ci: add OpenWrt SDK based CI jobs
This allows testing some more exotic architectures and libcs.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 23:16:48 +02:00
Thomas Weißschuh
9b1cf2bc69 enosys: provide a nicer build message for syscalls.h generation
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 17:52:19 +02:00
Thomas Weißschuh
d36705f402 libsmartcols: (samples): fix format truncation warning
As this is only an example and the needed memory is not much just
hardcode a large enough number.
The previously computed value was wrong anyways.

libsmartcols/samples/continuous.c: In function 'main':
libsmartcols/samples/continuous.c:110:61: error: '%3d' directive output may be truncated writing between 3 and 11 bytes into a region of size between 0 and 7 [-Werror=format-truncation=]
  110 |                         snprintf(timecell, timecellsz, "%f [%3d%%]", diff,
      |                                                             ^~~
libsmartcols/samples/continuous.c:110:25: note: 'snprintf' output between 11 and 333 bytes into a destination of size 12
  110 |                         snprintf(timecell, timecellsz, "%f [%3d%%]", diff,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111 |                                 done ? 100 : (int)(diff / (TIME_PERIOD / 100.0)));
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libsmartcols/samples/continuous.c:110:61: error: '%3d' directive output may be truncated writing 3 bytes into a region of size between 0 and 7 [-Werror=format-truncation=]
  110 |                         snprintf(timecell, timecellsz, "%f [%3d%%]", diff,
      |                                                             ^~~
libsmartcols/samples/continuous.c:110:25: note: 'snprintf' output between 11 and 325 bytes into a destination of size 12
  110 |                         snprintf(timecell, timecellsz, "%f [%3d%%]", diff,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111 |                                 done ? 100 : (int)(diff / (TIME_PERIOD / 100.0)));
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 17:50:01 +02:00
Thomas Weißschuh
cf652a7278 test_uuidd: make pthread_t formatting more robust
On musl pthread_t is a pointer. To avoid compiler warnings on 32bit
systems add a cast through intptr_t.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 17:48:58 +02:00
Thomas Weißschuh
c249602368 mkfs.minix: handle 64bit time on 32bit system
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 17:48:16 +02:00
Thomas Weißschuh
9c9d03e064 enosys: add support for MIPS, PowerPC and ARC
Co-developed-by: Hauke Mertens <hauke@hauke-m.de>
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 17:47:52 +02:00
Thomas Weißschuh
43d4d1cc1d enosys: include sys/syscall.h
Otherwise there is no guarantee that all syscall numbers detected by
tools/all_syscalls are actually available to enosys.c.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 17:47:52 +02:00
Thomas Weißschuh
6c1bd545cb enosys: include sys/syscall.h
Otherwise there is no guarantee that all syscall numbers detected by
tools/all_syscalls are actually available to enosys.c.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 10:51:25 +02:00
Thomas Weißschuh
1808882ad3 enosys: add support for MIPS, PowerPC and ARC
Co-developed-by: Hauke Mertens <hauke@hauke-m.de>
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 00:14:24 +02:00
Thomas Weißschuh
7eba8f98bd libblkid: constify cached disk data
The data returned from blkid_probe_get_buffer() and friends may or may
not be cached between different calls.
If one copy is modified this may not be visible in other copies.

This issue can be avoided by making any modification illegal.

See also #2165

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-19 00:00:34 +02:00
Masatake YAMATO
babcf0896c test_mkfds: avoid "ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’"
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
821efb4f6f tests: (lsfd) add cases for eventfd
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
5ba67aeabd tests: (mkfds) add eventfd factory
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
26406d1a72 tests: (mkfds) provide the way to declare the number of extra printing values
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
90317e2a12 tests: (mkfds) print a whitespace only when the running factory has "report" method
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
d4fea4d089 lsfd: fill ENDPOINTS column for eventfd
An example output:

  $ ./lsfd -Q '(TYPE == "eventfd") and (ENDPOINTS =~ ".+") ' -o+ENDPOINTS
  COMMAND          PID USER ASSOC MODE    TYPE       SOURCE MNTID INODE NAME   ENDPOINTS
  pipewire       17251  jet    40  rw- eventfd anon_inodefs    15  1060 id=818 17255,pipewire-pulse,26
  pipewire       17251  jet    52  rw- eventfd anon_inodefs    15  1060 id=695 17255,pipewire-pulse,30
									       17255,pipewire-pulse,37
									       17255,pipewire-pulse,49
  pipewire       17251  jet    54  rw- eventfd anon_inodefs    15  1060 id=845 17255,pipewire-pulse,31
  pipewire       17251  jet    61  rw- eventfd anon_inodefs    15  1060 id=212 17255,pipewire-pulse,45
  pipewire       17251  jet    62  rw- eventfd anon_inodefs    15  1060 id=224 17255,pipewire-pulse,46
  pipewire-pulse 17255  jet    26  rw- eventfd anon_inodefs    15  1060 id=818 17251,pipewire,40
  pipewire-pulse 17255  jet    30  rw- eventfd anon_inodefs    15  1060 id=695 17251,pipewire,52
									       17255,pipewire-pulse,37
									       17255,pipewire-pulse,49
  pipewire-pulse 17255  jet    31  rw- eventfd anon_inodefs    15  1060 id=845 17251,pipewire,54
  pipewire-pulse 17255  jet    37  rw- eventfd anon_inodefs    15  1060 id=695 17251,pipewire,52
									       17255,pipewire-pulse,30
									       17255,pipewire-pulse,49
  pipewire-pulse 17255  jet    45  rw- eventfd anon_inodefs    15  1060 id=212 17251,pipewire,61
  pipewire-pulse 17255  jet    46  rw- eventfd anon_inodefs    15  1060 id=224 17251,pipewire,62
  pipewire-pulse 17255  jet    49  rw- eventfd anon_inodefs    15  1060 id=695 17251,pipewire,52
									       17255,pipewire-pulse,30
									       17255,pipewire-pulse,37

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
e62d587334 lsfd: add a helper macro, foreach_endpoint
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
f9263edc9b lsfd: add a helper function, init_endpoint
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
1c2ab17ecd lsfd: add a helper function, add_endpoint
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
79ec864eaa lsfd: add a helper function, new_ipc
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
e283500c05 lsfd: add a back pointer as a member of anon_eventfd_data
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
55c857ae09 lsfd: move a local variable to a narrower scope
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:27 +09:00
Masatake YAMATO
8c2ca9c973 lsfd: add EVENTFD.ID column
The files under of /proc/$pid/fdinfo/* provide IDs for eventfd files.
With this change, lsfd extacts the IDs. All eventfd files share the
same inode. So the IDs are useful to distinguish two different
envetfds.

An example output:

  $ ./lsfd -Q '(TYPE == "eventfd")' -o+EVENTFD.ID | head
  COMMAND             PID USER ASSOC MODE    TYPE       SOURCE MNTID INODE NAME   EVENTFD.ID
  gnome-session-b   17113  jet     3  rw- eventfd anon_inodefs    15  1060 id=43          43
  gnome-session-b   17113  jet     4  rw- eventfd anon_inodefs    15  1060 id=44          44
  gnome-session-b   17113  jet     6  rw- eventfd anon_inodefs    15  1060 id=158        158
  gnome-session-b   17113  jet     8  rw- eventfd anon_inodefs    15  1060 id=167        167
  at-spi-bus-laun   17160  jet     3  rw- eventfd anon_inodefs    15  1060 id=341        341
  at-spi-bus-laun   17160  jet     4  rw- eventfd anon_inodefs    15  1060 id=342        342
  at-spi-bus-laun   17160  jet     5  rw- eventfd anon_inodefs    15  1060 id=343        343
  at-spi-bus-laun   17160  jet     9  rw- eventfd anon_inodefs    15  1060 id=344        344
  gvfsd             17169  jet     3  rw- eventfd anon_inodefs    15  1060 id=369        369

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:27:24 +09:00
Masatake YAMATO
4a3d70fed3 lsfd: delete redundant parentheses surrounding return value
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:26:57 +09:00
Masatake YAMATO
1e83b1fc6f ldfd: delete unnecessary ';'
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:26:57 +09:00
Masatake YAMATO
007e405b1e lsfd: choose anon_ops declarative way
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-05-19 03:26:55 +09:00
Frantisek Sumsal
c0d75916b6 build-sys: add --disable-waitpid
The new pidfd stuff waitpid uses is not compatible with older kernel
headers, but the rest of the util-linux is still perfectly fine, so
allow disabling just the waitpid utility to make the builds happy again.
2023-05-18 18:56:15 +02:00
Tobias Stoeckmann
b83e58a55c lib/shells: Plug econf memory leak
You can see the memory leak with address sanitizer if util-linux is
compiled with `--with-vendordir=/usr/etc`.

How to reproduce:

1. Prepare a custom shell file as root
```
mkdir -p /etc/shells.d
echo /bin/myshell > /etc/shells.d/custom
```

2. Run chsh as regular user
```
chsh
```

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2023-05-18 17:48:46 +02:00
Karel Zak
01a0a55601 lib/caputils: fix integer handling issues [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-18 10:26:02 +02:00
наб
03a8f430c5 mesg.1 cleanups/updates
First hunk:  grammar.
Second hunk: (a) mentioning BSD ptys and not UNIX98 ones is odd,
             (b) mentioning /only/ ptys is odder still.
Third hunk:  mesg is found in the UNIX Programmer's Manual;
             it takes its modern form in V7
             (it's unclear to me why V6 specifically is mentioned,
              since it's still default-invert + always-report-"was X").
2023-05-17 13:53:45 +02:00
Karel Zak
a82df27f5d Merge branch 'nsenter-keep-caps' of https://github.com/dgibson/util-linux
* 'nsenter-keep-caps' of https://github.com/dgibson/util-linux:
  Add --keep-caps option to nsenter, similar to the one in unshare
  unshare: Move implementation of --keep-caps option to library function
2023-05-17 13:43:40 +02:00
Karel Zak
d3edf0f8de Merge branch 'libmount/syscall' 2023-05-17 13:42:01 +02:00
Karel Zak
bd2ebbd4ea Merge branch 'enosys' of https://github.com/t-8ch/util-linux
* 'enosys' of https://github.com/t-8ch/util-linux:
  enosys: properly block execve syscall
  enosys: don't require end-of-options marker
  enosys: find syscalls at build time
  enosys: remove long jumps from BPF
  enosys: add --list
  enosys: validate syscall architecture
  enosys: add manpage
  enosys: add bash completion
  enosys: make messages useful for users
  enosys: translate messages
  enosys: add common arguments
  enosys: add test
  enosys: fix native arch for s390x
  enosys: syscall numbers are "long"
  enosys: mark variable static
  enosys: remove unneeded inline variable declaration
  enosys: improve checks for EXIT_NOTSUPP
  enosys: move from tests/helpers/test_enosys.c
  c.h: make err_nonsys available
2023-05-17 13:34:34 +02:00
Karel Zak
372e026e09 Merge branch 'mkswap/offset' of https://github.com/t-8ch/util-linux
* 'mkswap/offset' of https://github.com/t-8ch/util-linux:
  mkswap: implement --offset
  mkswap: (tests) don't overwrite logfiles
  mkswap: (tests) validate existence of truncate command
2023-05-17 13:27:55 +02:00
Karel Zak
976157c821 Merge branch 'blockdev/zonesz' of https://github.com/t-8ch/util-linux
* 'blockdev/zonesz' of https://github.com/t-8ch/util-linux:
  blockdev: add support for BLKGETZONESZ
2023-05-17 13:26:34 +02:00
Karel Zak
747fe9946a Merge branch 'mount/tests/fstab' of https://github.com/t-8ch/util-linux
* 'mount/tests/fstab' of https://github.com/t-8ch/util-linux:
  mount: (tests) reuse well-known per-test fstab location
  tests: (functions.sh) use per-test fstab file
  mount: (tests) explicitly use test fstab location
  tests: (functions.sh) create variable for test fstab location
2023-05-17 13:25:25 +02:00
Thomas Weißschuh
afb669afed enosys: properly block execve syscall
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-17 00:25:20 +02:00
Thomas Weißschuh
4b1538c754 enosys: don't require end-of-options marker
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:45:17 +02:00
Thomas Weißschuh
69e542bd2d enosys: find syscalls at build time
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:50 +02:00
Thomas Weißschuh
5e248716e6 enosys: remove long jumps from BPF
BPF encodes the jump distance in a uint8_t. To avoid overflows of this
value reorganize the generated bytecode to work without long jumps.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:50 +02:00
Thomas Weißschuh
7f104027e2 enosys: add --list 2023-05-16 22:44:50 +02:00
Thomas Weißschuh
9e8fb1f5ed enosys: validate syscall architecture
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:50 +02:00
Thomas Weißschuh
ae03abcf56 enosys: add manpage
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:50 +02:00
Thomas Weißschuh
ac5267423d enosys: add bash completion
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:50 +02:00
Thomas Weißschuh
a3fdbe0c4f enosys: make messages useful for users
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:50 +02:00
Thomas Weißschuh
13d1cbced2 enosys: translate messages
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:50 +02:00
Thomas Weißschuh
344ba205c1 enosys: add common arguments
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:50 +02:00
Thomas Weißschuh
4290056351 enosys: add test
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:44:41 +02:00
Thomas Weißschuh
113356e95d enosys: fix native arch for s390x
s390 also defines __s390__ so we first have to check for __s390x__.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:32:29 +02:00
Thomas Weißschuh
58fe26362c enosys: syscall numbers are "long"
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:32:29 +02:00
Thomas Weißschuh
165fbfd46e enosys: mark variable static
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:32:29 +02:00
Thomas Weißschuh
7626054ca8 enosys: remove unneeded inline variable declaration
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:32:29 +02:00
Thomas Weißschuh
f080b635a1 enosys: improve checks for EXIT_NOTSUPP
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:32:25 +02:00
Thomas Weißschuh
cba52cc194 enosys: move from tests/helpers/test_enosys.c 2023-05-16 22:31:57 +02:00
Thomas Weißschuh
bb2b071f54 c.h: make err_nonsys available
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-16 22:31:57 +02:00
Tomasz Wojdat
42de8aba28
hexdump: add new format-strings test case
Signed-off-by: Tomasz Wojdat <tpwojdat@gmail.com>
2023-05-16 21:46:57 +02:00
Tomasz Wojdat
bbf5bf8a88
hexdump: add '--one-byte-hex' format option
Signed-off-by: Tomasz Wojdat <tpwojdat@gmail.com>
2023-05-16 20:24:21 +02:00
Thomas Weißschuh
8b70b9e32a mount: (tests) reuse well-known per-test fstab location
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-14 21:51:23 +02:00
Thomas Weißschuh
6aa8d17b6b tests: (functions.sh) use per-test fstab file
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-14 21:51:23 +02:00
Thomas Weißschuh
b1580bd760 mount: (tests) explicitly use test fstab location
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-14 21:51:23 +02:00
Thomas Weißschuh
ed3d33faff tests: (functions.sh) create variable for test fstab location
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-14 21:51:23 +02:00
Thomas Weißschuh
84ec6f99f7 mkswap: implement --offset
Addresses #2166

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-11 12:09:56 +02:00
Thomas Weißschuh
b0826e8c98 mkswap: (tests) don't overwrite logfiles
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-11 12:09:56 +02:00
Thomas Weißschuh
d996ff1dc6 mkswap: (tests) validate existence of truncate command
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-11 12:09:55 +02:00
Thomas Weißschuh
4832fd9f36 blockdev: add support for BLKGETZONESZ
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-05-05 10:57:52 +02:00
Karel Zak
91ea38e91d libmount: report failed syscall name
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-04-25 12:48:18 +02:00
Chris Webb
a61bbb3709 mount: add --map-users and --map-groups convenience options
Allow an X-mount.idmap option to be specified either from an existing
userns with --map-users=/proc/PID/ns/user or incrementally with a series
of --map-users=INNER:OUTER:COUNT and --map-groups=INNER:OUTER:COUNT
options which compose into a single X-mount.idmap mount option.

Apart from distinguishing absolute namespace paths from literal mappings,
defer validation to libmount when it parses X-mount.idmap.

Signed-off-by: Chris Webb <chris@arachsys.com>
2023-04-24 15:37:45 +01:00
Daan De Meyer
1bf9c6915e Document new systemd credentials support for agetty and login 2023-04-16 15:05:15 +02:00
Karel Zak
2ed0190535 Merge branch 'flock/test/fd' of https://github.com/t-8ch/util-linux into next
* 'flock/test/fd' of https://github.com/t-8ch/util-linux:
  flock: (tests) add test for fd-based locking
2023-04-14 09:47:16 +02:00
Karel Zak
575d71fde1 nsenter: (man) add --keep-caps
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-04-13 12:29:55 +02:00
Karel Zak
d4b1d901c5 Merge branch 'nsenter-keep-caps' of https://github.com/dgibson/util-linux into next
* 'nsenter-keep-caps' of https://github.com/dgibson/util-linux:
  Add --keep-caps option to nsenter, similar to the one in unshare
  unshare: Move implementation of --keep-caps option to library function
2023-04-13 12:25:01 +02:00
Daan De Meyer
12252002ad login: Initialize noauth from login.noauth credential
Let's check if we've been passed credentials by systemd and if so,
try to determine whether we need to auth the user to login from
the login.noauth credential.
2023-04-13 11:47:18 +02:00
Daan De Meyer
bcebab29a7 agetty: Load autologin user from agetty.autologin credential
Let's check if we've been passed credentials by systemd and if so,
try to read the user to autologin from the agetty.autologin
credential.

Partially fixes #2012
2023-04-13 11:46:21 +02:00
Karel Zak
ad6d9fd50c cfdisk: ask y/n before wipe
Addresses: https://github.com/util-linux/util-linux/issues/2160
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-04-12 15:07:45 +02:00
David Gibson
5b175fa9f0 Add --keep-caps option to nsenter, similar to the one in unshare
When entering a user namespace at the kernel level, whether with clone(2),
unshare(2) or setns(2), a process always gains full capabilities in the
new userns.

unshare(1) allows using that from the shell with the --keep-caps option,
which transfers that full permitted capability set to the ambient set so
it's available to the spawned shell or other process.

nsenter(1) currently has no equivalent option, despite the fact that
setns(2) grants capabilities in just the same way.  This patch adds a
--keep-caps to nsenter(1) that works just like the one in unshare(1).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2023-03-29 13:51:10 +11:00
David Gibson
acb72212eb unshare: Move implementation of --keep-caps option to library function
unshare.c open codes some logic to copy the permitted capability set to the
ambient set in order to implement the --keep-caps option.  Move this logic
to lib/caputils.c so that we can reuse it in nsenter.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2023-03-29 13:36:15 +11:00
303 changed files with 6928 additions and 1173 deletions

View file

@ -2,6 +2,8 @@
set -ex
export DEBIAN_FRONTEND=noninteractive
apt-get -y update --fix-missing
# Xenial uses btrfs-tools, but since Focal it's btrfs-progs
@ -27,6 +29,7 @@ PACKAGES=(
iproute2
dmsetup
python3-dev
gawk
)
PACKAGES_OPTIONAL=(
@ -57,7 +60,9 @@ bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricte
# cov-build fails to compile util-linux when CC is set to gcc-*
# so let's just install and use the default compiler
if [[ "$COMPILER_VERSION" == "" ]]; then
PACKAGES+=("$COMPILER")
if [[ "$COMPILER" != "none" ]]; then
PACKAGES+=("$COMPILER")
fi
elif [[ "$COMPILER" == clang ]]; then
# Latest LLVM stack deb packages provided by https://apt.llvm.org/
# Following snippet was borrowed from https://apt.llvm.org/llvm.sh

View file

@ -1,5 +1,5 @@
#!/bin/bash
set -ex
PHASES=(${@:-CONFIGURE MAKE INSTALL CHECK DISTCHECK})
@ -87,9 +87,7 @@ for phase in "${PHASES[@]}"; do
)
if [[ "$COVERAGE" == "yes" ]]; then
CFLAGS+=(--coverage)
CXXFLAGS+=(--coverage)
LDFLAGS+=(--coverage)
opts+=(--enable-coverage)
fi
if [[ "$SANITIZE" == "yes" ]]; then
@ -104,6 +102,11 @@ for phase in "${PHASES[@]}"; do
CXXFLAGS+=(-shared-libasan)
fi
if [[ "$HOST_TRIPLET" != "" ]]; then
opts+=(--host "$HOST_TRIPLET")
fi
git config --global --add safe.directory "$PWD"
git clean -xdf
./autogen.sh
@ -123,9 +126,9 @@ for phase in "${PHASES[@]}"; do
ninja -C build
;;
CODECHECK)
make checklibdoc
make checkxalloc
;;
make checklibdoc
make checkxalloc
;;
CHECK)
if [[ "$SANITIZE" == "yes" ]]; then
# All the following black magic is to make test/eject/umount work, since
@ -157,6 +160,20 @@ for phase in "${PHASES[@]}"; do
fi
fi
if [[ "$COVERAGE" == "yes" ]]; then
# Make (almost) everything under current directory readable/writable
# for everyone to allow gcov to write the .gcda files even with
# dropped privileges
find . tests/helpers/ -maxdepth 1 -type d ! -name . ! -name tests \
-exec setfacl -R -m 'd:g::rwX,d:o::rwX' -m 'g::rwX,o::rwX' '{}' \;
# Make sure we can access $PWD as an unpriv user
path="$PWD"
while [[ "$path" != / ]]; do
chmod o+rx "$path"
path="$(dirname "$path")"
done
fi
./tests/run.sh --show-diff
if [[ "$COVERAGE" == "yes" ]]; then

View file

@ -20,14 +20,18 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ toJSON(matrix.env) }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
env:
- { COMPILER: "gcc", COMPILER_VERSION: "10", SANITIZE: "yes" }
- { COMPILER: "gcc", COMPILER_VERSION: "10", SANITIZE: "no" }
- { COMPILER: "clang", COMPILER_VERSION: "15", SANITIZE: "yes" }
- { COMPILER: "clang", COMPILER_VERSION: "15", SANITIZE: "no" }
# gcc-13 has false-positives with ubsan
- { COMPILER: "gcc", COMPILER_VERSION: "11", SANITIZE: "yes" }
- { COMPILER: "gcc", COMPILER_VERSION: "13", SANITIZE: "no" }
- { COMPILER: "clang", COMPILER_VERSION: "16", SANITIZE: "yes" }
- { COMPILER: "clang", COMPILER_VERSION: "16", SANITIZE: "no" }
env: ${{ matrix.env }}
steps:
- name: Repository checkout
@ -44,13 +48,16 @@ jobs:
run: sudo -E .github/workflows/cibuild.sh CHECK
- name: Make install
run: .github/workflows/cibuild.sh INSTALL
coveralls:
permissions:
contents: read # to fetch code (actions/checkout)
checks: write # to create new checks (coverallsapp/github-action)
runs-on: ubuntu-latest
if: github.repository == 'util-linux/util-linux'
concurrency:
group: ${{ github.workflow }}-coveralls-${{ github.ref }}
cancel-in-progress: true
env:
COMPILER: gcc
COMPILER_VERSION: 10
@ -70,9 +77,13 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage.info
meson:
needs: build
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-meson-${{ github.ref }}
cancel-in-progress: true
env:
COMPILER: gcc
COMPILER_VERSION: 10
@ -86,9 +97,13 @@ jobs:
run: .github/workflows/cibuild.sh MESONCONF
- name: Meson build
run: .github/workflows/cibuild.sh MESONBUILD
distcheck:
needs: build
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-distcheck-${{ github.ref }}
cancel-in-progress: true
env:
COMPILER: gcc
COMPILER_VERSION: 10
@ -103,9 +118,42 @@ jobs:
run: .github/workflows/cibuild.sh CONFIGURE
- name: Make distcheck
run: .github/workflows/cibuild.sh DISTCHECK
build-compat:
strategy:
fail-fast: false
matrix:
include:
- image: ubuntu:18.04
name: build (compat, ${{ matrix.image }})
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-build-compat-${{ github.ref }}
cancel-in-progress: true
env:
COMPILER: none
container:
image: ${{ matrix.image }}
steps:
- name: Repository checkout
uses: actions/checkout@v1
- name: Ubuntu setup
run: .github/workflows/cibuild-setup-ubuntu.sh
- name: Configure
run: .github/workflows/cibuild.sh CONFIGURE
- name: Code checks
run: .github/workflows/cibuild.sh CODECHECK
- name: Configure & Make
run: .github/workflows/cibuild.sh MAKE
- name: Check
run: .github/workflows/cibuild.sh CHECK
build-arch:
name: build (qemu-user, ${{ matrix.arch }})
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ toJSON(matrix) }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
@ -133,3 +181,55 @@ jobs:
.github/workflows/cibuild.sh CONFIGURE MAKE
# Check
.github/workflows/cibuild.sh CHECK
build-openwrt:
name: build (openwrt, ${{ matrix.target }})
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ toJSON(matrix) }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
include:
- target: ipq40xx
subtarget: generic
abi: musl_eabi
- target: ath79
subtarget: generic
abi: musl
- target: bcm63xx
subtarget: generic
abi: musl
- target: mpc85xx
subtarget: p2020
abi: musl
- target: archs38
subtarget: generic
abi: glibc
env:
COMPILER: none
steps:
- name: Repository checkout
uses: actions/checkout@v1
- name: Ubuntu setup
run: sudo -E .github/workflows/cibuild-setup-ubuntu.sh
- name: OpenWrt environment
run: |
OPENWRT_RELEASE=22.03.5
OPENWRT_SDK=openwrt-sdk-$OPENWRT_RELEASE-${{ matrix.target }}-${{ matrix.subtarget }}_gcc-11.2.0_${{ matrix.abi }}.Linux-x86_64
echo "COMPILER=$COMPILER" >> $GITHUB_ENV
echo "OPENWRT_RELEASE=$OPENWRT_RELEASE" >> $GITHUB_ENV
echo "OPENWRT_SDK=$OPENWRT_SDK" >> $GITHUB_ENV
- name: Download toolchain
run: |
curl -o ~/${{ env.OPENWRT_SDK }}.tar.xz -C - https://downloads.cdn.openwrt.org/releases/${{ env.OPENWRT_RELEASE }}/targets/${{ matrix.target }}/${{ matrix.subtarget }}/${{ env.OPENWRT_SDK }}.tar.xz
tar xf ~/${{ env.OPENWRT_SDK }}.tar.xz -C ~
- name: Configure
run: |
source .github/workflows/openwrt-sdk-env.sh ~/${{ env.OPENWRT_SDK }}
.github/workflows/cibuild.sh CONFIGURE
- name: Make
run: |
source .github/workflows/openwrt-sdk-env.sh ~/${{ env.OPENWRT_SDK }}
.github/workflows/cibuild.sh MAKE

View file

@ -23,6 +23,9 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'util-linux/util-linux'
concurrency:
group: ${{ github.workflow }}-${{ matrix.sanitizer }}-${{ matrix.architecture }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:

17
.github/workflows/openwrt-sdk-env.sh vendored Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
sdk="$(realpath $1)"
STAGING_DIR="$(echo "$sdk"/staging_dir/toolchain-*)"
. "$STAGING_DIR/info.mk"
PATH="$sdk/staging_dir/host/bin:$PATH"
CC="$STAGING_DIR/bin/${TARGET_CROSS}gcc"
BISON_PKGDATADIR="$sdk/staging_dir/host/share/bison"
M4="$sdk/staging_dir/host/bin/m4"
HOST_TRIPLET="$("$CC" -dumpmachine)"
echo "Building for $HOST_TRIPLET from $sdk"
export STAGING_DIR PATH CC BISON_PKGDATADIR M4 HOST_TRIPLET

12
.gitignore vendored
View file

@ -46,6 +46,10 @@ config/test-driver
configure
cscope.out
depcomp
GPATH
GRTAGS
GTAGS
GSYMS
INSTALL
install-sh
libtool
@ -58,22 +62,20 @@ mkinstalldirs
stamp-h
stamp-h.in
stamp-h1
syscalls.h
tags
test-suite.log
tests/run.sh.log
tests/run.sh.trs
update.log
ylwrap
GPATH
GRTAGS
GTAGS
GSYMS
#
# binaries
#
/addpart
/agetty
/build*/
/blkdiscard
/blkid
/blkpr
@ -95,6 +97,7 @@ GSYMS
/delpart
/dmesg
/eject
/enosys
/fadvise
/fallocate
/fdformat
@ -197,4 +200,3 @@ GSYMS
/wipefs
/write
/zramctl
/build*/

View file

@ -17,9 +17,14 @@ AM_CPPFLAGS += \
endif
endif
if WITH_COVERAGE
AM_CPPFLAGS += \
-include $(top_srcdir)/include/coverage.h
endif
AM_CFLAGS = -fsigned-char $(WARN_CFLAGS)
AM_CXXFLAGS = $(AM_CFLAGS)
AM_LDFLAGS = $(ASAN_LDFLAGS) $(UBSAN_LDFLAGS) $(FUZZING_ENGINE_LDFLAGS)
AM_LDFLAGS = $(ASAN_LDFLAGS) $(UBSAN_LDFLAGS) $(FUZZING_ENGINE_LDFLAGS) $(COVERAGE_LDFLAGS)
# Add gettext stuff to the global LDADD for systems with separate libintl
# library. The LTLIBINTL is generated by AM_GNU_GETTEXT macro.
@ -230,10 +235,13 @@ asciidoc_man_cmd = $(ASCIIDOCTOR) \
-a 'package-docdir=$(docdir)' \
-a 'VERSION=$(VERSION)' \
-a 'ADJTIME_PATH=$(ADJTIME_PATH)' \
--failure-level ERROR \
--load-path '$(abs_srcdir)/tools' \
--require asciidoctor-includetracker
if HAVE_ASCIIDOCTOR_FAILURE_LEVEL
asciidoc_man_cmd += --failure-level ERROR
endif
SUFFIXES = .1.adoc .3.adoc .5.adoc .8.adoc .1 .3 .5 .8
.1.adoc.1 .3.adoc.3 .5.adoc.5 .8.adoc.8:
$(AM_V_GEN) test -f ./$@ || \

View file

@ -344,5 +344,11 @@ endif
if BUILD_WAITPID
dist_bashcompletion_DATA += bash-completion/waitpid
endif
if BUILD_ENOSYS
dist_bashcompletion_DATA += bash-completion/enosys
endif
if BUILD_LSCLOCKS
dist_bashcompletion_DATA += bash-completion/lsclocks
endif
endif # BUILD_BASH_COMPLETION

View file

@ -13,6 +13,7 @@ _blockdev_module()
--getro
--getdiscardzeroes
--getdiskseq
--getzonesz
--getss
--getpbsz
--getiomin

37
bash-completion/enosys Normal file
View file

@ -0,0 +1,37 @@
_waitpid_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-s'|'--syscall')
return 0
;;
'-l'|'--list')
return 0
;;
'-h'|'--help'|'-V'|'--version')
return 0
;;
esac
case $cur in
-*)
OPTS="--syscall
--list
--help
--version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
*)
_pids
return 0
;;
esac
local IFS=$'\n'
compopt -o filenames
COMPREPLY=( $(compgen -u -- $cur) )
return 0
}
complete -F _enosys_module enosys

View file

@ -28,6 +28,7 @@ _hexdump_module()
case $cur in
-*)
OPTS=" --one-byte-octal
--one-byte-hex
--one-byte-char
--canonical
--two-bytes-decimal

View file

@ -54,6 +54,8 @@ _hwclock_module()
--epoch
--param-get
--param-set
--vl-read
--vl-clear
--update-drift
--noadjfile
--adjfile

48
bash-completion/lsclocks Normal file
View file

@ -0,0 +1,48 @@
_lsclocks_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-J'|'--json')
return 0
;;
'-n'|'--noheadings')
return 0
;;
'-o'|'--output')
return 0
;;
'-r'|'--raw')
return 0
;;
'-t'|'--time')
clocks="$(command "$1" --noheadings --raw --output NAME)"
COMPREPLY=( $(compgen -W "$clocks" -- "$cur") )
return 0
;;
'-h'|'--help'|'-V'|'--version')
return 0
;;
esac
case $cur in
-*)
OPTS="--json
--noheadings
--output
--raw
--time
--help
--version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
*)
return 0
;;
esac
return 0
}
complete -F _lsclocks_module lsclocks

View file

@ -21,13 +21,17 @@ _mkswap_module()
COMPREPLY=( $(compgen -W "$(uuidgen -r)" -- $cur) )
return 0
;;
'-o'|'--offset')
COMPREPLY=( $(compgen -W "bytes" -- $cur) )
return 0
;;
'-h'|'--help'|'-V'|'--version')
return 0
;;
esac
case $cur in
-*)
OPTS="--check --force --pagesize --lock --label --swapversion --uuid --verbose --version --help"
OPTS="--check --force --pagesize --lock --label --swapversion --uuid --offset --verbose --version --help"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;

View file

@ -42,9 +42,11 @@ _nsenter_module()
--pid=
--cgroup=
--user=
--user-parent
--time=
--setuid
--setgid
--keep-caps
--preserve-credentials
--root=
--wd=

View file

@ -215,6 +215,17 @@ AC_PROG_CXX
AM_CONDITIONAL([FUZZING_ENGINE], [test "x$enable_fuzzing_engine" = xyes])
AM_CONDITIONAL([OSS_FUZZ], [test "x$LIB_FUZZING_ENGINE" != x])
AC_ARG_ENABLE([coverage],
AS_HELP_STRING([--enable-coverage], [compile with gcov]),
[], [enable_coverage=no]
)
AS_IF([test "x$enable_coverage" = xyes], [
UL_WARN_ADD([--coverage])
COVERAGE_LDFLAGS="--coverage"
])
AC_SUBST([COVERAGE_LDFLAGS])
AM_CONDITIONAL([WITH_COVERAGE], [test "x$enable_coverage" = xyes])
dnl libtool-2
LT_INIT
@ -729,6 +740,9 @@ AS_IF([test x"$have_dirfd" = xno], [
AM_CONDITIONAL([HAVE_DIRFD], [test "x$have_dirfd" = xyes || test "x$have_ddfd" = xyes])
MQ_LIBS=
AC_CHECK_LIB([rt], [mq_open], [MQ_LIBS="-lrt"])
AC_SUBST([MQ_LIBS])
AC_MSG_CHECKING([whether program_invocation_short_name is defined])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@ -802,6 +816,17 @@ AC_ARG_ENABLE([asciidoc],
UL_BUILD_INIT([asciidoc])
UL_REQUIRES_PROGRAM([asciidoc], [ASCIIDOCTOR], [asciidoctor], [man pages])
AM_CONDITIONAL([ENABLE_ASCIIDOC], [test "x$build_asciidoc" = xyes])
have_asciidoctor_failure_level=no
AS_IF([test "x$build_asciidoc" = xyes], [
AC_MSG_CHECKING([whether ${ASCIIDOCTOR} supports --failure-level])
AS_IF([${ASCIIDOCTOR} --help | grep failure-level >/dev/null 2>&1 ], [
AC_MSG_RESULT([yes])
have_asciidoctor_failure_level=yes
], [
AC_MSG_RESULT([no])
])
])
AM_CONDITIONAL([HAVE_ASCIIDOCTOR_FAILURE_LEVEL], [test "x$have_asciidoctor_failure_level" = xyes])
have_manpages=no
AS_IF([test -f "$srcdir/sys-utils/mount.8"], [
@ -1847,10 +1872,31 @@ UL_BUILD_INIT([fadvise], [check])
UL_REQUIRES_LINUX([fadvise])
AM_CONDITIONAL([BUILD_FADVISE], [test "x$build_fadvise" = xyes])
UL_BUILD_INIT([waitpid], [check])
AC_ARG_ENABLE([waitpid],
AS_HELP_STRING([--disable-waitpid], [do not build waitpid]),
[], [UL_DEFAULT_ENABLE([waitpid], [check])]
)
UL_BUILD_INIT([waitpid])
UL_REQUIRES_LINUX([waitpid])
UL_REQUIRES_SYSCALL_CHECK([waitpid], [UL_CHECK_SYSCALL([pidfd_open])], [pidfd_open])
AM_CONDITIONAL([BUILD_WAITPID], [test "x$build_waitpid" = xyes])
UL_BUILD_INIT([enosys], [check])
UL_REQUIRES_LINUX([enosys])
AS_IF([test "x$build_enosys" = xyes], [
AC_MSG_CHECKING([for valid audit arch])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include "${srcdir}/include/audit-arch.h"]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
build_enosys=no
])
])
AM_CONDITIONAL([BUILD_ENOSYS], [test "x$build_enosys" = xyes])
UL_BUILD_INIT([lsclocks], [yes])
AM_CONDITIONAL([BUILD_LSCLOCKS], [test "x$build_lsclocks" = xyes])
UL_BUILD_INIT([getopt], [yes])
AM_CONDITIONAL([BUILD_GETOPT], [test "x$build_getopt" = xyes])
@ -2859,7 +2905,8 @@ AC_MSG_RESULT([
ldflags: ${LDFLAGS}
suid ldflags: ${SUID_LDFLAGS}
ASAN enabled: ${enable_asan}
Fuzzing enabled: ${enable_fuzzing_engine}
Fuzzing enabled: ${enable_fuzzing_engine}
Coverage enabled ${enable_coverage}
cflags: ${CFLAGS}

View file

@ -157,7 +157,9 @@ fdisk_SOURCES = \
disk-utils/fdisk.h \
disk-utils/fdisk-menu.c \
disk-utils/fdisk-list.c \
disk-utils/fdisk-list.h
disk-utils/fdisk-list.h \
include/pager.h \
lib/pager.c
fdisk_LDADD = $(LDADD) libcommon.la libfdisk.la \
libsmartcols.la libtcolors.la $(READLINE_LIBS)

View file

@ -60,6 +60,9 @@ Get discard zeroes support status.
*--getdiskseq*::
Get disk sequence number.
*--getzonesz*::
Get zone size in 512-byte sectors.
*--getfra*::
Get filesystem readahead in 512-byte sectors.

View file

@ -10,6 +10,9 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#ifdef HAVE_LINUX_BLKZONED_H
#include <linux/blkzoned.h>
#endif
#include "c.h"
#include "nls.h"
@ -175,6 +178,14 @@ static const struct bdc bdcms[] =
.argval = -1,
.help = N_("get disk sequence number")
},{
#ifdef BLKGETZONESZ
IOCTL_ENTRY(BLKGETZONESZ),
.name = "--getzonesz",
.argtype = ARG_UINT,
.argval = -1,
.help = N_("get zone size")
},{
#endif
IOCTL_ENTRY(BLKFLSBUF),
.name = "--flushbufs",
.help = N_("flush buffers")

View file

@ -1,7 +1,7 @@
/*
* cfdisk.c - Display or manipulate a disk partition table.
*
* Copyright (C) 2014-2015 Karel Zak <kzak@redhat.com>
* Copyright (C) 2014-2023 Karel Zak <kzak@redhat.com>
* Copyright (C) 1994 Kevin E. Martin (martin@cs.unc.edu)
*
* The original cfdisk was inspired by the fdisk program
@ -21,6 +21,7 @@
#include <assert.h>
#include <libsmartcols.h>
#include <sys/ioctl.h>
#include <rpmatch.h>
#include <libfdisk.h>
#ifdef HAVE_LIBMOUNT
@ -2256,7 +2257,8 @@ static int ui_help(void)
" ",
N_("Command Meaning"),
N_("------- -------"),
N_(" b Toggle bootable flag of the current partition"),
N_(" b Toggle bootable flag of the current partition;"),
N_(" implemented for DOS (MBR) and SGI labels only"),
N_(" d Delete the current partition"),
N_(" h Print this screen"),
N_(" n Create new partition from free space"),
@ -2280,7 +2282,7 @@ static int ui_help(void)
N_("Use lsblk(8) or partx(8) to see more details about the device."),
" ",
" ",
"Copyright (C) 2014-2017 Karel Zak <kzak@redhat.com>"
"Copyright (C) 2014-2023 Karel Zak <kzak@redhat.com>"
};
erase();
@ -2523,11 +2525,15 @@ static int main_menu_action(struct cfdisk *cf, int key)
if (rc)
warn = _("Failed to write disklabel.");
else {
size_t q_idx = 0;
if (cf->device_is_used)
fdisk_reread_changes(cf->cxt, cf->original_layout);
else
fdisk_reread_partition_table(cf->cxt);
info = _("The partition table has been altered.");
if (menu_get_menuitem_by_key(cf, 'q', &q_idx))
ui_menu_goto(cf, q_idx);
}
cf->nwrites++;
break;
@ -2587,11 +2593,17 @@ static int ui_run(struct cfdisk *cf)
DBG(UI, ul_debug("start cols=%zu, lines=%zu", ui_cols, ui_lines));
if (fdisk_get_collision(cf->cxt)) {
ui_warnx(_("Device already contains a %s signature; it will be removed by a write command."),
fdisk_get_collision(cf->cxt));
fdisk_enable_wipe(cf->cxt, 1);
ui_hint(_("Press a key to continue."));
getch();
ui_warnx(_("Device already contains a %s signature."), fdisk_get_collision(cf->cxt));
if (fdisk_is_readonly(cf->cxt)) {
ui_hint(_("Press a key to continue."));
getch();
} else {
char buf[64] = { 0 };
rc = ui_get_string(_("Do you want to remove it? [Y]es/[N]o: "), NULL,
buf, sizeof(buf));
fdisk_enable_wipe(cf->cxt,
rc > 0 && rpmatch(buf) == RPMATCH_YES ? 1 : 0);
}
}
if (!fdisk_has_label(cf->cxt) || cf->zero_start) {

View file

@ -20,7 +20,7 @@ fsck - check and repair a Linux filesystem
== DESCRIPTION
*fsck* is used to check and optionally repair one or more Linux filesystems. _filesystem_ can be a device name (e.g., _/dev/hdc1_, _/dev/sdb2_), a mount point (e.g., _/_, _/usr_, _/home_), or an filesystem label or UUID specifier (e.g., UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root). Normally, the *fsck* program will try to handle filesystems on different physical disk drives in parallel to reduce the total amount of time needed to check all of them.
*fsck* is used to check and optionally repair one or more Linux filesystems. _filesystem_ can be a device name (e.g., _/dev/hdc1_, _/dev/sdb2_), a mount point (e.g., _/_, _/usr_, _/home_), or a filesystem label or UUID specifier (e.g., UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root). Normally, the *fsck* program will try to handle filesystems on different physical disk drives in parallel to reduce the total amount of time needed to check all of them.
If no filesystems are specified on the command line, and the *-A* option is not specified, *fsck* will default to checking filesystems in _/etc/fstab_ serially. This is equivalent to the *-As* options.

View file

@ -69,7 +69,8 @@ fdisk_sources = files(
'fdisk.h',
'fdisk-menu.c',
'fdisk-list.c',
'fdisk-list.h')
'fdisk-list.h') + \
pager_c
sfdisk_sources = files(
'sfdisk.c',

View file

@ -157,9 +157,9 @@ static void __attribute__((__noreturn__)) usage(void)
static inline time_t mkfs_minix_time(time_t *t)
{
const char *str = getenv("MKFS_MINIX_TEST_SECOND_SINCE_EPOCH");
time_t sec;
uint64_t sec;
if (str && sscanf(str, "%ld", &sec) == 1)
if (str && sscanf(str, "%"SCNd64, &sec) == 1)
return sec;
return time(t);
}

View file

@ -73,6 +73,9 @@ generate a new time-based UUID
*-e*, *--endianness* _ENDIANNESS_::
Specify the _ENDIANNESS_ to use, valid arguments are *native*, *little* or *big*. The default is *native*.
*-o*, *--offset* _offset_::
Specify the _offset_ to write the swap area to.
*-v*, *--swapversion 1*::
Specify the swap-space version. (This option is currently pointless, as the old *-v 0* option has become obsolete and now only *-v 1* is supported. The kernel has not supported v0 swap-space format since 2.5.22 (June 2002). The new version v1 is supported since 2.1.117 (August 1998).)

View file

@ -76,6 +76,7 @@ struct mkswap_control {
int user_pagesize; /* --pagesize */
int pagesize; /* final pagesize used for the header */
off_t offset; /* offset of the header in the target */
char *opt_label; /* LABEL as specified on command line */
unsigned char *uuid; /* UUID parsed by libbuuid */
@ -194,6 +195,7 @@ static void __attribute__((__noreturn__)) usage(void)
fprintf(out,
_(" -e, --endianness=<value> specify the endianness to use "
"(%s, %s or %s)\n"), "native", "little", "big");
fputs(_(" -o, --offset OFFSET specify the offset in the device\n"), out);
fputs(_(" --verbose verbose output\n"), out);
fprintf(out,
@ -347,6 +349,9 @@ static unsigned long long get_size(const struct mkswap_control *ctl)
err(EXIT_FAILURE, _("cannot open %s"), ctl->devname);
if (blkdev_get_size(fd, &size) < 0)
err(EXIT_FAILURE, _("cannot determine size of %s"), ctl->devname);
if ((unsigned long long) ctl->offset > size)
errx(EXIT_FAILURE, _("offset larger than file size"));
size -= ctl->offset;
size /= ctl->pagesize;
close(fd);
@ -465,11 +470,15 @@ static void wipe_device(struct mkswap_control *ctl)
static void write_header_to_device(struct mkswap_control *ctl)
{
off_t offset;
assert(ctl);
assert(ctl->fd > -1);
assert(ctl->signature_page);
if (lseek(ctl->fd, SIGNATURE_OFFSET, SEEK_SET) != SIGNATURE_OFFSET)
offset = SIGNATURE_OFFSET + ctl->offset;
if (lseek(ctl->fd, offset, SEEK_SET) != offset)
errx(EXIT_FAILURE, _("unable to rewind swap-device"));
if (write_all(ctl->fd, (char *) ctl->signature_page + SIGNATURE_OFFSET,
@ -503,6 +512,7 @@ int main(int argc, char **argv)
{ "swapversion", required_argument, NULL, 'v' },
{ "uuid", required_argument, NULL, 'U' },
{ "endianness", required_argument, NULL, 'e' },
{ "offset", required_argument, NULL, 'o' },
{ "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{ "lock", optional_argument, NULL, OPT_LOCK },
@ -521,7 +531,7 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
close_stdout_atexit();
while((c = getopt_long(argc, argv, "cfp:qL:v:U:e:Vh", longopts, NULL)) != -1) {
while((c = getopt_long(argc, argv, "cfp:qL:v:U:e:o:Vh", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@ -567,6 +577,10 @@ int main(int argc, char **argv)
_("invalid endianness %s is not supported"), optarg);
}
break;
case 'o':
ctl.offset = str2unum_or_err(optarg,
10, _("Invalid offset"), SINT_MAX(off_t));
break;
case 'V':
print_version(EXIT_SUCCESS);
break;

View file

@ -75,14 +75,14 @@ enum {
/* column names */
struct colinfo {
const char *name; /* header */
double whint; /* width hint (N < 1 is in percent of termwidth) */
int flags; /* SCOLS_FL_* */
const char *help;
const char * const name; /* header */
double whint; /* width hint (N < 1 is in percent of termwidth) */
int flags; /* SCOLS_FL_* */
const char *help;
};
/* columns descriptions */
static struct colinfo infos[] = {
static const struct colinfo infos[] = {
[COL_PARTNO] = { "NR", 0.25, SCOLS_FL_RIGHT, N_("partition number") },
[COL_START] = { "START", 0.30, SCOLS_FL_RIGHT, N_("start of the partition in sectors") },
[COL_END] = { "END", 0.30, SCOLS_FL_RIGHT, N_("end of the partition in sectors") },
@ -141,7 +141,7 @@ static inline int get_column_id(int num)
return columns[num];
}
static inline struct colinfo *get_column_info(int num)
static inline const struct colinfo *get_column_info(int num)
{
return &infos[ get_column_id(num) ];
}
@ -674,7 +674,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
scols_table_enable_noheadings(table, !!(scols_flags & PARTX_NOHEADINGS));
for (i = 0; (size_t)i < ncolumns; i++) {
struct colinfo *col = get_column_info(i);
const struct colinfo *col = get_column_info(i);
if (!scols_table_new_column(table, col->name, col->whint, col->flags)) {
warnx(_("failed to allocate output column"));

View file

@ -366,6 +366,8 @@ ____
*sfdisk /dev/sda < sda.dump*
____
Note that sfdisk completely restores partition types and partition UUIDs. This could potentially become problematic if you duplicate the same layout to different disks, as it may result in duplicate UUIDs within your system.
=== Full binary backup
If you want to do a full binary backup of all sectors where the partition table is stored, then use the *--backup-pt-sectors* command. It writes the sectors to _~/sfdisk-<device>-<offset>.bak_ files. The default name of the backup file can be changed with the *--backup-file* option. The backup files contain only raw data from the _device_. For example:

View file

@ -1,6 +1,7 @@
dist_noinst_HEADERS += \
include/all-io.h \
include/audit-arch.h \
include/bitops.h \
include/blkdev.h \
include/buffer.h \
@ -12,6 +13,7 @@ dist_noinst_HEADERS += \
include/closestream.h \
include/colors.h \
include/color-names.h \
include/coverage.h \
include/cpuset.h \
include/crc32.h \
include/crc32c.h \

64
include/audit-arch.h Normal file
View file

@ -0,0 +1,64 @@
/*
* Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
*
* This file may be distributed under the terms of the
* GNU Lesser General Public License.
*/
#ifndef UTIL_LINUX_AUDIT_ARCH_H
#define UTIL_LINUX_AUDIT_ARCH_H
#if __x86_64__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_X86_64
#elif __i386__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_I386
#elif __arm__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARM
#elif __aarch64__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_AARCH64
#elif __riscv
# if __riscv_xlen == 32
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_RISCV32
# elif __riscv_xlen == 64
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_RISCV64
# endif
#elif __s390x__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_S390X
#elif __s390__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_S390
#elif __PPC64__
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC64
# else
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC64LE
# endif
#elif __powerpc__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC
#elif __mips__
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_MIPS
# else
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_MIPSEL
# endif
#elif __arc__
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARCV2BE
# else
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARCV2
# endif
#elif __sparc__
# if __SIZEOF_POINTER__ == 4
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_SPARC
# else
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_SPARC64
# endif
#elif __loongarch__
# if __SIZEOF_POINTER__ == 4
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_LOONGARCH32
# else
# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_LOONGARCH64
# endif
#else
# error Unknown target architecture
#endif
#endif /* UTIL_LINUX_AUDIT_ARCH_H */

View file

@ -31,7 +31,7 @@
# define be16toh(x) betoh16(x)
# define be32toh(x) betoh32(x)
# define be64toh(x) betoh64(x)
#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__NetBSD__) || defined(__DragonFly__)
# define bswap_16(x) bswap16(x)
# define bswap_32(x) bswap32(x)
# define bswap_64(x) bswap64(x)

View file

@ -294,6 +294,9 @@ void __err_oom(const char *file, unsigned int line)
}
#define err_oom() __err_oom(__FILE__, __LINE__)
#define err_nosys(exitcode, ...) \
err(errno == ENOSYS ? EXIT_NOTSUPP : exitcode, __VA_ARGS__)
/* Don't use inline function to avoid '#include "nls.h"' in c.h
*/

View file

@ -31,4 +31,6 @@ extern int capget(cap_user_header_t header, const cap_user_data_t data);
extern int cap_last_cap(void);
extern void cap_permitted_to_ambient(void);
#endif /* CAPUTILS_H */

View file

@ -1,8 +1,8 @@
/*
* Copyright (C) 2012-2015 Karel Zak <kzak@redhat.com>
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*
* This file may be distributed under the terms of the
* GNU Lesser General Public License.
* Copyright (C) 2012-2015 Karel Zak <kzak@redhat.com>
*/
#ifndef UTIL_LINUX_COLOR_NAMES_H
#define UTIL_LINUX_COLOR_NAMES_H

View file

@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* Copyright (C) 2012 Ondrej Oprala <ooprala@redhat.com>
* Copyright (C) 2012-2014 Karel Zak <kzak@redhat.com>
*

25
include/coverage.h Normal file
View file

@ -0,0 +1,25 @@
/*
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*/
#ifndef UTIL_LINUX_COVERAGE_H
#define UTIL_LINUX_COVERAGE_H
/* When built with --coverage (gcov) we need to explicitly call __gcov_dump()
* in places where we use _exit(), since _exit() skips at-exit hooks resulting
* in lost coverage.
*
* To make sure we don't miss any _exit() calls, this header file is included
* explicitly on the compiler command line via the -include directive (only
* when built with --coverage/-Db_coverage=true)
*/
void __gcov_dump(void);
void _exit(int);
__attribute__((noreturn)) static inline void _coverage__exit(int status) {
__gcov_dump();
_exit(status);
}
#define _exit(x) _coverage__exit(x)
#endif

View file

@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This file may be redistributed under the terms of the
* GNU Lesser General Public License.
*/

View file

@ -1,3 +1,7 @@
/* SPDX-License-Identifier: MIT
*
* This file is licensed under the MIT License.
*/
#ifndef UL_CRC64_H
#define UL_CRC64_H

View file

@ -1,3 +1,7 @@
/*
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*/
#ifndef UTIL_LINUX_ENV_H
#define UTIL_LINUX_ENV_H

View file

@ -1,19 +1,15 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2010 Free Software Foundation, Inc.
Copyright (C) 2010-2013 Karel Zak <kzak@redhat.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* Align/Truncate a string in a given screen width
* Copyright (C) 2009-2010 Free Software Foundation, Inc.
* Copyright (C) 2010-2013 Karel Zak <kzak@redhat.com>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*/
#ifndef UTIL_LINUX_MBSALIGN_H
# define UTIL_LINUX_MBSALIGN_H
# include <stddef.h>

View file

@ -19,7 +19,7 @@ struct dos_partition {
#define MBR_PT_OFFSET 0x1be
#define MBR_PT_BOOTBITS_SIZE 440
static inline struct dos_partition *mbr_get_partition(unsigned char *mbr, int i)
static inline struct dos_partition *mbr_get_partition(const unsigned char *mbr, int i)
{
return (struct dos_partition *)
(mbr + MBR_PT_OFFSET + (i * sizeof(struct dos_partition)));
@ -42,7 +42,7 @@ static inline void __dos_store_4le(unsigned char *p, unsigned int val)
p[3] = ((val >> 24) & 0xff);
}
static inline unsigned int dos_partition_get_start(struct dos_partition *p)
static inline unsigned int dos_partition_get_start(const struct dos_partition *p)
{
return __dos_assemble_4le(&(p->start_sect[0]));
}
@ -52,7 +52,7 @@ static inline void dos_partition_set_start(struct dos_partition *p, unsigned int
__dos_store_4le(p->start_sect, n);
}
static inline unsigned int dos_partition_get_size(struct dos_partition *p)
static inline unsigned int dos_partition_get_size(const struct dos_partition *p)
{
return __dos_assemble_4le(&(p->nr_sects[0]));
}

View file

@ -1,32 +1,24 @@
/***
SPDX-License-Identifier: LGPL-2.1-or-later
First set of functions in this file are part of systemd, and were
copied to util-linux at August 2013.
Copyright 2010 Lennart Poettering
Copyright (C) 2014 Karel Zak <kzak@redhat.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* First set of functions in this file are part of systemd, and were
* copied to util-linux at August 2013.
*
* Copyright 2010 Lennart Poettering
* Copyright (C) 2014 Karel Zak <kzak@redhat.com>
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*/
#ifndef UTIL_LINUX_TIME_UTIL_H
#define UTIL_LINUX_TIME_UTIL_H
#include <stdio.h>
#include <inttypes.h>
#include <sys/time.h>
#include <stdbool.h>
typedef uint64_t usec_t;
typedef uint64_t nsec_t;
@ -65,8 +57,10 @@ enum {
ISO_TIMEZONE = (1 << 2),
ISO_DOTUSEC = (1 << 3),
ISO_COMMAUSEC = (1 << 4),
ISO_T = (1 << 5),
ISO_GMTIME = (1 << 6),
ISO_DOTNSEC = (1 << 5),
ISO_COMMANSEC = (1 << 6),
ISO_T = (1 << 7),
ISO_GMTIME = (1 << 8),
ISO_TIMESTAMP = ISO_DATE | ISO_TIME | ISO_TIMEZONE,
ISO_TIMESTAMP_T = ISO_TIMESTAMP | ISO_T,
ISO_TIMESTAMP_DOT = ISO_TIMESTAMP | ISO_DOTUSEC,
@ -80,9 +74,10 @@ enum {
#define CTIME_BUFSIZ 26
#define ISO_BUFSIZ 42
int strtimeval_iso(struct timeval *tv, int flags, char *buf, size_t bufsz);
int strtm_iso(struct tm *tm, int flags, char *buf, size_t bufsz);
int strtimeval_iso(const struct timeval *tv, int flags, char *buf, size_t bufsz);
int strtm_iso(const struct tm *tm, int flags, char *buf, size_t bufsz);
int strtime_iso(const time_t *t, int flags, char *buf, size_t bufsz);
int strtimespec_iso(const struct timespec *t, int flags, char *buf, size_t bufsz);
#define UL_SHORTTIME_THISYEAR_HHMM (1 << 1)
@ -111,4 +106,9 @@ static inline struct timeval usec_to_timeval(usec_t t)
return r;
}
static inline bool is_timespecset(const struct timespec *t)
{
return t->tv_sec || t->tv_nsec;
}
#endif /* UTIL_LINUX_TIME_UTIL_H */

View file

@ -88,6 +88,7 @@ struct chardata {
extern int get_terminal_dimension(int *cols, int *lines);
extern int get_terminal_width(int default_width);
extern int get_terminal_type(const char **type);
extern char *get_terminal_default_type(const char *ttyname, int is_serial);
extern int get_terminal_stdfd(void);
extern int get_terminal_name(const char **path, const char **name,
const char **number);

View file

@ -46,6 +46,18 @@ void *xrealloc(void *ptr, const size_t size)
return ret;
}
static inline
__ul_calloc_size(2, 3)
__ul_returns_nonnull
void *xreallocarray(void *ptr, const size_t nelems, const size_t size)
{
void *ret = reallocarray(ptr, nelems, size);
if (!ret && size && nelems)
err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size);
return ret;
}
static inline
__ul_calloc_size(1, 2)
__ul_returns_nonnull

View file

@ -30,7 +30,6 @@ libcommon_la_SOURCES = \
lib/mbsalign.c \
lib/mbsedit.c\
lib/md5.c \
lib/pager.c \
lib/pwdutils.c \
lib/randutils.c \
lib/sha1.c \

View file

@ -24,6 +24,7 @@
#include "caputils.h"
#include "pathnames.h"
#include "procfs.h"
#include "nls.h"
static int test_cap(unsigned int cap)
{
@ -87,6 +88,43 @@ int cap_last_cap(void)
return cap;
}
void cap_permitted_to_ambient(void)
{
/* We use capabilities system calls to propagate the permitted
* capabilities into the ambient set because we may have
* already forked so be in async-signal-safe context. */
struct __user_cap_header_struct header = {
.version = _LINUX_CAPABILITY_VERSION_3,
.pid = 0,
};
struct __user_cap_data_struct payload[_LINUX_CAPABILITY_U32S_3] = {{ 0 }};
uint64_t effective, cap;
if (capget(&header, payload) < 0)
err(EXIT_FAILURE, _("capget failed"));
/* In order the make capabilities ambient, we first need to ensure
* that they are all inheritable. */
payload[0].inheritable = payload[0].permitted;
payload[1].inheritable = payload[1].permitted;
if (capset(&header, payload) < 0)
err(EXIT_FAILURE, _("capset failed"));
effective = ((uint64_t)payload[1].effective << 32) | (uint64_t)payload[0].effective;
for (cap = 0; cap < (sizeof(effective) * 8); cap++) {
/* This is the same check as cap_valid(), but using
* the runtime value for the last valid cap. */
if (cap > (uint64_t) cap_last_cap())
continue;
if ((effective & (1ULL << cap))
&& prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap, 0, 0) < 0)
err(EXIT_FAILURE, _("prctl(PR_CAP_AMBIENT) failed"));
}
}
#ifdef TEST_PROGRAM_CAPUTILS
int main(int argc, char *argv[])
{

View file

@ -2,7 +2,7 @@
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*
* Written by Karel Zak <kzak@redhat.com>
* Copyright (C) 2012-2015 Karel Zak <kzak@redhat.com>
*/
#include "c.h"
#include "color-names.h"

View file

@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* Copyright (C) 2012 Ondrej Oprala <ooprala@redhat.com>
* Copyright (C) 2012-2014 Karel Zak <kzak@redhat.com>
*

View file

@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* Terminology:
*
* cpuset - (libc) cpu_set_t data structure represents set of CPUs

View file

@ -580,7 +580,7 @@ static int loopcxt_next_from_sysfs(struct loopdev_cxt *lc)
/*
* @lc: context, has to initialized by loopcxt_init_iterator()
*
* Returns: 0 on success, -1 on error, 1 at the end of scanning. The details
* Returns: 0 on success, < 0 on error, 1 at the end of scanning. The details
* about the current loop device are available by
* loopcxt_get_{fd,backing_file,device,offset, ...} functions.
*/
@ -1602,6 +1602,8 @@ done:
* kernels we have to check all loop devices to found unused one.
*
* See kernel commit 770fe30a46a12b6fb6b63fbe1737654d28e8484.
*
* Returns: 0 = success, < 0 error
*/
int loopcxt_find_unused(struct loopdev_cxt *lc)
{
@ -1617,6 +1619,8 @@ int loopcxt_find_unused(struct loopdev_cxt *lc)
ctl = open(_PATH_DEV_LOOPCTL, O_RDWR|O_CLOEXEC);
if (ctl >= 0)
rc = ioctl(ctl, LOOP_CTL_GET_FREE);
else
rc = -errno;
if (rc >= 0) {
char name[16];
snprintf(name, sizeof(name), "loop%d", rc);
@ -1638,6 +1642,8 @@ int loopcxt_find_unused(struct loopdev_cxt *lc)
rc = loopcxt_next(lc);
loopcxt_deinit_iterator(lc);
DBG(CXT, ul_debugobj(lc, "find_unused by scan [rc=%d]", rc));
if (rc)
return -ENOENT;
}
return rc;
}
@ -1681,6 +1687,9 @@ char *loopdev_get_backing_file(const char *device)
return res;
}
/*
* Returns: TRUE/FALSE
*/
int loopdev_has_backing_file(const char *device)
{
char *tmp = loopdev_get_backing_file(device);
@ -1718,6 +1727,9 @@ int loopdev_is_used(const char *device, const char *filename,
return rc;
}
/*
* Returns: 0 = success, < 0 error
*/
int loopdev_delete(const char *device)
{
struct loopdev_cxt lc;

View file

@ -1,21 +1,16 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Pádraig Brady. */
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* Align/Truncate a string in a given screen width
* Copyright (C) 2009-2010 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*
* Written by Pádraig Brady.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

View file

@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* Very simple multibyte buffer editor. Allows to maintaine the current
* position in the string, add and remove chars on the current position.
*

View file

@ -17,7 +17,6 @@ lib_common_sources = '''
mbsalign.c
mbsedit.c
md5.c
pager.c
procfs.c
pwdutils.c
randutils.c
@ -37,6 +36,7 @@ md5_c = files('md5.c')
sha1_c = files('sha1.c')
strutils_c = files('strutils.c')
strv_c = files('strv.c')
pager_c = files('pager.c')
lib_common_sources += [idcache_c,
randutils_c,

View file

@ -1,4 +1,10 @@
/*
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*
* Copyright (C) 2018 Karel Zak <kzak@redhat.com>
*
*
* Simple functions to access files. Paths can be globally prefixed to read
* data from an alternative source (e.g. a /proc dump for regression tests).
*
@ -7,11 +13,6 @@
*
* The ul_path_read_* API is possible to use without path_cxt handler. In this
* case is not possible to use global prefix and printf-like formatting.
*
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*
* Written by Karel Zak <kzak@redhat.com> [February 2018]
*/
#include <stdarg.h>
#include <string.h>

View file

@ -2,7 +2,7 @@
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*
* Written by Karel Zak <kzak@redhat.com>
* Copyright (C) 2021 Karel Zak <kzak@redhat.com>
*/
#include <ctype.h>
#include <unistd.h>

View file

@ -21,8 +21,8 @@ extern int is_known_shell(const char *shell_name)
#if defined (HAVE_LIBECONF) && defined (USE_VENDORDIR)
size_t size = 0;
econf_err error;
char **keys;
econf_file *key_file;
char **keys = NULL;
econf_file *key_file = NULL;
error = econf_readDirs(&key_file,
_PATH_VENDORDIR,
@ -43,17 +43,18 @@ extern int is_known_shell(const char *shell_name)
syslog(LOG_ALERT,
_("Cannot evaluate entries in shells files: %s"),
econf_errString(error));
econf_free (key_file);
econf_free(key_file);
exit(EXIT_FAILURE);
}
for (size_t i = 0; i < size; i++) {
if (strcmp (keys[i], shell_name) == 0) {
if (strcmp(keys[i], shell_name) == 0) {
ret = 1;
break;
}
}
econf_free (key_file);
econf_free(keys);
econf_free(key_file);
#else
char *s;

View file

@ -397,7 +397,7 @@ int ul_strtou32(const char *str, uint32_t *num, int base)
* Convert strings to numbers in defined range and print message on error.
*
* These functions are used when we read input from users (getopt() etc.). It's
* better to consolidate the code and keep it all based on 64-bit numbers then
* better to consolidate the code and keep it all based on 64-bit numbers than
* implement it for 32 and 16-bit numbers too.
*/
int64_t str2num_or_err(const char *str, int base, const char *errmesg,

View file

@ -2,7 +2,7 @@
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*
* Written by Karel Zak <kzak@redhat.com>
* Copyright (C) 2011 Karel Zak <kzak@redhat.com>
*/
#include <ctype.h>
#include <libgen.h>

View file

@ -1,23 +1,17 @@
/***
First set of functions in this file are part of systemd, and were
copied to util-linux at August 2013.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with util-linux; If not, see <http://www.gnu.org/licenses/>.
***/
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* First set of functions in this file are part of systemd, and were
* copied to util-linux at August 2013.
*
* Copyright 2010 Lennart Poettering
* Copyright (C) 2014 Karel Zak <kzak@redhat.com>
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*/
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
@ -454,8 +448,9 @@ int get_gmtoff(const struct tm *tp)
#endif
}
static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf, size_t bufsz)
static int format_iso_time(const struct tm *tm, uint32_t nsec, int flags, char *buf, size_t bufsz)
{
uint32_t usec = nsec / NSEC_PER_USEC;
char *p = buf;
int len;
@ -485,15 +480,28 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf
p += len;
}
if (flags & ISO_DOTUSEC) {
len = snprintf(p, bufsz, ".%06"PRId64, (int64_t) usec);
if (flags & ISO_DOTNSEC) {
len = snprintf(p, bufsz, ".%09"PRIu32, nsec);
if (len < 0 || (size_t) len > bufsz)
goto err;
bufsz -= len;
p += len;
} else if (flags & ISO_COMMANSEC) {
len = snprintf(p, bufsz, ",%09"PRIu32, nsec);
if (len < 0 || (size_t) len > bufsz)
goto err;
bufsz -= len;
p += len;
} else if (flags & ISO_DOTUSEC) {
len = snprintf(p, bufsz, ".%06"PRIu32, usec);
if (len < 0 || (size_t) len > bufsz)
goto err;
bufsz -= len;
p += len;
} else if (flags & ISO_COMMAUSEC) {
len = snprintf(p, bufsz, ",%06"PRId64, (int64_t) usec);
len = snprintf(p, bufsz, ",%06"PRIu32, usec);
if (len < 0 || (size_t) len > bufsz)
goto err;
bufsz -= len;
@ -514,26 +522,37 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf
return -1;
}
/* timeval to ISO 8601 */
int strtimeval_iso(struct timeval *tv, int flags, char *buf, size_t bufsz)
/* timespec to ISO 8601 */
int strtimespec_iso(const struct timespec *ts, int flags, char *buf, size_t bufsz)
{
struct tm tm;
struct tm *rc;
if (flags & ISO_GMTIME)
rc = gmtime_r(&tv->tv_sec, &tm);
rc = gmtime_r(&ts->tv_sec, &tm);
else
rc = localtime_r(&tv->tv_sec, &tm);
rc = localtime_r(&ts->tv_sec, &tm);
if (rc)
return format_iso_time(&tm, tv->tv_usec, flags, buf, bufsz);
return format_iso_time(&tm, ts->tv_nsec, flags, buf, bufsz);
warnx(_("time %"PRId64" is out of range."), (int64_t)(tv->tv_sec));
warnx(_("time %"PRId64" is out of range."), (int64_t)(ts->tv_sec));
return -1;
}
/* timeval to ISO 8601 */
int strtimeval_iso(const struct timeval *tv, int flags, char *buf, size_t bufsz)
{
struct timespec ts = {
.tv_sec = tv->tv_sec,
.tv_nsec = tv->tv_usec * NSEC_PER_USEC,
};
return strtimespec_iso(&ts, flags, buf, bufsz);
}
/* struct tm to ISO 8601 */
int strtm_iso(struct tm *tm, int flags, char *buf, size_t bufsz)
int strtm_iso(const struct tm *tm, int flags, char *buf, size_t bufsz)
{
return format_iso_time(tm, 0, flags, buf, bufsz);
}

View file

@ -7,9 +7,40 @@
#include <ctype.h>
#include <unistd.h>
#ifdef HAVE_GETTTYNAM
# include <ttyent.h>
#endif
#include "c.h"
#include "ttyutils.h"
#ifdef __linux__
# ifndef DEFAULT_VCTERM
# define DEFAULT_VCTERM "linux"
# endif
# if defined (__s390__) || defined (__s390x__)
# define DEFAULT_TTYS0 "dumb"
# define DEFAULT_TTY32 "ibm327x"
# define DEFAULT_TTYS1 "vt220"
# endif
# ifndef DEFAULT_STERM
# define DEFAULT_STERM "vt102"
# endif
#elif defined(__GNU__)
# ifndef DEFAULT_VCTERM
# define DEFAULT_VCTERM "hurd"
# endif
# ifndef DEFAULT_STERM
# define DEFAULT_STERM "vt102"
# endif
#else
# ifndef DEFAULT_VCTERM
# define DEFAULT_VCTERM "vt100"
# endif
# ifndef DEFAULT_STERM
# define DEFAULT_STERM "vt100"
# endif
#endif
static int get_env_int(const char *name)
{
@ -130,6 +161,35 @@ int get_terminal_type(const char **type)
return 0;
}
char *get_terminal_default_type(const char *ttyname, int is_serial)
{
if (ttyname) {
#ifdef HAVE_GETTTYNAM
struct ttyent *ent = getttynam(ttyname);
if (ent && ent->ty_type)
return strdup(ent->ty_type);
#endif
#if defined (__s390__) || defined (__s390x__)
/*
* Special terminal on first serial line on a S/390(x) which
* is due legacy reasons a block terminal of type 3270 or
* higher. Whereas the second serial line on a S/390(x) is
* a real character terminal which is compatible with VT220.
*/
if (strcmp(ttyname, "ttyS0") == 0) /* linux/drivers/s390/char/con3215.c */
return strdup(DEFAULT_TTYS0);
else if (strncmp(ttyname, "3270/tty", 8) == 0) /* linux/drivers/s390/char/con3270.c */
return strdup(DEFAULT_TTY32);
else if (strcmp(ttyname, "ttyS1") == 0) /* linux/drivers/s390/char/sclp_vt220.c */
return strdup(DEFAULT_TTYS1);
#endif
}
return strdup(is_serial ? DEFAULT_STERM : DEFAULT_VCTERM);
}
#ifdef TEST_PROGRAM_TTYUTILS
# include <stdlib.h>
int main(void)
@ -138,13 +198,21 @@ int main(void)
int c, l;
if (get_terminal_name(&path, &name, &num) == 0) {
fprintf(stderr, "tty path: %s\n", path);
fprintf(stderr, "tty name: %s\n", name);
fprintf(stderr, "tty number: %s\n", num);
char *term;
fprintf(stderr, "tty path: %s\n", path);
fprintf(stderr, "tty name: %s\n", name);
fprintf(stderr, "tty number: %s\n", num);
fprintf(stderr, "tty term: %s\n", getenv("TERM"));
term = get_terminal_default_type(name, 0);
fprintf(stderr, "tty dflt term: %s\n", term);
free(term);
}
get_terminal_dimension(&c, &l);
fprintf(stderr, "tty cols: %d\n", c);
fprintf(stderr, "tty lines: %d\n", l);
fprintf(stderr, "tty cols: %d\n", c);
fprintf(stderr, "tty lines: %d\n", l);
return EXIT_SUCCESS;

View file

@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
* xxHash - Extremely Fast Hash algorithm
* Copyright (C) 2012-2020 Yann Collet
*

View file

@ -412,12 +412,12 @@ extern int blkdid_probe_is_opal_locked(blkid_probe pr)
__attribute__((nonnull))
__attribute__((warn_unused_result));
extern unsigned char *blkid_probe_get_buffer(blkid_probe pr,
extern const unsigned char *blkid_probe_get_buffer(blkid_probe pr,
uint64_t off, uint64_t len)
__attribute__((nonnull))
__attribute__((warn_unused_result));
extern unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector)
extern const unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector)
__attribute__((nonnull))
__attribute__((warn_unused_result));
@ -434,7 +434,7 @@ extern int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id,
__attribute__((nonnull(1)));
/* returns superblock according to 'struct blkid_idmag' */
extern unsigned char *blkid_probe_get_sb_buffer(blkid_probe pr, const struct blkid_idmag *mag, size_t size);
extern const unsigned char *blkid_probe_get_sb_buffer(blkid_probe pr, const struct blkid_idmag *mag, size_t size);
#define blkid_probe_get_sb(_pr, _mag, type) \
((type *) blkid_probe_get_sb_buffer((_pr), _mag, sizeof(type)))

View file

@ -47,7 +47,7 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag)
blkid_partition parent;
blkid_partlist ls;
int i, nparts = BSD_MAXPARTITIONS;
unsigned char *data;
const unsigned char *data;
int rc = BLKID_PROBE_NONE;
uint32_t abs_offset = 0;

View file

@ -34,7 +34,7 @@ static const struct dos_subtypes {
{ MBR_MINIX_PARTITION, &minix_pt_idinfo }
};
static inline int is_extended(struct dos_partition *p)
static inline int is_extended(const struct dos_partition *p)
{
return (p->sys_ind == MBR_DOS_EXTENDED_PARTITION ||
p->sys_ind == MBR_W95_EXTENDED_PARTITION ||
@ -46,7 +46,7 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
{
blkid_partlist ls = blkid_probe_get_partlist(pr);
uint32_t cur_start = ex_start, cur_size = ex_size;
unsigned char *data;
const unsigned char *data;
int ct_nodata = 0; /* count ext.partitions without data partitions */
int i;
@ -57,7 +57,7 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
}
while (1) {
struct dos_partition *p, *p0;
const struct dos_partition *p, *p0;
uint32_t start = 0, size;
if (++ct_nodata > 100)
@ -156,9 +156,9 @@ static inline int is_lvm(blkid_probe pr)
return (v && v->data && strcmp((char *) v->data, "LVM2_member") == 0);
}
static inline int is_empty_mbr(unsigned char *mbr)
static inline int is_empty_mbr(const unsigned char *mbr)
{
struct dos_partition *p = mbr_get_partition(mbr, 0);
const struct dos_partition *p = mbr_get_partition(mbr, 0);
int i, nparts = 0;
for (i = 0; i < 4; i++) {
@ -177,8 +177,8 @@ static int probe_dos_pt(blkid_probe pr,
int ssf;
blkid_parttable tab = NULL;
blkid_partlist ls;
struct dos_partition *p0, *p;
unsigned char *data;
const struct dos_partition *p0, *p;
const unsigned char *data;
uint32_t start, size, id;
char idstr[UUID_STR_LEN];

View file

@ -109,7 +109,7 @@ static inline uint32_t count_crc32(const unsigned char *buf, size_t len,
return (ul_crc32_exclude_offset(~0L, buf, len, exclude_off, exclude_len) ^ ~0L);
}
static inline unsigned char *get_lba_buffer(blkid_probe pr,
static inline const unsigned char *get_lba_buffer(blkid_probe pr,
uint64_t lba, size_t bytes)
{
return blkid_probe_get_buffer(pr,
@ -161,8 +161,8 @@ static int last_lba(blkid_probe pr, uint64_t *lba)
static int is_pmbr_valid(blkid_probe pr, int *has)
{
int flags = blkid_partitions_get_flags(pr);
unsigned char *data;
struct dos_partition *p;
const unsigned char *data;
const struct dos_partition *p;
int i;
if (has)

View file

@ -56,7 +56,7 @@ struct mac_driver_desc {
/* there is more stuff after this that we don't need */
} __attribute__((packed));
static inline unsigned char *get_mac_block(
static inline const unsigned char *get_mac_block(
blkid_probe pr,
uint16_t block_size,
uint32_t num)

View file

@ -17,11 +17,11 @@
static int probe_minix_pt(blkid_probe pr,
const struct blkid_idmag *mag __attribute__((__unused__)))
{
struct dos_partition *p;
const struct dos_partition *p;
blkid_parttable tab = NULL;
blkid_partition parent;
blkid_partlist ls;
unsigned char *data;
const unsigned char *data;
int i;
data = blkid_probe_get_sector(pr, 0);

View file

@ -37,8 +37,8 @@ struct ultrix_disklabel {
static int probe_ultrix_pt(blkid_probe pr,
const struct blkid_idmag *mag __attribute__((__unused__)))
{
unsigned char *data;
struct ultrix_disklabel *l;
const unsigned char *data;
const struct ultrix_disklabel *l;
blkid_parttable tab = NULL;
blkid_partlist ls;
int i;
@ -50,7 +50,7 @@ static int probe_ultrix_pt(blkid_probe pr,
goto nothing;
}
l = (struct ultrix_disklabel *) (data + ULTRIX_OFFSET);
l = (const struct ultrix_disklabel *) (data + ULTRIX_OFFSET);
if (l->pt_magic != ULTRIX_MAGIC || l->pt_valid != 1)
goto nothing;

View file

@ -669,7 +669,7 @@ static int hide_buffer(blkid_probe pr, uint64_t off, uint64_t len)
* Note that @off is offset within probing area, the probing area is defined by
* pr->off and pr->size.
*/
unsigned char *blkid_probe_get_buffer(blkid_probe pr, uint64_t off, uint64_t len)
const unsigned char *blkid_probe_get_buffer(blkid_probe pr, uint64_t off, uint64_t len)
{
struct blkid_bufinfo *bf = NULL;
uint64_t real_off = pr->off + off;
@ -1136,7 +1136,7 @@ int blkid_probe_set_dimension(blkid_probe pr, uint64_t off, uint64_t size)
return 0;
}
unsigned char *blkid_probe_get_sb_buffer(blkid_probe pr, const struct blkid_idmag *mag, size_t size)
const unsigned char *blkid_probe_get_sb_buffer(blkid_probe pr, const struct blkid_idmag *mag, size_t size)
{
uint64_t hint_offset;
@ -1164,7 +1164,7 @@ int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id,
/* try to detect by magic string */
while(mag && mag->magic) {
unsigned char *buf;
const unsigned char *buf;
uint64_t kboff;
uint64_t hint_offset;
@ -1690,7 +1690,7 @@ done:
}
/* same sa blkid_probe_get_buffer() but works with 512-sectors */
unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector)
const unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector)
{
return blkid_probe_get_buffer(pr, ((uint64_t) sector) << 9, 0x200);
}

View file

@ -10,6 +10,7 @@
#include <stddef.h>
#include <stdio.h>
#include <inttypes.h>
#include "superblocks.h"
#include "crc32c.h"
@ -17,10 +18,11 @@
#include "xxhash.h"
#define SB_LABEL_SIZE 32
#define SB_JOURNAL_BUCKETS 256U
/*
* The bcache_super_block is heavily simplified version of struct cache_sb in kernel.
* https://github.com/torvalds/linux/blob/master/include/uapi/linux/bcache.h
* The bcache_super_block is adapted from struct cache_sb in kernel.
* https://github.com/torvalds/linux/blob/master/drivers/md/bcache/bcache_ondisk.h
*/
struct bcache_super_block {
uint64_t csum;
@ -28,6 +30,43 @@ struct bcache_super_block {
uint64_t version;
uint8_t magic[16]; /* bcache file system identifier */
uint8_t uuid[16]; /* device identifier */
uint8_t set_info[16]; /* magic or uuid */
uint8_t label[SB_LABEL_SIZE];
uint64_t flags;
uint64_t seq;
uint64_t feature_compat;
uint64_t feature_incompat;
uint64_t feature_ro_compat;
uint64_t pad[5];
union {
struct {
/* Cache devices */
uint64_t nbuckets; /* device size */
uint16_t block_size; /* sectors */
uint16_t bucket_size; /* sectors */
uint16_t nr_in_set;
uint16_t nr_this_dev;
};
struct {
/* Backing devices */
uint64_t data_offset;
};
};
uint32_t last_mount;
uint16_t first_bucket;
union {
uint16_t njournal_buckets;
uint16_t keys;
};
uint64_t d[SB_JOURNAL_BUCKETS]; /* journal buckets */
uint16_t obso_bucket_size_hi; /* obsoleted */
} __attribute__((packed));
struct bcachefs_sb_field {
@ -102,8 +141,6 @@ struct bcachefs_super_block {
#define BCACHE_SB_MAGIC_OFF offsetof(struct bcache_super_block, magic)
/* start of checksummed data within superblock */
#define BCACHE_SB_CSUMMED_START 8
/* end of checksummed data within superblock */
#define BCACHE_SB_CSUMMED_END 208
/* granularity of offset and length fields within superblock */
#define BCACHEFS_SECTOR_SIZE 512
/* maximum superblock size */
@ -118,9 +155,19 @@ struct bcachefs_super_block {
static int bcache_verify_checksum(blkid_probe pr, const struct blkid_idmag *mag,
const struct bcache_super_block *bcs)
{
unsigned char *csummed = blkid_probe_get_sb_buffer(pr, mag, BCACHE_SB_CSUMMED_END);
uint64_t csum = ul_crc64_we(csummed + BCACHE_SB_CSUMMED_START,
BCACHE_SB_CSUMMED_END - BCACHE_SB_CSUMMED_START);
const unsigned char *csummed;
size_t csummed_size;
uint64_t csum;
if (le16_to_cpu(bcs->keys) > ARRAY_SIZE(bcs->d))
return 0;
/* up to the end of bcs->d[] */
csummed_size = offsetof(typeof(*bcs), d) +
sizeof(bcs->d[0]) * le16_to_cpu(bcs->keys);
csummed = blkid_probe_get_sb_buffer(pr, mag, csummed_size);
csum = ul_crc64_we(csummed + BCACHE_SB_CSUMMED_START,
csummed_size - BCACHE_SB_CSUMMED_START);
return blkid_probe_verify_csum(pr, csum, le64_to_cpu(bcs->csum));
}
@ -138,9 +185,18 @@ static int probe_bcache (blkid_probe pr, const struct blkid_idmag *mag)
if (le64_to_cpu(bcs->offset) != BCACHE_SB_OFF / 512)
return BLKID_PROBE_NONE;
if (blkid_probe_sprintf_version(pr, "%"PRIu64, le64_to_cpu(bcs->version)) < 0)
return BLKID_PROBE_NONE;
if (blkid_probe_set_uuid(pr, bcs->uuid) < 0)
return BLKID_PROBE_NONE;
if (blkid_probe_set_label(pr, bcs->label, sizeof(bcs->label)) < 0)
return BLKID_PROBE_NONE;
if (blkid_probe_set_block_size(pr, le16_to_cpu(bcs->block_size) * 512))
return BLKID_PROBE_NONE;
blkid_probe_set_wiper(pr, 0, BCACHE_SB_OFF);
return BLKID_PROBE_OK;
@ -168,7 +224,7 @@ static void probe_bcachefs_sb_members(blkid_probe pr,
blkid_probe_set_fssize(pr, sectors * BCACHEFS_SECTOR_SIZE);
}
static int is_within_range(void *start, uint64_t size, void *end)
static int is_within_range(const void *start, uint64_t size, const void *end)
{
ptrdiff_t diff;
@ -180,9 +236,9 @@ static int is_within_range(void *start, uint64_t size, void *end)
}
static void probe_bcachefs_sb_fields(blkid_probe pr, const struct bcachefs_super_block *bcs,
unsigned char *sb_start, unsigned char *sb_end)
const unsigned char *sb_start, const unsigned char *sb_end)
{
unsigned char *field_addr = sb_start + BCACHEFS_SB_FIELDS_OFF;
const unsigned char *field_addr = sb_start + BCACHEFS_SB_FIELDS_OFF;
while (1) {
struct bcachefs_sb_field *field = (struct bcachefs_sb_field *) field_addr;
@ -212,10 +268,10 @@ static void probe_bcachefs_sb_fields(blkid_probe pr, const struct bcachefs_super
}
static int bcachefs_validate_checksum(blkid_probe pr, const struct bcachefs_super_block *bcs,
unsigned char *sb, unsigned char *sb_end)
const unsigned char *sb, const unsigned char *sb_end)
{
uint8_t checksum_type = be64_to_cpu(bcs->flags[0]) >> 58;
unsigned char *checksummed_data_start = sb + sizeof(bcs->csum);
const unsigned char *checksummed_data_start = sb + sizeof(bcs->csum);
size_t checksummed_data_size = sb_end - checksummed_data_start;
switch (checksum_type) {
@ -242,7 +298,7 @@ static int bcachefs_validate_checksum(blkid_probe pr, const struct bcachefs_supe
static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag)
{
struct bcachefs_super_block *bcs;
unsigned char *sb, *sb_end;
const unsigned char *sb, *sb_end;
uint64_t sb_size, blocksize;
bcs = blkid_probe_get_sb(pr, mag, struct bcachefs_super_block);

View file

@ -122,7 +122,7 @@ struct bplustree_node {
char name[0];
} __attribute__((packed));
static unsigned char *get_block_run(blkid_probe pr, const struct befs_super_block *bs,
static const unsigned char *get_block_run(blkid_probe pr, const struct befs_super_block *bs,
const struct block_run *br, int fs_le)
{
return blkid_probe_get_buffer(pr,
@ -135,7 +135,7 @@ static unsigned char *get_block_run(blkid_probe pr, const struct befs_super_bloc
<< FS32_TO_CPU(bs->block_shift, fs_le));
}
static unsigned char *get_custom_block_run(blkid_probe pr,
static const unsigned char *get_custom_block_run(blkid_probe pr,
const struct befs_super_block *bs,
const struct block_run *br,
int64_t offset, uint32_t length, int fs_le)
@ -154,7 +154,7 @@ static unsigned char *get_custom_block_run(blkid_probe pr,
length);
}
static unsigned char *get_tree_node(blkid_probe pr, const struct befs_super_block *bs,
static const unsigned char *get_tree_node(blkid_probe pr, const struct befs_super_block *bs,
const struct data_stream *ds,
int64_t start, uint32_t length, int fs_le)
{

View file

@ -55,7 +55,7 @@ static int cramfs_verify_csum(blkid_probe pr, const struct blkid_idmag *mag,
struct cramfs_super *cs, int le)
{
uint32_t crc, expected, csummed_size;
unsigned char *csummed;
const unsigned char *csummed;
expected = cfs32_to_cpu(le, cs->info.crc);
csummed_size = cfs32_to_cpu(le, cs->size);
@ -67,9 +67,10 @@ static int cramfs_verify_csum(blkid_probe pr, const struct blkid_idmag *mag,
csummed = blkid_probe_get_sb_buffer(pr, mag, csummed_size);
if (!csummed)
return 0;
memset(csummed + offsetof(struct cramfs_super, info.crc), 0, sizeof(uint32_t));
crc = ~ul_crc32(~0LL, csummed, csummed_size);
crc = ~ul_crc32_exclude_offset(~0LL, csummed, csummed_size,
offsetof(struct cramfs_super, info.crc),
sizeof_member(struct cramfs_super, info.crc));
return blkid_probe_verify_csum(pr, crc, expected);
}

View file

@ -106,7 +106,7 @@ static int probe_ddf(blkid_probe pr,
if (lba > 0) {
/* check primary header */
unsigned char *buf;
const unsigned char *buf;
buf = blkid_probe_get_buffer(pr,
lba << 9, sizeof(ddf->signature));

View file

@ -46,7 +46,7 @@ static int erofs_verify_checksum(blkid_probe pr, const struct blkid_idmag *mag,
{
uint32_t expected, csum;
size_t csummed_size;
unsigned char *csummed;
const unsigned char *csummed;
if (!(le32_to_cpu(sb->feature_compat) & EROFS_FEATURE_SB_CSUM))
return 1;

View file

@ -119,7 +119,7 @@ static struct exfat_entry_label *find_label(blkid_probe pr,
}
/* From https://docs.microsoft.com/en-us/windows/win32/fileio/exfat-specification#34-main-and-backup-boot-checksum-sub-regions */
static uint32_t exfat_boot_checksum(unsigned char *sectors,
static uint32_t exfat_boot_checksum(const unsigned char *sectors,
size_t sector_size)
{
uint32_t n_bytes = sector_size * 11;
@ -141,7 +141,7 @@ static int exfat_validate_checksum(blkid_probe pr,
{
size_t sector_size = BLOCK_SIZE(sb);
/* 11 sectors will be checksummed, the 12th contains the expected */
unsigned char *data = blkid_probe_get_buffer(pr, 0, sector_size * 12);
const unsigned char *data = blkid_probe_get_buffer(pr, 0, sector_size * 12);
if (!data)
return 0;

View file

@ -67,14 +67,14 @@ static int f2fs_validate_checksum(blkid_probe pr, size_t sb_off,
if (csum_off + sizeof(uint32_t) > 4096)
return 0;
unsigned char *csum_data = blkid_probe_get_buffer(pr,
const unsigned char *csum_data = blkid_probe_get_buffer(pr,
sb_off + csum_off, sizeof(uint32_t));
if (!csum_data)
return 0;
uint32_t expected = le32_to_cpu(*(uint32_t *) csum_data);
unsigned char *csummed = blkid_probe_get_buffer(pr, sb_off, csum_off);
const unsigned char *csummed = blkid_probe_get_buffer(pr, sb_off, csum_off);
if (!csummed)
return 0;

View file

@ -183,11 +183,11 @@ static int probe_hfs(blkid_probe pr, const struct blkid_idmag *mag)
static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag)
{
struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
struct hfsplus_bnode_descriptor *descr;
struct hfsplus_bheader_record *bnode;
struct hfsplus_catalog_key *key;
struct hfsplus_vol_header *hfsplus;
struct hfs_mdb *sbd;
const struct hfsplus_bnode_descriptor *descr;
const struct hfsplus_bheader_record *bnode;
const struct hfsplus_catalog_key *key;
const struct hfsplus_vol_header *hfsplus;
const struct hfs_mdb *sbd;
unsigned int alloc_block_size;
unsigned int alloc_first_block;
unsigned int embed_first_block;
@ -203,7 +203,7 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag)
unsigned int leaf_block;
int ext;
uint64_t leaf_off;
unsigned char *buf;
const unsigned char *buf;
sbd = blkid_probe_get_sb(pr, mag, struct hfs_mdb);
if (!sbd)
@ -225,7 +225,7 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag)
buf = blkid_probe_get_buffer(pr,
off + (mag->kboff * 1024),
sizeof(struct hfsplus_vol_header));
hfsplus = (struct hfsplus_vol_header *) buf;
hfsplus = (const struct hfsplus_vol_header *) buf;
} else
hfsplus = blkid_probe_get_sb(pr, mag,

View file

@ -232,7 +232,7 @@ static int probe_iso9660(blkid_probe pr, const struct blkid_idmag *mag)
return probe_iso9660_hsfs(pr, mag);
for (i = 0, off += ISO_SUPERBLOCK_OFFSET; i < ISO_VD_MAX && (!boot || !pvd || !joliet); i++, off += ISO_SECTOR_SIZE) {
unsigned char *desc =
const unsigned char *desc =
blkid_probe_get_buffer(pr,
off,
max(sizeof(struct boot_record),

View file

@ -41,7 +41,7 @@ static int probe_jfs(blkid_probe pr, const struct blkid_idmag *mag)
js = blkid_probe_get_sb(pr, mag, struct jfs_super_block);
if (!js)
return errno ? -errno : 1;
if (le16_to_cpu(js->js_l2bsize) > 32 || le16_to_cpu(js->js_l2pbsize) > 32)
if (le16_to_cpu(js->js_l2bsize) > 31 || le16_to_cpu(js->js_l2pbsize) > 31)
return 1;
if (le32_to_cpu(js->js_bsize) != (1U << le16_to_cpu(js->js_l2bsize)))
return 1;

View file

@ -187,15 +187,14 @@ static int raid1_verify_csum(blkid_probe pr, off_t off,
{
size_t csummed_size = sizeof(struct mdp1_super_block)
+ le32_to_cpu(mdp1->max_dev) * sizeof(mdp1->dev_roles[0]);
unsigned char *csummed = blkid_probe_get_buffer(pr, off, csummed_size);
const unsigned char *csummed = blkid_probe_get_buffer(pr, off, csummed_size);
if (!csummed)
return 1;
memset(csummed + offsetof(struct mdp1_super_block, sb_csum), 0,
sizeof(mdp1->sb_csum));
uint64_t csum = 0;
csum -= le32_to_cpu(*(uint32_t *) (csummed + offsetof(struct mdp1_super_block, sb_csum)));
while (csummed_size >= 4) {
csum += le32_to_cpu(*(uint32_t *) csummed);
csummed_size -= 4;

View file

@ -76,7 +76,7 @@ static int probe_lvm2(blkid_probe pr, const struct blkid_idmag *mag)
int sector = mag->kboff << 1;
struct lvm2_pv_label_header *label;
char uuid[LVM2_ID_LEN + 7];
unsigned char *buf;
const unsigned char *buf;
buf = blkid_probe_get_buffer(pr,
mag->kboff << 10,

View file

@ -74,7 +74,7 @@ static int get_minix_version(const unsigned char *data, int *other_endian)
static int probe_minix(blkid_probe pr,
const struct blkid_idmag *mag __attribute__((__unused__)))
{
unsigned char *ext;
const unsigned char *ext;
const unsigned char *data;
int version = 0, swabme = 0;
unsigned long zones, ninodes, imaps, zmaps;

View file

@ -80,13 +80,13 @@ struct file_attribute {
static int __probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag, int save_info)
{
struct ntfs_super_block *ns;
struct master_file_table_record *mft;
const struct ntfs_super_block *ns;
const struct master_file_table_record *mft;
uint32_t sectors_per_cluster, mft_record_size;
uint16_t sector_size;
uint64_t nr_clusters, off, attr_off;
unsigned char *buf_mft;
const unsigned char *buf_mft;
ns = blkid_probe_get_sb(pr, mag, struct ntfs_super_block);
if (!ns)

View file

@ -100,7 +100,7 @@ struct oracle_asm_disk_label {
static int probe_ocfs(blkid_probe pr, const struct blkid_idmag *mag)
{
unsigned char *buf;
const unsigned char *buf;
struct ocfs_volume_header ovh;
struct ocfs_volume_label ovl;
uint32_t maj, min;

View file

@ -29,7 +29,7 @@ static int romfs_verify_csum(blkid_probe pr, const struct blkid_idmag *mag,
{
uint32_t csummed_size = min((uint32_t) 512,
be32_to_cpu(ros->ros_full_size));
unsigned char *csummed;
const unsigned char *csummed;
uint32_t csum;
if (csummed_size % sizeof(uint32_t) != 0)

View file

@ -49,7 +49,7 @@ const char STRATIS_MAGIC[] = "!Stra0tis\x86\xff\x02^\x41rh";
#define MAGIC_OFFSET_COPY_1 (FIRST_COPY_OFFSET + _MAGIC_OFFSET)
#define MAGIC_OFFSET_COPY_2 (SECOND_COPY_OFFSET + _MAGIC_OFFSET)
static int stratis_valid_sb(uint8_t *p)
static int stratis_valid_sb(const uint8_t *p)
{
const struct stratis_sb *stratis = (const struct stratis_sb *)p;
uint32_t crc = 0;
@ -83,7 +83,7 @@ static int probe_stratis(blkid_probe pr,
const struct blkid_idmag *mag __attribute__((__unused__)))
{
const struct stratis_sb *stratis = NULL;
uint8_t *buf = blkid_probe_get_buffer(pr, 0, SB_AREA_SIZE);
const uint8_t *buf = blkid_probe_get_buffer(pr, 0, SB_AREA_SIZE);
unsigned char uuid[STRATIS_UUID_STR_LEN];
if (!buf)

View file

@ -91,7 +91,7 @@ static int swap_set_info(blkid_probe pr, const struct blkid_idmag *mag,
static int probe_swap(blkid_probe pr, const struct blkid_idmag *mag)
{
unsigned char *buf;
const unsigned char *buf;
if (!mag)
return 1;

View file

@ -351,7 +351,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
version = "FAT16";
} else if (vs->vs_fat32_length) {
unsigned char *buf;
const unsigned char *buf;
uint16_t fsinfo_sect;
int maxloop = 100;

View file

@ -49,7 +49,7 @@ static int probe_vmfs_fs(blkid_probe pr, const struct blkid_idmag *mag)
static int probe_vmfs_volume(blkid_probe pr, const struct blkid_idmag *mag)
{
struct vmfs_volume_info *header;
unsigned char *lvm_uuid;
const unsigned char *lvm_uuid;
header = blkid_probe_get_sb(pr, mag, struct vmfs_volume_info);
if (header == NULL)

View file

@ -206,7 +206,7 @@ static int xfs_verify_sb(struct xfs_super_block *ondisk, blkid_probe pr,
if ((sbp->sb_versionnum & 0x0f) == 5) {
uint32_t expected, crc;
unsigned char *csummed;
const unsigned char *csummed;
if (!(sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT))
return 0;
@ -331,7 +331,7 @@ static int probe_xfs_log(blkid_probe pr,
{
int i;
struct xlog_rec_header *rhead;
unsigned char *buf;
const unsigned char *buf;
buf = blkid_probe_get_buffer(pr, 0, 256*1024);
if (!buf)

View file

@ -71,13 +71,13 @@ struct nvlist {
struct nvpair nvl_nvpair;
};
static void zfs_process_value(blkid_probe pr, char *name, size_t namelen,
void *value, size_t max_value_size, unsigned directory_level)
static void zfs_process_value(blkid_probe pr, const char *name, size_t namelen,
const void *value, size_t max_value_size, unsigned directory_level)
{
if (strncmp(name, "name", namelen) == 0 &&
sizeof(struct nvstring) <= max_value_size &&
!directory_level) {
struct nvstring *nvs = value;
const struct nvstring *nvs = value;
uint32_t nvs_type = be32_to_cpu(nvs->nvs_type);
uint32_t nvs_strlen = be32_to_cpu(nvs->nvs_strlen);
@ -92,7 +92,7 @@ static void zfs_process_value(blkid_probe pr, char *name, size_t namelen,
} else if (strncmp(name, "guid", namelen) == 0 &&
sizeof(struct nvuint64) <= max_value_size &&
!directory_level) {
struct nvuint64 *nvu = value;
const struct nvuint64 *nvu = value;
uint32_t nvu_type = be32_to_cpu(nvu->nvu_type);
uint64_t nvu_value;
@ -110,7 +110,7 @@ static void zfs_process_value(blkid_probe pr, char *name, size_t namelen,
} else if (strncmp(name, "pool_guid", namelen) == 0 &&
sizeof(struct nvuint64) <= max_value_size &&
!directory_level) {
struct nvuint64 *nvu = value;
const struct nvuint64 *nvu = value;
uint32_t nvu_type = be32_to_cpu(nvu->nvu_type);
uint64_t nvu_value;
@ -128,7 +128,7 @@ static void zfs_process_value(blkid_probe pr, char *name, size_t namelen,
"%"PRIu64, nvu_value);
} else if (strncmp(name, "ashift", namelen) == 0 &&
sizeof(struct nvuint64) <= max_value_size) {
struct nvuint64 *nvu = value;
const struct nvuint64 *nvu = value;
uint32_t nvu_type = be32_to_cpu(nvu->nvu_type);
uint64_t nvu_value;
@ -147,9 +147,9 @@ static void zfs_process_value(blkid_probe pr, char *name, size_t namelen,
static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
{
unsigned char *p;
struct nvlist *nvl;
struct nvpair *nvp;
const unsigned char *p;
const struct nvlist *nvl;
const struct nvpair *nvp;
size_t left = 4096;
unsigned directory_level = 0;
@ -166,16 +166,16 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
DBG(LOWPROBE, ul_debug("zfs_extract: nvlist offset %jd",
(intmax_t)offset));
nvl = (struct nvlist *) p;
nvl = (const struct nvlist *) p;
nvp = &nvl->nvl_nvpair;
left -= (unsigned char *)nvp - p; /* Already used up 12 bytes */
left -= (const unsigned char *)nvp - p; /* Already used up 12 bytes */
while (left > sizeof(*nvp)) {
uint32_t nvp_size = be32_to_cpu(nvp->nvp_size);
uint32_t nvp_namelen = be32_to_cpu(nvp->nvp_namelen);
uint64_t namesize = ((uint64_t)nvp_namelen + 3) & ~3;
size_t max_value_size;
void *value;
const void *value;
if (!nvp->nvp_size) {
if (!directory_level)
@ -201,7 +201,7 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
value = nvp->nvp_name + namesize;
if (sizeof(struct nvdirectory) <= max_value_size) {
struct nvdirectory *nvu = value;
const struct nvdirectory *nvu = value;
if (be32_to_cpu(nvu->nvd_type) == DATA_TYPE_DIRECTORY) {
nvp_size = sizeof(*nvp) + namesize + sizeof(*nvu);
directory_level++;
@ -259,7 +259,7 @@ static int probe_zfs(blkid_probe pr,
struct zfs_uberblock *ub = NULL;
loff_t offset = 0, ub_offset = 0;
int label_no, found = 0, found_in_label;
void *label;
const void *label;
loff_t blk_align = (pr->size % (256 * 1024ULL));
DBG(PROBE, ul_debug("probe_zfs"));

View file

@ -26,7 +26,7 @@
static const struct topology_val {
/* /sys/dev/block/<maj>:<min>/<ATTR> */
const char *attr;
const char * const attr;
/* functions to set probing result */
int (*set_ulong)(blkid_probe, unsigned long);

View file

@ -30,7 +30,7 @@
*
*/
static const char *bsd_dktypenames[] = {
static const char * const bsd_dktypenames[] = {
"unknown",
"SMD",
"MSCP",

View file

@ -792,7 +792,7 @@ static void get_partition_table_geometry(struct fdisk_context *cxt,
unsigned char *bufp = cxt->firstsector;
struct { unsigned int c, h, o, v; } t[8];
unsigned int n1, n2, n3, n4, n5, n6;
struct dos_partition *p;
const struct dos_partition *p;
unsigned int c, h, s, l;
unsigned int hh, ss;
unsigned int sects;

View file

@ -75,6 +75,7 @@ int fdisk_set_wipe_area(struct fdisk_context *cxt,
free(wp);
return 1;
}
DBG(WIPE, ul_debug("not requested"));
return 0;
}

View file

@ -2,6 +2,7 @@ if BUILD_LIBMOUNT
include libmount/src/Makemodule.am
include libmount/python/Makemodule.am
include libmount/samples/Makemodule.am
if ENABLE_GTK_DOC
# Docs uses separate Makefiles

View file

@ -117,6 +117,7 @@ libmount_tests = [
'context',
'lock',
'optstr',
'optlist',
'tab',
'tab_diff',
'monitor',
@ -141,7 +142,7 @@ foreach libmount_test: libmount_tests
c_args : ['-DTEST_PROGRAM'],
)
# the test-setup expects the helpers in the toplevel build-directory
link = meson.build_root() / test_name
link = meson.project_build_root() / test_name
run_command('ln', '-srf', exe.full_path(), link,
check : true)
endforeach

View file

@ -1175,43 +1175,17 @@ static PyObject *Context_repr(ContextObjext *self)
PyTypeObject ContextType = {
PyVarObject_HEAD_INIT(NULL, 0)
"libmount.Context", /*tp_name*/
sizeof(ContextObjext), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)Context_dealloc, /*tp_dealloc*/
0, /*tp_print*/
NULL, /*tp_getattr*/
NULL, /*tp_setattr*/
NULL, /*tp_compare*/
(reprfunc) Context_repr,
NULL, /*tp_as_number*/
NULL, /*tp_as_sequence*/
NULL, /*tp_as_mapping*/
NULL, /*tp_hash */
NULL, /*tp_call*/
NULL, /*tp_str*/
NULL, /*tp_getattro*/
NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
Context_HELP, /* tp_doc */
NULL, /* tp_traverse */
NULL, /* tp_clear */
NULL, /* tp_richcompare */
0, /* tp_weaklistoffset */
NULL, /* tp_iter */
NULL, /* tp_iternext */
Context_methods, /* tp_methods */
Context_members, /* tp_members */
Context_getseters, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
NULL, /* tp_descr_get */
NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)Context_init, /* tp_init */
NULL, /* tp_alloc */
Context_new, /* tp_new */
.tp_name = "libmount.Context",
.tp_basicsize = sizeof(ContextObjext),
.tp_dealloc = (destructor)Context_dealloc,
.tp_repr = (reprfunc) Context_repr,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = Context_HELP,
.tp_methods = Context_methods,
.tp_members = Context_members,
.tp_getset = Context_getseters,
.tp_init = (initproc)Context_init,
.tp_new = Context_new,
};
void Context_AddModuleObject(PyObject *mod)

View file

@ -832,43 +832,17 @@ static PyObject *Fs_copy_fs(FsObject *self, PyObject *args, PyObject *kwds)
PyTypeObject FsType = {
PyVarObject_HEAD_INIT(NULL, 0)
"libmount.Fs", /*tp_name*/
sizeof(FsObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)Fs_destructor, /*tp_dealloc*/
0, /*tp_print*/
NULL, /*tp_getattr*/
NULL, /*tp_setattr*/
NULL, /*tp_compare*/
(reprfunc)Fs_repr, /*tp_repr*/
NULL, /*tp_as_number*/
NULL, /*tp_as_sequence*/
NULL, /*tp_as_mapping*/
NULL, /*tp_hash */
NULL, /*tp_call*/
NULL, /*tp_str*/
NULL, /*tp_getattro*/
NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
Fs_HELP, /* tp_doc */
NULL, /* tp_traverse */
NULL, /* tp_clear */
NULL, /* tp_richcompare */
0, /* tp_weaklistoffset */
NULL, /* tp_iter */
NULL, /* tp_iternext */
Fs_methods, /* tp_methods */
Fs_members, /* tp_members */
Fs_getseters, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
NULL, /* tp_descr_get */
NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)Fs_init, /* tp_init */
NULL, /* tp_alloc */
Fs_new, /* tp_new */
.tp_name = "libmount.Fs",
.tp_basicsize = sizeof(FsObject),
.tp_dealloc = (destructor)Fs_destructor,
.tp_repr = (reprfunc)Fs_repr,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = Fs_HELP,
.tp_methods = Fs_methods,
.tp_members = Fs_members,
.tp_getset = Fs_getseters,
.tp_init = (initproc)Fs_init,
.tp_new = Fs_new,
};
void FS_AddModuleObject(PyObject *mod)

View file

@ -731,43 +731,17 @@ static PyObject *Table_repr(TableObject *self)
PyTypeObject TableType = {
PyVarObject_HEAD_INIT(NULL, 0)
"libmount.Table", /*tp_name*/
sizeof(TableObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)Table_destructor, /*tp_dealloc*/
0, /*tp_print*/
NULL, /*tp_getattr*/
NULL, /*tp_setattr*/
NULL, /*tp_compare*/
(reprfunc) Table_repr, /*tp_repr*/
NULL, /*tp_as_number*/
NULL, /*tp_as_sequence*/
NULL, /*tp_as_mapping*/
NULL, /*tp_hash */
NULL, /*tp_call*/
NULL, /*tp_str*/
NULL, /*tp_getattro*/
NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
Table_HELP, /* tp_doc */
NULL, /* tp_traverse */
NULL, /* tp_clear */
NULL, /* tp_richcompare */
0, /* tp_weaklistoffset */
NULL, /* tp_iter */
NULL, /* tp_iternext */
Table_methods, /* tp_methods */
Table_members, /* tp_members */
Table_getseters, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
NULL, /* tp_descr_get */
NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)Table_init, /* tp_init */
NULL, /* tp_alloc */
Table_new, /* tp_new */
.tp_name = "libmount.Table",
.tp_basicsize = sizeof(TableObject),
.tp_dealloc = (destructor)Table_destructor,
.tp_repr = (reprfunc) Table_repr,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = Table_HELP,
.tp_methods = Table_methods,
.tp_members = Table_members,
.tp_getset = Table_getseters,
.tp_init = (initproc)Table_init,
.tp_new = Table_new,
};
void Table_AddModuleObject(PyObject *mod)

View file

@ -0,0 +1,12 @@
check_PROGRAMS += \
sample-mount-overwrite
sample_mount_cflags = $(AM_CFLAGS) $(NO_UNUSED_WARN_CFLAGS) \
-I$(ul_libmount_incdir)
sample_mount_ldadd = libmount.la $(LDADD)
sample_mount_overwrite_SOURCES = libmount/samples/overwrite.c
sample_mount_overwrite_LDADD = $(sample_mount_ldadd)
sample_mount_overwrite_CFLAGS = $(sample_mount_cflags)

Some files were not shown because too many files have changed in this diff Show more