From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=51.159.59.229 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796486903; b=XVJ1HRkgR4HX/5eSterbhiqCk+70+PgzIbt+3mSbF73d4QjPu62RgYjabYzdIxgkOUuW 7UFwjI4+qa11zvltvBym8T5294VvhnXiFqgqpuN2mx1vpXLBaVKrdEqhw0Hr1S+s4y3i1 YJhfu0MLyZVNZapGXVjOU6E12GnaMB6Y17gE0KoPOWQ2wJSfR1CPwd5RolwieNw3tsUWN im2STYLEjakl4sc8A39N4MJUeER+ahHlIi1diGSUi4ac0tHXZJIIkp/Oz4ZFJktOxjTEV 71W4iaU3r6qk9nNyme4qeokmHtSWD9DOHXz9gwGIQHCNGqmvqjzp1aVXlMFmAS8JBOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796486903; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=8q2qO7un+PO/oIKuLCKYsdydcp2zhc3nkfezB4Kh4vI=; b=vtJY9mSiMxpsFQ8YOZ5e9rUw3D1oQH+hXY0eLrNaMdaKDOLK90V+5V1bh3aBLT4e2E91 p3XDyc8oqIZHU461s9M6bz4hTmBRxGtXvC/CFru9kN+XIblnYQc8mQny/1Yhlz4Bo8+SG OzN6+T9650Ja+UKKSYr/FAWSgxXPZE1CeLooOG0JwTFS6Y8RrBT5MepM3Y7E4apguUJmS rsdlRoTGy7VL6cXsZ/Xo2qCO7wjh0hXrKBzecoKd7Q9Fzbnfio+FQHIOnIcUR1bg/GeY+ GNQwaV1LZqdSCIsd/Bup5iOM/YhH1OOsrtuEa+D6Nfmlsq1HzwB3IJD5Ai0S2tpcSYw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; dkim=pass header.d=1wt.eu header.i=@1wt.eu header.a=rsa-sha256 header.s=mail header.b=VzeCbxq4; arc=none smtp.remote-ip=51.159.59.229 Received: from mta1.formilux.org (mta1.formilux.org [51.159.59.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A71E6606A31F for ; Sat, 5 Dec 2026 16:08:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A71E6606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=1wt.eu header.i=@1wt.eu header.a=rsa-sha256 header.s=mail header.b=VzeCbxq4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1796486899; bh=8q2qO7un+PO/oIKuLCKYsdydcp2zhc3nkfezB4Kh4vI=; h=From:Message-ID:From; b=VzeCbxq4BUuKxQFE1zZgEliNI22M+MuYTTl7MHddzFfFQAFrogvLBuJ4JX26wrXFe z82499WpBzNlsDR+ZAl1DflrnJ/RASEH68glV1SATCZivgFxYUQqnqEtLgYwr9mY+q lLT0eW0h0rAiU5ZogFYcrnpFupUA2qnMU2pbOgVg= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id 5DE6FC000B; Sat, 05 Dec 2026 17:08:19 +0100 (CET) Date: Sat, 5 Dec 2026 17:08:18 +0100 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: linux-kernel@vger.kernel.org, Danish Khateeb Subject: Re: [PATCH v2 3/4] tools/nolibc: add support for fcntl() Message-ID: References: <20261202-nolibc-fcntl-v2-0-651ff5781baa@weissschuh.net> <20261202-nolibc-fcntl-v2-3-651ff5781baa@weissschuh.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Sat, Dec 05, 2026 at 03:56:56PM +0100, Thomas Weißschuh wrote: > Hi! > > On 2026-12-05 15:25:36+0100, Willy Tarreau wrote: > > 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 > > (...) > > > --- a/tools/include/nolibc/types.h > > > +++ b/tools/include/nolibc/types.h > > > @@ -32,6 +32,21 @@ struct timeval { > > > #include > > > #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. > > The pad member is necessary to match the UAPI definition. If we leave it > out the kernel will overwrite unrelated data. None of the existing > architectures will require this padding in the future as it would break > the ABI and I don't think new architectures will require it either. > As far as I can see this is unrelated to __kernel_pid_t. > I'll add a comment. Thanks! I also thought about __attribute__((aligned)) but that doesn't cope well with packed structs while an exact pad will work. > > 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. > > This is completely unrelated to flock(). > > > 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). > > GETFD/GETFL are trivial and I did not deem it necessary to have a > testcase for them. My goal with the GETLK/SETLK test was not to verify > that the locking works but that the types line up correctly with what > the kernel expect. If we have a simpler fcntl() which does not handle > 'struct flock' then that version is effectively broken if anyone uses > the locking operations. I can however split the commit up, the first > commit introduces the 64-bit 'struct flock' and the second adds fcntl(). Maybe, because just reading the patch and commit message, I'm really having difficulties figuring why so much flock just for fcntl(), which I commonly use but basically never with GETLK/SETLK so this example doesn't ring as something obvious when I read it. Otherwise maybe a richer commit message explaining why flock appears here with fcntl() could possibly be fine as well. In this case, maybe the test should use "fcntl(SETLK)" instead of "fcntl()" alone, because that's really what it's testing, and its support is optional, so one could accept to ignore it failing knowing that they disabled the build option, without being scared that fcntl() itself might be broken. Thanks! Willy