Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

233.2. libblockdev-3.5.0

Library for manipulating block devices: partitions, filesystems, LVM, MD RAID, crypto, NVMe

Version 3.5.0, release 1
Shelf disk — Block devices: partitioning, RAID, LVM, block encryption, SMART, NVMe, recovery, image writing and async I/O
Phase 43_toolkits (Toolkits), 60 of 344 in build order
Licence LGPL-2.1-or-later
Homepage https://github.com/storaged-project/libblockdev
Build time 0.4 SBU
Installed size 2.6 MiB in 88 files
Recipe ports/core/disk/libblockdev/kpkgbuild

About

libblockdev is the library udisks2 does its block-device work through: a plugin per technology (partitions, filesystems, LVM, MD RAID, encryption, NVMe, SMART), loaded by the soname lists in /etc/libblockdev/3/conf.d/00-default.cfg. The smart plugin is libbd_smart.so.3, built on libatasmart, with libbd_smartmontools.so.3 as its fallback.

Sources

Dependencies

Depends on: python3, glib, gobject-introspection, glib-introspection, eudev, kmod, util-linux, e2fsprogs, cryptsetup, keyutils, nss, volume_key, lvm2, yaml, json-glib, libbytesize, libnvme, libatasmart, smartmontools, btrfs-progs, mdadm, dosfstools, exfatprogs, xfsprogs, f2fs-tools, ntfs-3g, ndctl.

Required by (1): udisks2.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

Patches

build.sh applies these; kpkg applies nothing by itself.

c-locale-strerror.patch defines the _C_LOCALE that the fs, NVMe, SMART and device-utility code pass to strerror_l() as newlocale (LC_ALL_MASK, "C", (locale_t) 0). Upstream defines it as (locale_t) 0. glibc’s strerror_l() takes a null locale as the current one, but musl’s reads the locale’s LC_MESSAGES slot, so every error path that formats errno faults at address 0x28 inside libc.so. udisksd hits one on every SATA disk whose SMART data cannot be read, QEMU’s emulated AHCI disk among them, and dies on the worker thread that refreshes SMART; the bus starts it again on the next call and it crashes again, so Solid, Dolphin’s Places panel and the Device Notifier lose every device. newlocale() of "C" with no base returns the C library’s static C locale on both C libraries, so the macro allocates nothing and cannot fail. The patch is to be offered upstream.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/43_toolkits/phase.env && kpkg install libblockdev'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/disk/libblockdev.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/disk/libblockdev
echo 'bccd30e6b5d11504de60d9889ff6a2a25b07a4ec8f04070f2387e168301b3e3a  libblockdev-3.5.0.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/libblockdev
SRC=$SRC_ROOT/libblockdev-3.5.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libblockdev-3.5.0.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/c-locale-strerror.patch"

export CFLAGS="$CFLAGS -Wno-error"

./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --disable-static \
	--enable-introspection=yes \
	--disable-tests \
	--without-python3 \
	--without-gtk-doc \
	--without-tools \
	--without-s390 \
	--with-nvdimm \
	--without-lvm_dbus \
	--with-escrow \
	--with-nvme \
	--with-smart \
	--with-smartmontools \
	--with-drivedb=/usr/share/smartmontools
make PYTHON=python3
make PYTHON=python3 DESTDIR=$PKG install

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/libblockdev, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf libblockdev-3.5.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/libblockdev, and runs the triggers its paths call for.

Contents

Installed libraries: libbd_btrfs.so, libbd_crypto.so, libbd_dm.so, libbd_fs.so, libbd_loop.so, libbd_lvm.so, libbd_mdraid.so, libbd_mpath.so, libbd_nvdimm.so, libbd_nvme.so, libbd_part.so, libbd_smart.so, libbd_smartmontools.so, libbd_swap.so, libbd_utils.so, libblockdev.so.

Installed directories: /etc/libblockdev, /usr/include/blockdev, /usr/share/licenses/libblockdev.

Short descriptions

blockdev.pc Library for doing low-level operations with block devices
blockdev-utils.pc A library with utility functions used by the libblockdev library