This file provides guidance to AI coding agents working on this repository.
util-linux is a collection of essential Linux system utilities and libraries (libmount, libblkid, libsmartcols, libfdisk, libuuid). The project follows Linux kernel coding conventions and workflows.
Only human beings can be credited as authors. Do not use Co-Developed-By, Co-Authored-By, or similar authorship attribution for AI models — authorship carries responsibility for the origin of the patch, which a model cannot take.
Disclosing tool use with an Assisted-by: trailer is welcome, but not required. It does not change the standard the patch is held to.
Commits must include a Signed-off-by line (git commit -s) from the human submitter, who is responsible for the patch and is expected to understand and be able to defend every line of it.
Always consult these files as needed:
Documentation/HOWTO-BUILDING.md — how to compile the project, build system internalsDocumentation/HOWTO-CONTRIBUTING.md — contribution guidelines, patch and PR workflowDocumentation/HOWTO-HACKING.md — coding details: usage functions, man pages, debuggingDocumentation/HOWTO-TESTING.md — regression test framework, environment variablesThe coding style is based on the Linux kernel coding style.
{ } braces for single-line if/else blocks.else after non-returning functions (err(), errx(), exit(), ...).if ((rc = func()) != 0) — split into separate assignment and comparison:rc = func(); if (rc != 0)
printf() consistently, not fprintf(stdout, ...)..editorconfig in the project root) for whitespace settings._is_, _has_, _can_._next_ functions: 0 = success, <0 = error, 1 = end of list.include/xalloc.h wrappers (xmalloc(), xcalloc(), xstrdup(), etc.) — these always succeed or terminate with err().malloc/calloc/strdup/asprintf to its corresponding free().list_del() must also free the element memory, not just unlink.free() on error/early-return paths.Fixes: when the commit resolves an issue.Addresses: when the commit only partly implements requested changes.Fixes: https://github.com/util-linux/util-linux/issues/NNNThe project supports two build systems: autotools and meson.
Autotools:
./autogen.sh && ./configure && makemake check or cd tests && ./run.sh./configure --disable-all-programs --enable-<name>Meson:
meson setup build && meson compile -C buildmeson test -C buildTests:
./tests/run.sh to execute all tests../tests/run.sh <subsystem> ... to test specified subsystems (e.g., run.sh mount more). The subsystem name is based on the directory name; see tests/ts/*../tests/ts/<subsystem>/<scriptname> to directly call a script test. Do not use the run.sh wrapper in this case.Features should include corresponding tests.