]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
2 years agoMerge branch 'parsetimestamp-usec' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 24 Jan 2023 15:20:25 +0000 (16:20 +0100)] 
Merge branch 'parsetimestamp-usec' of https://github.com/t-8ch/util-linux

* 'parsetimestamp-usec' of https://github.com/t-8ch/util-linux:
  lib/timeutils: parse_timestamp: parse usecs
  lib/timeutils: parse_timestamp: fix second parsing
  lib/timeutils: parse_timestamp: add unittests
  lib/timeutils: parse_timestamp: allow fixed reference time
  ci: update shellcheck
  ci: disable shellcheck warning for unused variables

2 years agoMerge branch 'patch-1' of https://github.com/ThomasKaiser/util-linux
Karel Zak [Tue, 24 Jan 2023 15:19:39 +0000 (16:19 +0100)] 
Merge branch 'patch-1' of https://github.com/ThomasKaiser/util-linux

* 'patch-1' of https://github.com/ThomasKaiser/util-linux:
  Change ThunderX3T110 core name to ThunderX3-T110
  Add missing Exynos M5 core
  Add missing Cavium cores
  Add missing Ampere cores
  Add missing ARM-cores
  Add HiSilicon's 0x48/0xd40 Cortex-A76 variant.
  Add exynos-m4
  Add 53/002:Samsung Exynos-m3

2 years agolib/timeutils: parse_timestamp: parse usecs
Thomas Weißschuh [Fri, 20 Jan 2023 02:18:30 +0000 (02:18 +0000)] 
lib/timeutils: parse_timestamp: parse usecs

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/timeutils: parse_timestamp: fix second parsing
Thomas Weißschuh [Fri, 20 Jan 2023 02:43:34 +0000 (02:43 +0000)] 
lib/timeutils: parse_timestamp: fix second parsing

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/timeutils: parse_timestamp: add unittests
Thomas Weißschuh [Fri, 20 Jan 2023 02:13:36 +0000 (02:13 +0000)] 
lib/timeutils: parse_timestamp: add unittests

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/timeutils: parse_timestamp: allow fixed reference time
Thomas Weißschuh [Fri, 20 Jan 2023 02:06:04 +0000 (02:06 +0000)] 
lib/timeutils: parse_timestamp: allow fixed reference time

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoci: update shellcheck
Thomas Weißschuh [Fri, 20 Jan 2023 06:43:59 +0000 (06:43 +0000)] 
ci: update shellcheck

2 years agoci: disable shellcheck warning for unused variables
Thomas Weißschuh [Fri, 20 Jan 2023 06:42:31 +0000 (06:42 +0000)] 
ci: disable shellcheck warning for unused variables

2 years agoMerge branch 'fix-befs' of https://github.com/mbroz/util-linux
Karel Zak [Mon, 23 Jan 2023 13:11:56 +0000 (14:11 +0100)] 
Merge branch 'fix-befs' of https://github.com/mbroz/util-linux

* 'fix-befs' of https://github.com/mbroz/util-linux:
  libblkid: befs - avoid undefined shift

2 years agoMerge branch 'lsfd-const' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Jan 2023 13:11:12 +0000 (14:11 +0100)] 
Merge branch 'lsfd-const' of https://github.com/t-8ch/util-linux

* 'lsfd-const' of https://github.com/t-8ch/util-linux:
  lsfd: make a few structs const

2 years agoMerge branch 'blkpr' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Jan 2023 13:10:42 +0000 (14:10 +0100)] 
Merge branch 'blkpr' of https://github.com/t-8ch/util-linux

* 'blkpr' of https://github.com/t-8ch/util-linux:
  blkpr: mark data const
  meson: add blkpr

2 years agoMerge branch 'bcachefs-fuzz' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Jan 2023 13:09:27 +0000 (14:09 +0100)] 
Merge branch 'bcachefs-fuzz' of https://github.com/t-8ch/util-linux

* 'bcachefs-fuzz' of https://github.com/t-8ch/util-linux:
  libblkid: bcachefs: limit maximum size of read superblock
  libblkid: iso9660: don't warn on isonum mismatch
  libblkid: bcachefs: fix member_field_end
  libblkid: bcachefs: validate size of member field
  libblkid: bcachefs: fix field type
  libblkid: bcachefs: add reproducer for oss-fuzz 55282
  libblkid: bcachefs: fix endless loop

