The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: linux-kernel@vger.kernel.org, Danish Khateeb <danishkhateeb03@gmail.com>
Subject: Re: [PATCH v2 3/4] tools/nolibc: add support for fcntl()
Date: Sat, 5 Dec 2026 15:25:36 +0100	[thread overview]
Message-ID: <axQe4K48XpLYKP66@1wt.eu> (raw)
In-Reply-To: <20261202-nolibc-fcntl-v2-3-651ff5781baa@weissschuh.net>

Hi Thomas!

On Wed, Dec 02, 2026 at 08:29:48AM +0100, Thomas Weißschuh wrote:
> Add the fcntl() function.
> 
> Special handling is necessary for 'struct flock'.
> The definition from the UAPI headers is not large-file capable.
> Provide a custom definition which is compatible with 'struct flock64'
> on 32-bit systems and 'struct flock' on 64-bit ones.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
(...)
> --- a/tools/include/nolibc/types.h
> +++ b/tools/include/nolibc/types.h
> @@ -32,6 +32,21 @@ struct timeval {
>  #include <linux/time.h>
>  #undef timeval
>  
> +struct flock {
> +	short l_type;
> +	short l_whence;
> +	__kernel_loff_t l_start;
> +	__kernel_loff_t l_len;
> +	__kernel_pid_t l_pid;
> +#if defined(__sparc__)
> +	short __pad;
> +#endif
> +};

The commit message makes no mention of this pad and nothing here explains
why it is necessary nor if other architectures might need it in the
future. I suspect it might be that __kernel_pid_t would be 16-bit there,
but I really don't know. I think a comment here in front of__pad to say
why/when it's needed would help.

Also I must confess I'm a bit confused because the same patch seems to mix
fcntl() and flock(), and even _sys_fcntl() relies on flock definition.
There might be a trick there but again it's not explained and the commit
message only says that special handling is required for struct flock,
which makes one wonder if this is a single feature or two distinct features
with one depending on the other.

My impression is that this is mostly flock-centric and that it required to
fix fcntl() first. If that is the case, I think that the fcntl() call should
first do just that with a test on its own that for example does GETFD/SETFD
or GETFL/SETFL, and another one specific to advisory locking because even
the test_fcntl() function actually essentially tests locking from what I
can see. This would also clarify small builds that drop CONFIG_FILE_LOCKING
but which still have a properly working fcntl() implementation (which is
already not trivial to get right especially in compat mode from what I seem
to remember).

Thanks,
Willy

  reply	other threads:[~2026-12-05 14:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  7:29 [PATCH v2 0/4] tools/nolibc: add support for fcntl() Thomas Weißschuh
2026-12-02  7:29 ` [PATCH v2 1/4] tools/nolibc: derive clang target flags from ARCH if CROSS_COMPILE is not set Thomas Weißschuh
2026-12-05 14:33   ` Willy Tarreau
2026-12-02  7:29 ` [PATCH v2 2/4] selftests/nolibc: split out the structure member compatibility checks Thomas Weißschuh
2026-12-02 11:29   ` David Laight
2026-12-05 14:31     ` Willy Tarreau
2026-12-02  7:29 ` [PATCH v2 3/4] tools/nolibc: add support for fcntl() Thomas Weißschuh
2026-12-05 14:25   ` Willy Tarreau [this message]
2026-12-05 14:56     ` Thomas Weißschuh
2026-12-05 16:08       ` Willy Tarreau
2026-12-02  7:29 ` [PATCH v2 4/4] tools/nolibc: remove the open-coded fcntl() in dup2() Thomas Weißschuh
2026-12-05 14:26   ` Willy Tarreau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axQe4K48XpLYKP66@1wt.eu \
    --to=w@1wt.eu \
    --cc=danishkhateeb03@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox