mkswap: check for holes and unwanted extentd in file
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>