2 years agoMerge branch 'sizeof-member' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Jan 2023 13:08:33 +0000 (14:08 +0100)] 
Merge branch 'sizeof-member' of https://github.com/t-8ch/util-linux

* 'sizeof-member' of https://github.com/t-8ch/util-linux:
  uuidd: use sizeof_member
  last: use sizeof_member
  libblkid: iso9660: use sizeof_member

2 years agoMerge branch 'more_mempcpy' of https://github.com/crrodriguez/util-linux
Karel Zak [Mon, 23 Jan 2023 13:07:13 +0000 (14:07 +0100)] 
Merge branch 'more_mempcpy' of https://github.com/crrodriguez/util-linux

* 'more_mempcpy' of https://github.com/crrodriguez/util-linux:
  remove no longer needed braces
  replace open-coded instances of mempcpy

2 years agoMerge branch 'cramfs32' of https://github.com/ferivoz/util-linux
Karel Zak [Mon, 23 Jan 2023 13:05:59 +0000 (14:05 +0100)] 
Merge branch 'cramfs32' of https://github.com/ferivoz/util-linux

* 'cramfs32' of https://github.com/ferivoz/util-linux:
  fsck.cramfs: print correct error on 32-bit systems

2 years agolsfd: make a few structs const
Thomas Weißschuh [Sun, 22 Jan 2023 17:55:48 +0000 (17:55 +0000)] 
lsfd: make a few structs const

2 years agoblkpr: mark data const
Thomas Weißschuh [Sun, 22 Jan 2023 14:27:24 +0000 (14:27 +0000)] 
blkpr: mark data const

2 years agomeson: add blkpr
Thomas Weißschuh [Sun, 22 Jan 2023 14:27:12 +0000 (14:27 +0000)] 
meson: add blkpr

2 years agolibblkid: bcachefs: limit maximum size of read superblock
Thomas Weißschuh [Sun, 22 Jan 2023 17:40:15 +0000 (17:40 +0000)] 
libblkid: bcachefs: limit maximum size of read superblock

2 years agolibblkid: iso9660: don't warn on isonum mismatch
Thomas Weißschuh [Sat, 21 Jan 2023 05:43:40 +0000 (05:43 +0000)] 
libblkid: iso9660: don't warn on isonum mismatch

we are not doing anything about it anyways

2 years agolibblkid: bcachefs: fix member_field_end
Thomas Weißschuh [Sun, 22 Jan 2023 03:36:06 +0000 (03:36 +0000)] 
libblkid: bcachefs: fix member_field_end

The end of this member is the start of the next one, not the start of
the current one.

2 years agolibblkid: bcachefs: validate size of member field
Thomas Weißschuh [Sun, 22 Jan 2023 01:52:29 +0000 (01:52 +0000)] 
libblkid: bcachefs: validate size of member field

2 years agolibblkid: bcachefs: fix field type
Thomas Weißschuh [Sat, 21 Jan 2023 05:32:22 +0000 (05:32 +0000)] 
libblkid: bcachefs: fix field type

2 years agolibblkid: bcachefs: add reproducer for oss-fuzz 55282
Thomas Weißschuh [Sat, 21 Jan 2023 05:25:34 +0000 (05:25 +0000)] 
libblkid: bcachefs: add reproducer for oss-fuzz 55282

2 years agolibblkid: bcachefs: fix endless loop
Thomas Weißschuh [Sat, 21 Jan 2023 05:01:55 +0000 (05:01 +0000)] 
libblkid: bcachefs: fix endless loop

When a field has size 0 it will loop forever.

See #2031

2 years agouuidd: use sizeof_member
Thomas Weißschuh [Sat, 21 Jan 2023 00:52:49 +0000 (00:52 +0000)] 
uuidd: use sizeof_member

2 years agolast: use sizeof_member
Thomas Weißschuh [Sat, 21 Jan 2023 00:52:39 +0000 (00:52 +0000)] 
last: use sizeof_member

2 years agolibblkid: iso9660: use sizeof_member
Thomas Weißschuh [Sat, 21 Jan 2023 00:52:23 +0000 (00:52 +0000)] 
libblkid: iso9660: use sizeof_member

2 years agoremove no longer needed braces
Cristian Rodríguez [Sat, 21 Jan 2023 18:19:28 +0000 (18:19 +0000)] 
remove no longer needed braces

2 years agoreplace open-coded instances of mempcpy
Cristian Rodríguez [Thu, 19 Jan 2023 18:25:08 +0000 (18:25 +0000)] 
replace open-coded instances of mempcpy

2 years agofsck.cramfs: print correct error on 32-bit systems
Samanta Navarro [Fri, 20 Jan 2023 11:57:15 +0000 (11:57 +0000)] 
fsck.cramfs: print correct error on 32-bit systems

On 32-bit systems the file length check does not handle files correctly
which are larger than 4 GB. Use an unsigned long long which is already
in place for blkdev_get_size.

Proof of Concept:

- Prepare a file containing a CramFS
```
mkdir owo
mkfs.cramfs owo owo.iso
dd if=/dev/zero of=owo.iso bs=1 seek=4294967296 count=1 conv=notrunc
fsck.cramfs owo.iso
```

- Check the file
```
fsck.cramfs owo.iso
```

You will see: `fsck.cramfs: file length too short`
Better message is: `fsck.cramfs: file extends past end of filesystem`

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agolibblkid: befs - avoid undefined shift
Milan Broz [Mon, 23 Jan 2023 12:46:31 +0000 (13:46 +0100)] 
libblkid: befs - avoid undefined shift

BEFS does not check maximal value for ag_shift leading
to undefined behavior. Avoid this by limiting shift size.

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

Signed-off-by: Milan Broz <gmazyland@gmail.com>
2 years agoChange ThunderX3T110 core name to ThunderX3-T110
ThomasKaiser [Mon, 23 Jan 2023 12:15:16 +0000 (13:15 +0100)] 
Change ThunderX3T110 core name to ThunderX3-T110

(for consistency reasons)

2 years agolsfd: make a few structs const
Thomas Weißschuh [Sun, 22 Jan 2023 17:55:48 +0000 (17:55 +0000)] 
lsfd: make a few structs const

2 years agolibblkid: bcachefs: limit maximum size of read superblock
Thomas Weißschuh [Sun, 22 Jan 2023 17:40:15 +0000 (17:40 +0000)] 
libblkid: bcachefs: limit maximum size of read superblock

2 years agoAdd missing Exynos M5 core
ThomasKaiser [Sun, 22 Jan 2023 17:18:44 +0000 (18:18 +0100)] 
Add missing Exynos M5 core

https://github.com/Dr-Noob/cpufetch/blob/master/src/arm/uarch.c#L310

2 years agoblkpr: mark data const
Thomas Weißschuh [Sun, 22 Jan 2023 14:27:24 +0000 (14:27 +0000)] 
blkpr: mark data const

2 years agomeson: add blkpr
Thomas Weißschuh [Sun, 22 Jan 2023 14:27:12 +0000 (14:27 +0000)] 
meson: add blkpr

2 years agoAdd missing Cavium cores
ThomasKaiser [Sun, 22 Jan 2023 11:45:08 +0000 (12:45 +0100)] 
Add missing Cavium cores

https://github.com/ThomasKaiser/sbc-bench/commit/37332238c0a8b7c1555dca9d18a7c98362564416#diff-fdfd2a032c64d6e9ba92a3197cad6b26573c7094433d74efa4ae80f44f65aa99

2 years agoAdd missing Ampere cores
ThomasKaiser [Sun, 22 Jan 2023 11:41:36 +0000 (12:41 +0100)] 
Add missing Ampere cores

https://github.com/ThomasKaiser/sbc-bench/commit/37332238c0a8b7c1555dca9d18a7c98362564416#diff-fdfd2a032c64d6e9ba92a3197cad6b26573c7094433d74efa4ae80f44f65aa99

2 years agoAdd missing ARM-cores
ThomasKaiser [Sun, 22 Jan 2023 11:37:33 +0000 (12:37 +0100)] 
Add missing ARM-cores

https://github.com/ThomasKaiser/sbc-bench/commit/37332238c0a8b7c1555dca9d18a7c98362564416#diff-fdfd2a032c64d6e9ba92a3197cad6b26573c7094433d74efa4ae80f44f65aa99

