vfio: selftests: Include <libgen.h> for basename() on non-glibc builds

sysfs.c calls basename() but does not include its declaration.
Glibc exposes basename() through <string.h> with _GNU_SOURCE, while
musl declares it in <libgen.h>.

With musl, this results in an implicit-function-declaration error and
subsequent type-mismatch errors at the callers.

Include <libgen.h> so the declaration is available on both glibc and
musl. This is safe at both call sites: the arguments are local writable
char[PATH_MAX] buffers filled by readlink_safe().

Link: https://lore.kernel.org/kvm/CALzav=fs4bqMM7BXNPXqhtbqGzA+LW5fgx2-1Q5=sTN5+krYhw@mail.gmail.com/
Fixes: a262fc49e0 ("KVM: selftests: Build and link selftests/vfio/lib into KVM selftests")
Reviewed-by: David Matlack <dmatlack@google.com>
Signed-off-by: Hisam Mehboob <hisamshar@gmail.com>
Link: https://lore.kernel.org/r/20260824222845.459181-3-hisamshar@gmail.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
This commit is contained in:
Hisam Mehboob 2026-08-25 03:28:47 +05:00 committed by Alex Williamson
parent cee9395acd
commit e11a07856b

View File

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>