HomeFreeBSD

filesystems/libblkid: fix odd reads and fdisk

Description

filesystems/libblkid: fix odd reads and fdisk

TL;DR: This fixes "invalid argument" in util-linux's fdisk.
libblkid assumes buffered block devices, skipping most character
devices (unless their name starts with "ubi") and failing because
it tries reads that aren't a multiple of the underlying I/O size.

Detail: util-linux assumes a Linux-like behavior and naming of devices,
and assumes it's looking at buffered block devices, which FreeBSD has
not been provided for many major releases. It also requires specific
layouts of procfs, sysfs, devfs, which FreeBSD or its Linuxulator does
not provide.

So we specifically need to patch the read_buffer function to make sure
it rounds up its read size to the io_size (often 512) and not attempt to
read 36, 256, 548 or other strange sizes and emulate a buffered disk
character device; we also need to patch many of the S_ISCHR checks so
they accept our character devices.

This patching is apparently enough to fix the "invalid argument"
(EINVAL, errno==22) errors from the util-linux fdisk tools.

This patch set is not complete, but is sufficient to get the util-linux
fdisk/cfdisk/sfdisk back up to their feet so we can nuke the dangerous
linuxfdisk port now and for good.

Note that many uses will require sysctl to allow foot-shooting
by setting kern.geom.debugflags=16.

blkid can not yet enumerate disk character devices if run without
argument.

Approved by: portmgr@ (blanket just-fix it)

Could the port maintainer please check with the upstream what their
stance on supporting non-GNU userspaces and non-Linux kernels is?
Can we work with them to get such fixes upstreamed or will they turn
us down because the tools are specifically called "util-linux"?

Details

Provenance
mandreeAuthored on Sep 29 2025, 10:30 PM
Parents
R11:4aea75ddb74a: www/firefox: update to 143.0.3 (rc1)
Branches
Unknown
Tags
Unknown