2 years agoAdd HiSilicon's 0x48/0xd40 Cortex-A76 variant.
ThomasKaiser [Sun, 22 Jan 2023 09:36:01 +0000 (10:36 +0100)] 
Add HiSilicon's 0x48/0xd40 Cortex-A76 variant.

Both Kirin 980 and Kirin 810 feature big cores with 0x48/0xd40 ID though they are marketed/documented as Cortex-A76 by HiSilicon themselves. Kirin 980 shows a r1p0 stepping while newer 810 has r3p0.

  * https://github.com/deater/test_proc/blob/master/arm64/arm64.v8.0x41.0xd05.0x48.0xd40.huawei_mate_20#L37-L71
  * https://github.com/termux/proot/issues/190#issuecomment-927013509

2 years agolibblkid: iso9660: don't warn on isonum mismatch
Thomas Weißschuh [Sat, 21 Jan 2023 05:43:40 +0000 (05:43 +0000)] 
libblkid: iso9660: don't warn on isonum mismatch

we are not doing anything about it anyways

2 years agolibblkid: bcachefs: fix member_field_end
Thomas Weißschuh [Sun, 22 Jan 2023 03:36:06 +0000 (03:36 +0000)] 
libblkid: bcachefs: fix member_field_end

The end of this member is the start of the next one, not the start of
the current one.

2 years agolibblkid: bcachefs: validate size of member field
Thomas Weißschuh [Sun, 22 Jan 2023 01:52:29 +0000 (01:52 +0000)] 
libblkid: bcachefs: validate size of member field

2 years agoAdd exynos-m4
ThomasKaiser [Sat, 21 Jan 2023 18:54:27 +0000 (19:54 +0100)] 
Add exynos-m4

https://github.com/ThomasKaiser/sbc-bench/blob/master/results/Exynos-9820.cpuinfo

2 years agoremove no longer needed braces
Cristian Rodríguez [Sat, 21 Jan 2023 18:19:28 +0000 (18:19 +0000)] 
remove no longer needed braces

2 years agoAdd 53/002:Samsung Exynos-m3
ThomasKaiser [Sat, 21 Jan 2023 17:03:11 +0000 (18:03 +0100)] 
Add 53/002:Samsung Exynos-m3

