Re: [PATCH] fuse: uapi: use UAPI types

From: Thomas Weißschuh

Date: Tue Dec 23 2025 - 03:37:14 EST


Hi Bernd,

On Mon, Dec 22, 2025 at 10:16:39PM +0100, Bernd Schubert wrote:
> On 12/22/25 09:06, Thomas Weißschuh wrote:
> > Using libc types and headers from the UAPI headers is problematic as it
> > introduces a dependency on a full C toolchain.
> >
> > Use the fixed-width integer types provided by the UAPI headers instead.
> >
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
>
> I think that came up a couple of times already.
>
> https://lkml.org/lkml/2015/10/15/672
>
> Also see
> https://git.zx2c4.com/linux-rng/commit/include/uapi/linux/fuse.h?id=4c82456eeb4da081dd63dc69e91aa6deabd29e03&follow=1

Thanks for these pointers.

Looking at the linked commit 4c82456eeb4d ("fuse: fix type definitions in
uapi header"), it seems you were fine with custom typedefs/defines for
non-Linux targets. But the way it was done previously was problematic for
cross-compilation.

What about the following aproach:

#if defined(__KERNEL__)
#include <linux/types.h>
#elif defined(__linux__)
#include <linux/types.h>
#else
#include <stdint.h>
typedef uint32_t __u32;
...
#endif

(borrowed from include/uapi/drm/drm.h, the identical #if/#elif branches are
necessary for unifdef.

This works correctly when (cross-)compiling the kernel itself. It also uses
the standard UAPI types when used from Linux userspace and also works on
non-Linux userspace. And the header can still be copied into libfuse as is.


Thomas