- remove unknown extent type (kernel does not care about it too)
- fix last_logical use in messages
- improve warning for DELALLOC extents
- check for hole at the end of the file
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* do not ignore all empty devices, we need more smart solution
* ignore only loop devices without backing file, for example:
# touch img
# losetup -f img
losetup: img: Warning: file is smaller than 512 bytes; the loop device may be useless or invisible for system tools.
- old version display nothing
- new version:
# lsblk /dev/loop0
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 0B 0 loop
Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's make mkswap(8) more user-friend and report possible swapon
issues already when user initialize a swap file. The extents check
produces warnings, no exit with error.
# dd if=/dev/zero of=img count=100 bs=1MiB
# chmod 0600 img
# fallocate --dig-hole --offset 64520192 --length 1MiB img
# fallocate --dig-hole --offset 84520960 --length 1MiB img
# ./mkswap img
mkswap: extents check failed:
- hole detected at offset 64520192 (size 1048576 bytes)
- hole detected at offset 84520960 (size 1048576 bytes)
file img can be rejected by kernel on swap activation.
Setting up swapspace version 1, size = 100 MiB (104853504 bytes)
no label, UUID=92091112-26b5-47aa-a02a-592e52528319
It checks for holes in the file, and for unknown, inline, shared and
deallocated extents.
Addresses: https://github.com/karelzak/util-linux/issues/1120
Signed-off-by: Karel Zak <kzak@redhat.com>
Commit 7b54f05d6b added iflag=fullblock
option, it works fine with coreutils's dd but macOS's dd doesn't support
iflag option then test failed on macOS[1].
This commit added prepared test data for test to not use dd command to
avoid dd command difference.
tested on raspberry pi3
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ; done' | grep FAILED | wc -l
0
tested on macOS
$ sudo sh -c 'for i in $(seq 1 500); do ./ts/cramfs/mkfs-endianness ; done' | grep FAILED | wc -l
0
[1]https://travis-ci.org/github/karelzak/util-linux/jobs/723642222#L3907
Signed-off-by: Masami Ichikawa <masami256@gmail.com>
This adds support for the "nosymfollow" mount option, which indicates
that symlinks should not be traversed on the mount this option is
applied to. Also update the mount(8) man page with information about
this option.
Signed-off-by: Mattias Nissler <mnissler@chromium.org>
Signed-off-by: Ross Zwisler <zwisler@google.com>
When run mkfs-endianness test on lowend machine, sometimes dd didn't
fill block with string then test failed.
So, it's nice to add iflag=fullblock option to fill a block with
string read from stdin.
Tested on Raspberry Pi 3 B+(using 1core to simulate lowend environment)
with iflag=fullblock option didn't get test failure.
Without iflag=fullblock option.
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ; done' | grep FAILED | wc -l
49
With iflag=fullblock option.
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ; done' | grep FAILED | wc -l
0
Signed-off-by: Masami Ichikawa <masami256@gmail.com>
Fix couple "initialization of ‘long int’ from ‘void *’ makes integer from
pointer without a cast" warnings.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The size (3rd) argument should be ignored if the 1st *dest is NULL, but it seems gcc & glibc headers
are more pedantic now:
ext-utils/pg.c:456:13: error: argument 1 is null but the corresponding size argument 3 value is 2048 [-Werror=nonnull]
Signed-off-by: Karel Zak <kzak@redhat.com>
This workaround has been introduced by
e4925f591c
And originally requested by https://github.com/systemd/systemd/issues/10872
It seems we do not need it anymore as the problem should be fixed in kernel since 5.8
(kernel commit 9f6c61f96f2d97cbb5f7fa85607bc398f843ff0f).
Note that the libmount solution is very expensive as it repeats read()
many times (until we get consistent result) if kernel is busy with
mount table modification. This behaviour makes events management in
systemd (or other places) pretty difficult as read mountinfo takes
time on busy systems.
Addresses: https://github.com/systemd/systemd/pull/16537
Signed-off-by: Karel Zak <kzak@redhat.com>
turns out this is subtly broken. musl 1.2.x for 64-bit architectures defines __NR_settimeofday but not
for 32-bit ones. For 32-bit, it defines a _time32 variant.
Permanently turn off current stdin ECHO when it is a terminal and enable setting slave ECHO instead.
Fix other minor typos, update documentation.
[kzak@redhat.com: - remove irrelevant changes
- keep --echo argument unchanged]
Signed-off-by: Karel Zak <kzak@redhat.com>
The commands mount and umount sanitize environment variables as it
works with suid permissions by default. Since v2.36 it's possible
that the commands drop the permissions and continue as regular user.
It seems we also need to restore the original environ to keep things
consistent for users (e.g. HOME=).
The implementation is pretty simple -- it keeps in memory removed
variables and use it after switch to non-suid mode.
Addresses: https://github.com/karelzak/util-linux/issues/880
Signed-off-by: Karel Zak <kzak@redhat.com>
When the partition table is present **but** empty, the existing code would output fields followed by a `,` , on the assumption that the list of partitions would follow. But if the list of partitions is empty, it is skipped, leading to output like this:
```
{
"partitiontable": {
"label":"gpt",
"id":"1F9E80D9-DD78-024F-94A3-B61EC82B18C8",
"device":"/dev/sdb",
"unit":"sectors",
"firstlba":2048,
"lastlba":30949342,
"sectorsize":512,
}
}
```
Note the `512,` on the *sectorsize* line.
This is invalid JSON for some parsers, which choke on it.
Avoid this, by checking when outputting the last separator: if there's no table, or there is a table but it is empty, then just put a newline, otherwise use the old path of comma-newline and assume there's going to be a list of partitions after.
It seems to be failing with
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==13==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000055f428 bp 0x7ffc3743a170 sp 0x7ffc3743a080 T0)
==13==The signal is caused by a WRITE memory access.
==13==Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
#0 0x55f428 in mnt_table_parse_next /src/util-linux/libmount/src/tab_parse.c:587:6
#1 0x55c200 in __table_parse_stream /src/util-linux/libmount/src/tab_parse.c:737:8
#2 0x55be38 in mnt_table_parse_stream /src/util-linux/libmount/src/tab_parse.c:809:8
#3 0x5511ff in LLVMFuzzerTestOneInput /src/util-linux/libmount/src/fuzz.c:21:16
#4 0x458a31 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:558:15
#5 0x458175 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:470:3
#6 0x45a117 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:770:7
#7 0x45a319 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:799:3
#8 0x44a055 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:846:6
#9 0x471bf2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
#10 0x7fe3bd93b83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
#11 0x41f208 in _start (/out/test_mount_fuzz+0x41f208)
DEDUP_TOKEN: mnt_table_parse_next--__table_parse_stream--mnt_table_parse_stream
```