ID 002 for the Exynos-m3 core seems weird since Exynos-m1 had 001 but Samsung's Mongoose line differs only by stepping between M1 and M2

  * Mongoose 1, for example [Exynos 8890](https://github.com/ThomasKaiser/sbc-bench/blob/master/results/Exynos-8890-highperformance.cpuinfo): Exynos-m1 / r1p1
  * Mongoose 2, for example [Exynos 8895](https://github.com/ThomasKaiser/sbc-bench/blob/master/results/Exynos-8895.cpuinfo): Exynos-m1 / r4p0
  * Mongoose 3, for example [Exynos 9810](https://github.com/ThomasKaiser/sbc-bench/blob/master/results/Exynos-9810.cpuinfo): Exynos-m3 / r1p0

2 years agolibblkid: bcachefs: fix field type
Thomas Weißschuh [Sat, 21 Jan 2023 05:32:22 +0000 (05:32 +0000)] 
libblkid: bcachefs: fix field type

2 years agolibblkid: bcachefs: add reproducer for oss-fuzz 55282
Thomas Weißschuh [Sat, 21 Jan 2023 05:25:34 +0000 (05:25 +0000)] 
libblkid: bcachefs: add reproducer for oss-fuzz 55282

2 years agolibblkid: bcachefs: fix endless loop
Thomas Weißschuh [Sat, 21 Jan 2023 05:01:55 +0000 (05:01 +0000)] 
libblkid: bcachefs: fix endless loop

When a field has size 0 it will loop forever.

See #2031

2 years agouuidd: use sizeof_member
Thomas Weißschuh [Sat, 21 Jan 2023 00:52:49 +0000 (00:52 +0000)] 
uuidd: use sizeof_member

2 years agolast: use sizeof_member
Thomas Weißschuh [Sat, 21 Jan 2023 00:52:39 +0000 (00:52 +0000)] 
last: use sizeof_member

2 years agolibblkid: iso9660: use sizeof_member
Thomas Weißschuh [Sat, 21 Jan 2023 00:52:23 +0000 (00:52 +0000)] 
libblkid: iso9660: use sizeof_member

2 years agolsfd: remove strcpy(), keep things based on sizeof()
Karel Zak [Fri, 20 Jan 2023 14:20:55 +0000 (15:20 +0100)] 
lsfd: remove strcpy(), keep things based on sizeof()

* use safe xstrncpy() rather than strcpy()
* use sizeof() for static buffers rather than macro with real size
  (this solution is more robust for future code changes)
* use xcalloc() to zeroize allocated memory

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoinclude/c: add sizeof_member()
Karel Zak [Fri, 20 Jan 2023 14:19:52 +0000 (15:19 +0100)] 
include/c: add sizeof_member()

This macro returns size of struct member.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'master' of https://github.com/karelzak/util-linux into more_mempcpy
Cristian Rodríguez [Fri, 20 Jan 2023 12:26:22 +0000 (12:26 +0000)] 
Merge branch 'master' of https://github.com/karelzak/util-linux into more_mempcpy

2 years agofsck.cramfs: print correct error on 32-bit systems
Samanta Navarro [Fri, 20 Jan 2023 11:57:15 +0000 (11:57 +0000)] 
fsck.cramfs: print correct error on 32-bit systems

On 32-bit systems the file length check does not handle files correctly
which are larger than 4 GB. Use an unsigned long long which is already
in place for blkdev_get_size.

Proof of Concept:

- Prepare a file containing a CramFS
```
mkdir owo
mkfs.cramfs owo owo.iso
dd if=/dev/zero of=owo.iso bs=1 seek=4294967296 count=1 conv=notrunc
fsck.cramfs owo.iso
```

- Check the file
```
fsck.cramfs owo.iso
```

You will see: `fsck.cramfs: file length too short`
Better message is: `fsck.cramfs: file extends past end of filesystem`

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agolibblkid: (bcachefs) verify checksum before set probing result
Karel Zak [Fri, 20 Jan 2023 11:45:10 +0000 (12:45 +0100)] 
libblkid: (bcachefs) verify checksum before set probing result

* merge probe_bcachefs_full_sb() in to probe_bcachefs()

* define variables at the beginning of the code block

* cosmetic code cleanup

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibblkid: bcachefs: add xxhash checksum support
Thomas Weißschuh [Fri, 18 Nov 2022 17:42:01 +0000 (18:42 +0100)] 
libblkid: bcachefs: add xxhash checksum support

2 years agolibblkid: bcachefs: add crc64 checksum support
Thomas Weißschuh [Tue, 13 Sep 2022 07:50:51 +0000 (09:50 +0200)] 
libblkid: bcachefs: add crc64 checksum support

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolibblkid: bcachefs: add crc32 checksum support
Thomas Weißschuh [Mon, 19 Apr 2021 22:02:07 +0000 (00:02 +0200)] 
libblkid: bcachefs: add crc32 checksum support

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolibblkid: bcachefs: validate device fields
Thomas Weißschuh [Sun, 27 Nov 2022 19:47:04 +0000 (20:47 +0100)] 
libblkid: bcachefs: validate device fields

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolibblkid: bcachefs: probe UUID_SUB
Thomas Weißschuh [Mon, 12 Apr 2021 12:05:00 +0000 (14:05 +0200)] 
libblkid: bcachefs: probe UUID_SUB

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolibblkid: add bcachefs support
Thomas Weißschuh [Mon, 12 Apr 2021 12:01:14 +0000 (14:01 +0200)] 
libblkid: add bcachefs support

https://bcachefs.org/

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoreplace open-coded instances of mempcpy
Cristian Rodríguez [Thu, 19 Jan 2023 18:25:08 +0000 (18:25 +0000)] 
replace open-coded instances of mempcpy

2 years agoc.h: fix compiler warning [-Werror=shift-count-overflow]
Karel Zak [Tue, 17 Jan 2023 15:36:13 +0000 (16:36 +0100)] 
c.h: fix compiler warning [-Werror=shift-count-overflow]

It's probably typo in the original path (too many brackets:-)). Let's
be explicit about the types used in the calculation. '1 << n' means
the left shift is on 'int', but we need '(t)1 << n'.

Addresses: e53463ea40c58a6f84a597966ac69be9be72cd7d
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'blkdev' of https://github.com/ferivoz/util-linux
Karel Zak [Tue, 17 Jan 2023 15:15:11 +0000 (16:15 +0100)] 
Merge branch 'blkdev' of https://github.com/ferivoz/util-linux

* 'blkdev' of https://github.com/ferivoz/util-linux:
  lib/blkdev: use off_t for max values
  lib/blkdev: set errno in more cases
  lib/blkdev: handle interrupted read call

2 years agoswapon: add --fstab command line option
Karel Zak [Mon, 16 Jan 2023 12:47:36 +0000 (13:47 +0100)] 
swapon: add --fstab command line option

Let's add --fstab mount option for compatibility with mount(8).

Addresses: https://github.com/util-linux/util-linux/issues/2017
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolib/blkdev: use off_t for max values
Samanta Navarro [Fri, 13 Jan 2023 11:52:36 +0000 (11:52 +0000)] 
lib/blkdev: use off_t for max values

The off_t datatype is signed. Use it for high and low boundaries as
well to support also very large block devices close to its limits.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agolib/blkdev: set errno in more cases
Samanta Navarro [Fri, 13 Jan 2023 11:51:52 +0000 (11:51 +0000)] 
lib/blkdev: set errno in more cases

Applications evaluate errno in case of a -1 return value. Examples
within util-linux are fsck.cramfs and mkfs.minix. Set errno more often
to offer reasonable error codes to the application and user.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agolib/blkdev: handle interrupted read call
Samanta Navarro [Fri, 13 Jan 2023 11:50:40 +0000 (11:50 +0000)] 
lib/blkdev: handle interrupted read call

The read call may fail if it is interrupted by a signal. Do not assume
that we have reached the end of the underlying block device because of
this. Use read_all which retries in these cases.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agoc.h: really avoid undefined behavior in SINT_MAX
Thomas Weißschuh [Sat, 14 Jan 2023 22:16:28 +0000 (22:16 +0000)] 
c.h: really avoid undefined behavior in SINT_MAX

The previous fix in #2013 still invoked undefined behavior by shifting
into the sign-bit.

Now we have a correct, albeit unwieldy solution that avoids undefined
behavior.
Instead of bit fiddling it uses plain addition and substraction.

We are looking for (in LaTeX notation):
  2^(n - 1) - 1
= 2 * 2^(n - 2) - 1
= 2^(n - 2) + 2^(n - 2) - 1
= 2^(n - 2) - 1 + 2^(n - 2)

2 years agoMerge branch 'mkswap' of https://github.com/ferivoz/util-linux
Karel Zak [Fri, 13 Jan 2023 12:35:02 +0000 (13:35 +0100)] 
Merge branch 'mkswap' of https://github.com/ferivoz/util-linux

* 'mkswap' of https://github.com/ferivoz/util-linux:
  mkswap: do not use uninitialized stack value

2 years agomkswap: do not use uninitialized stack value
Samanta Navarro [Fri, 13 Jan 2023 11:53:41 +0000 (11:53 +0000)] 
mkswap: do not use uninitialized stack value

If blkdev_get_size fails, then size is not set. Exit with an error code
and indicate what went wrong instead of continuing with random stack
content.

Proof of Concept:

```
$ mkswap /dev/null
mkswap: warning: truncating swap area to 17179869180 KiB
mkswap: /dev/null: insecure permissions 0666, fix with: chmod 0600 /dev/null
mkswap: unable to assign device to libblkid probe
```

The first output line depends on stack content and sometimes does not
show up at all. Abort operation if argument is neither regular file nor
block device.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agologger: (man) fix examples
Karel Zak [Fri, 13 Jan 2023 11:18:27 +0000 (12:18 +0100)] 
logger: (man) fix examples

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoinclude: add missing license lines
Karel Zak [Thu, 12 Jan 2023 14:33:09 +0000 (15:33 +0100)] 
include: add missing license lines

The header files are usually based on code from lib/. This commit
copies relevant license headers from lib/ to include/ to keep
things consistent. The very generic things (e.g. MBR definitions)
are always public domain.

Fixes: https://github.com/util-linux/util-linux/issues/2010
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'sint-max' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 12 Jan 2023 13:35:50 +0000 (14:35 +0100)] 
Merge branch 'sint-max' of https://github.com/t-8ch/util-linux

* 'sint-max' of https://github.com/t-8ch/util-linux:
  c.h: avoid undefined behavior in SINT_MAX macro

2 years agoc.h: avoid undefined behavior in SINT_MAX macro
Thomas Weißschuh [Thu, 12 Jan 2023 00:49:35 +0000 (00:49 +0000)] 
c.h: avoid undefined behavior in SINT_MAX macro

The previous implementation relied on signed-integer overflow.
This is undefined behavior.

Instead use an implementation that only requires twos-complement
representation. This is what everybody uses anyways and it will be
required by C23.

2 years agologin: never send signals to init
Samanta Navarro [Wed, 11 Jan 2023 11:57:21 +0000 (11:57 +0000)] 
login: never send signals to init

If the signal handler is triggered after a failed fork attempt, then
child_pid will be -1. This in turn leads to a positive test and a
subsequent call of kill(1, signal). If signal was SIGTERM, then there
will be also another kill(1, SIGHUP) call.

Test explicitly for a positive child_pid value to prevent these cases.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agounshare: support --map-users=inner:outer:count as well as outer,inner,count
Chris Webb [Tue, 10 Jan 2023 13:58:58 +0000 (13:58 +0000)] 
unshare: support --map-users=inner:outer:count as well as outer,inner,count

The argument ordering in /proc/self/[gu]id_map and mount -o X-mount.idmap
is consistently inner:outer:count but unshare --map-users and --map-groups
were originally defined to expect outer,inner,count instead.

To reduce confusion caused by this mismatch, support a colon-separated
inner:outer:count ordering as well as the original comma-separated
outer,inner,count argument format. Although we accept both formats, only
document the new one in the usage text and deprecate the old format in
the man page.

Fixes: https://github.com/util-linux/util-linux/issues/1988
Signed-off-by: Chris Webb <chris@arachsys.com>
2 years agoMerge branch 'typo' of https://github.com/ferivoz/util-linux
Karel Zak [Tue, 10 Jan 2023 14:10:15 +0000 (15:10 +0100)] 
Merge branch 'typo' of https://github.com/ferivoz/util-linux

* 'typo' of https://github.com/ferivoz/util-linux:
  Fix typo

2 years agoinclude: add MOVE_MOUNT_SET_GROUP fallback
Karel Zak [Tue, 10 Jan 2023 13:48:06 +0000 (14:48 +0100)] 
include: add MOVE_MOUNT_SET_GROUP fallback

Addresses: https://github.com/torvalds/linux/commit/9ffb14ef61bab83fa818736bf3e7e6b6e182e8e2
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoFix typo
Samanta Navarro [Tue, 10 Jan 2023 12:00:56 +0000 (12:00 +0000)] 
Fix typo

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2 years agolibmount: use MNT_ERR_APPLYFLAGS for failed mount_setattr()
Karel Zak [Tue, 10 Jan 2023 11:40:47 +0000 (12:40 +0100)] 
libmount: use MNT_ERR_APPLYFLAGS for failed mount_setattr()

The classic mount(2) based version uses MNT_ERR_APPLYFLAGS when not
able to set flags and errno is EINVAL. This is expected by
mnt_context_get_mount_excode() where libmount generates error messages
for mount(8).

Expected is:

 # mount --make-private /mnt/test
 mount: /mnt/test: not mount point or bad option.

rather than generic error:

 mount: /mnt/test: wrong fs type, bad option, bad superblock on none ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'waitpid' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 10 Jan 2023 10:30:55 +0000 (11:30 +0100)] 
Merge branch 'waitpid' of https://github.com/t-8ch/util-linux

* 'waitpid' of https://github.com/t-8ch/util-linux:
  waitpid: adapt bash-completion for current functionality
  po-man: add waitpid.1 manpage
  waitpid: add support for already exited PIDs

2 years agolibmount: fix typo in debug message
Karel Zak [Tue, 10 Jan 2023 10:27:40 +0000 (11:27 +0100)] 
libmount: fix typo in debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibmount: implement X-mount.auto-fstypes
Karel Zak [Mon, 9 Jan 2023 13:22:06 +0000 (14:22 +0100)] 
libmount: implement X-mount.auto-fstypes

Fixes: https://github.com/util-linux/util-linux/issues/1969
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agowaitpid: adapt bash-completion for current functionality
Thomas Weißschuh [Sat, 7 Jan 2023 04:30:18 +0000 (04:30 +0000)] 
waitpid: adapt bash-completion for current functionality

2 years agopo-man: add waitpid.1 manpage
Thomas Weißschuh [Sat, 7 Jan 2023 02:18:22 +0000 (02:18 +0000)] 
po-man: add waitpid.1 manpage

2 years agowaitpid: add support for already exited PIDs
Thomas Weißschuh [Sat, 7 Jan 2023 02:16:06 +0000 (02:16 +0000)] 
waitpid: add support for already exited PIDs

2 years agolibmount: (optlist) keep parsed options without quotes
Karel Zak [Mon, 9 Jan 2023 12:58:45 +0000 (13:58 +0100)] 
libmount: (optlist) keep parsed options without quotes

Some mount options uses quotes due to commas in the value, for
example (SELinux) mount -o 'context="foo,bar"'.

Let's keep this parsed values without quotes in options list. It will
make things more simple.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'po-man/fixes' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 9 Jan 2023 11:47:31 +0000 (12:47 +0100)] 
Merge branch 'po-man/fixes' of https://github.com/t-8ch/util-linux

