[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260105104342-8d6f1457-f422-4ef6-ac66-5170869a5ec7@linutronix.de>
Date: Mon, 5 Jan 2026 10:57:17 +0100
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Bernd Schubert <bernd@...ernd.com>
Cc: Miklos Szeredi <miklos@...redi.hu>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v2] fuse: uapi: use UAPI types
On Mon, Jan 05, 2026 at 09:50:30AM +0100, Bernd Schubert wrote:
>
>
> On 1/5/26 09:40, Thomas Weißschuh wrote:
> > On Sat, Jan 03, 2026 at 01:44:49PM +0100, Bernd Schubert wrote:
> >>
> >>
> >> On 1/2/26 23:27, Bernd Schubert wrote:
> >>>
> >>>
> >>> On 12/30/25 13:10, 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.
> >>>> To keep compatibility with non-Linux platforms, add a stdint.h fallback.
> >>>>
> >>>> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
> >>>> ---
> >>>> Changes in v2:
> >>>> - Fix structure member alignments
> >>>> - Keep compatibility with non-Linux platforms
> >>>> - Link to v1: https://lore.kernel.org/r/20251222-uapi-fuse-v1-1-85a61b87baa0@linutronix.de
> >>>> ---
> >>>> include/uapi/linux/fuse.h | 626 +++++++++++++++++++++++-----------------------
> >>>> 1 file changed, 319 insertions(+), 307 deletions(-)
> >>>
> >>> I tested this and it breaks libfuse compilation
> >>>
> >>> https://github.com/libfuse/libfuse/pull/1410
> >>>
> >>> Any chance you could test libfuse compilation for v3? Easiest way is to
> >>> copy it to <libfuse>/include/fuse_kernel.h and then create PR. That
> >>> includes a BSD test.
> >
> > Ack.
> >
> >>> libfuse3.so.3.19.0.p/fuse_uring.c.o -c
> >>> ../../../home/runner/work/libfuse/libfuse/lib/fuse_uring.c
> >>> ../../../home/runner/work/libfuse/libfuse/lib/fuse_uring.c:197:5: error:
> >>> format specifies type 'unsigned long' but the argument has type '__u64'
> >>> (aka 'unsigned long long') [-Werror,-Wformat]
> >>> 196 | fuse_log(FUSE_LOG_DEBUG, " unique: %" PRIu64
> >>> ", result=%d\n",
> >>> | ~~~~~~~~~
> >>> 197 | out->unique, ent_in_out->payload_sz);
> >>> | ^~~~~~~~~~~
> >>> 1 error generated.
> >>>
> >>>
> >>> I can certainly work it around in libfuse by adding a cast, IMHO,
> >>> PRIu64 is the right format.
> >
> > PRIu64 is indeed the right format for uint64_t. Unfortunately not necessarily
> > for __u64. As the vast majority of the UAPI headers to use the UAPI types,
> > adding a cast in this case is already necessary for most UAPI users.
> >
> >> I think what would work is the attached version. Short interesting part
> >>
> >> #if defined(__KERNEL__)
> >> #include <linux/types.h>
> >> typedef __u8 fuse_u8;
> >> typedef __u16 fuse_u16;
> >> typedef __u32 fuse_u32;
> >> typedef __u64 fuse_u64;
> >> typedef __s8 fuse_s8;
> >> typedef __s16 fuse_s16;
> >> typedef __s32 fuse_s32;
> >> typedef __s64 fuse_s64;
> >> #else
> >> #include <stdint.h>
> >> typedef uint8_t fuse_u8;
> >> typedef uint16_t fuse_u16;
> >> typedef uint32_t fuse_u32;
> >> typedef uint64_t fuse_u64;
> >> typedef int8_t fuse_s8;
> >> typedef int16_t fuse_s16;
> >> typedef int32_t fuse_s32;
> >> typedef int64_t fuse_s64;
> >> #endif
> >
> > Unfortunately this is equivalent to the status quo.
> > It contains a dependency on the libc header stdint.h when used from userspace.
> >
> > IMO the best way forward is to use the v2 patch and add a cast in fuse_uring.c.
>
> libfuse is easy, but libfuse is just one library that might use/copy the
> header. If libfuse breaks the others might as well.
Yes, unfortunately.
> Maybe you could explain your issue more detailed? I.e. how are you using
> this include exactly?
I want the linux/fuse.h to work together with -nostdinc.
This has various advantages:
* It allows compilers for other languages to parse the C headers without
the dependency on a full toolchain.
* It enables the usage in other, non-libc based C environments.
* Together with [0], it allows the verification of the header for all
architectures. For example Arnd works on validating the UAPI against -Wpadded
which requires the header to be built for each architecture.
This affected me at [1] and now I'm trying to proactively avoid this issue in
other places and prevent its re-introduction.
[0] https://lore.kernel.org/lkml/20251223-uapi-nostdinc-v1-0-d91545d794f7@linutronix.de/
[1] https://lore.kernel.org/lkml/20251203-uapi-fcntl-v1-1-490c67bf3425@linutronix.de/
Thomas
Powered by blists - more mailing lists