Provide loff_t via <fcntl.h> on musl-based Linux systems

Musl exposes loff_t only as a macro in <fcntl.h> when _GNU_SOURCE is
defined. Including <fcntl.h> ensures the type is available, and a
fallback typedef is provided when no macro is defined. This fixes build
failures on musl systems.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Signed-off-by: Alexander Moch <mail@alexmoch.com>
Closes #18002
This commit is contained in:
Alexander Moch 2025-12-02 20:14:09 +00:00 committed by GitHub
parent ffaea08319
commit 05e2747bf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,4 +54,15 @@ typedef int projid_t;
typedef off_t loff_t; typedef off_t loff_t;
#endif #endif
/*
* On musl, loff_t is a macro within fcntl.h when _GNU_SOURCE is defined.
* If no macro is defined, a typedef fallback is provided.
*/
#if defined(__linux__) && !defined(__GLIBC__)
#include <fcntl.h>
#ifndef loff_t
typedef off_t loff_t;
#endif
#endif
#endif #endif