* 'po-man/fixes' of https://github.com/t-8ch/util-linux:
  sr.po: fix mkfs.cramfs translation
  build: propagate failures from asciidoctor
  po-man: remove unicode dash from manpage NAME section
  sr.po: add missing dash to manpage header
  po-man: always convert common manpage fragments
  po-man: enable out of tree builds
  autotools: add asciidoctor-includetracker to distributed files

2 years agogit: update .gitignore
Karel Zak [Mon, 9 Jan 2023 11:45:24 +0000 (12:45 +0100)] 
git: update .gitignore

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'mount.idmap.fix' of https://github.com/brauner/util-linux
Karel Zak [Mon, 9 Jan 2023 11:38:13 +0000 (12:38 +0100)] 
Merge branch 'mount.idmap.fix' of https://github.com/brauner/util-linux

* 'mount.idmap.fix' of https://github.com/brauner/util-linux:
  libmount: ensure child hangs around until we persisted namespace

2 years agoMerge branch 'schedutils' of https://github.com/chaiken/util-linux
Karel Zak [Mon, 9 Jan 2023 11:35:03 +0000 (12:35 +0100)] 
Merge branch 'schedutils' of https://github.com/chaiken/util-linux

* 'schedutils' of https://github.com/chaiken/util-linux:
  schedutils: better illustrate the usage of cpu-lists with taskset
  schedutils: clarify meaning of taskset return code
  schedutils: clarify confusing mask example in taskset man page

