Re: [PATCH 1/3] nolibc: Add statx() support to implement sys_stat()

From: Willy Tarreau
Date: Wed Feb 08 2023 - 09:08:03 EST


On Wed, Feb 08, 2023 at 01:01:48PM +0000, David Laight wrote:
> From: Willy Tarreau
> > Sent: 08 February 2023 08:20
> ....
> > Also looking at the man page I see that statx() only appeared in 4.11,
> > and here we're targetting userland so I'd rather keep a bit of margin
> > when it comes to backwards compatibility, thus not dropping stat() and
> > friends too early when not necessary. However using statx() by default
> > when available sounds fine to me!
>
> Does that really matter?
> Isn't 'nolibc' really just used for programs built in the
> kernel source tree to be release/run with the current kernel?

Not just that even if mostly related, and even in such a case
we'd rather maintain a low level of breakage when it doesn't
require any effort (and moving the ifdef __NR_statx up 20 lines
is perfectly within what I consider low effort).

> I also wonder if building a 'mini_libc.a' that the programs
> can be linked against might be easier than having to
> generate inline versions of everything?

It's another option but a different approach. There are pros and cons
to different approaches. For this, better not reinvent the wheel,
there's already klibc that does this well. A few of us do value the
simplicity of not having to pre-build anything before the test program,
especially when running tests that cover multiple architectures and/or
versions. I'm not saying it's a solution to everything at all, far from
this (and the level of coverage of that code should be self-explanatory
to remind anyone that it's not the goal). But when working on some small
test programs it's quite handy like this.

Regards,
Willy