2 years agoci: packit: enable -Werror
Thomas Weißschuh [Sat, 7 Jan 2023 13:58:17 +0000 (13:58 +0000)] 
ci: packit: enable -Werror

2 years agowdctl: mark flags field as unsigned long
Thomas Weißschuh [Sun, 8 Jan 2023 03:29:51 +0000 (03:29 +0000)] 
wdctl: mark flags field as unsigned long

This is required by string_to_bitmask().
The previous cast failed on s390x with the following warning:

In function 'string_to_bitmask',
    inlined from 'string_to_bitmask' at lib/strutils.c:802:5,
    inlined from 'main' at sys-utils/wdctl.c:770:8:
lib/strutils.c:829:23: error: write of 64-bit data outside the bound of destination object, data truncated into 32-bit [-Werror=extra]
  829 |                 *mask |= flag;
      |

2 years agolibblkid: topology/sysfs: fix uint64_t handling on 32bit systems
Thomas Weißschuh [Sun, 8 Jan 2023 03:22:35 +0000 (03:22 +0000)] 
libblkid: topology/sysfs: fix uint64_t handling on 32bit systems

2 years agolibblkid: topology/ioctl: fix uint64_t handling on 32bit systems
Thomas Weißschuh [Sun, 8 Jan 2023 03:09:37 +0000 (03:09 +0000)] 
libblkid: topology/ioctl: fix uint64_t handling on 32bit systems