From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796562491; b=UwrijpgGpsxqPoSjt0PADw6q9VKOsRrrOPMNa8o035kYrG9BhZ2ydHfdi1tvmpCtHVwL SsKJAsq0ctUuOmH9yO3Zzl7NTmQc+xKV8da+J0cjaV/pHR/KWCu5BM2HsdSVCoCQiv2Sq rAI7oBjBavHSezmVarUqHyKOSRutzYnRcmB4UoGsHDWSYgK8wy3Idoe0bjXxsoC6ZuLzg kkbAYiZ61DZ4XNUkB3vFQrXYNjs7bbRqWEbmKxOFE+L3FyDtx53XnvDOf2Gyiqsw0KwYt siursUOGgSUl9+226y6bQ8qzFz3xRZQpdIz+haWyLnaXm+qLkh6GoDpm8QHcoW08EqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796562491; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=rhjAE4jzyYr9NYSORHAImsF130i2aDasMbyeOjjAMis=; b=YjVz/NZ+dsNT6y37hvVdMsSqlrnHMzM58lG2EMUdiaBQQCrEezWia8aNqHJ1EmYADAP6 xq5YhpKqnAx1yueLZSh0LRFhrl61fhk9PYlgPNEMAuXH56yaPr6USG+/PPGCxqszmnxSO I9SaeKwGG20m2IQZACwPo1USc6nINNwnhz6jnuB4VxEW027xj8GY+vdOuFSuI1z3ngGzu /Cy2f4roSuqq7AiPUkC38eGDBGlUklT7ATozRpPQFtS5FnKTgDVccKII+O3UcIbju5gqF ogEDB1OXPTQ1VNDW3TjRuzndQldQl5UCUgIgk0YGg5lWRl0rxsasQAHVk0s0Wc10srQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SVoZ7Tfr; arc=none smtp.remote-ip=209.85.128.42 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AEC0606A31F for ; Sun, 6 Dec 2026 13:08:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7AEC0606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SVoZ7Tfr Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4bba5e17cbeso21707615e9.1 for ; Sun, 06 Dec 2026 05:08:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796562490; x=1797167290; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=rhjAE4jzyYr9NYSORHAImsF130i2aDasMbyeOjjAMis=; b=SVoZ7TfrEkiQiU2Kjze1iLWpNVQrs6o8f+4u1v6kRxJbGxm7vbHTNpTFR3XGuqv70D PMzSzEHDKLl3v4EmTYOIz06ezR8Z/qieAnaqfqP67rhleNRgAfQ4OMoEsCL8QQcPg4gb t6G1AnZYK51ZiW7BXBkCmQdzpRDVKl5c82vrL1cTfrAd5YmwUkc20aD9ddtlEaWyDExa 0pNFubl166WzufFckZ+KUm2D/G+RDDduID6g38oUv2WvTkd9z6MJFLzGPkPnwRiZj7h1 h46kMRrXJbJtdmw0NJ7nitrjQaB51r71I6JC1pwi4ZaTe6NMewLd5CLpUNGPXcdFOBJf wkqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796562490; x=1797167290; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rhjAE4jzyYr9NYSORHAImsF130i2aDasMbyeOjjAMis=; b=00evWP+1HHG0jkAVykVzvQ8HeciiOlERDiuLglSZWAcEXhmvgi/4lqz/JZMlckO3se v7fQ8Sqop41oyehxBESTU+9tjCM2HmGEwfWVzmYfWtXXWSAEM5z3TQj0+HYdBWJrnbqM 7/J2Wp55OF6DJAC0R3D7Adc2IgyYdsrgQR7Tuu2ZC+U0YZIS29AgyF3mCpbQWVcdIHOY rK0UImMTYKwmCJGGoRPzGr4eROy8GiKJmC7dRM5k1o3YyCR43MGmzx++031uO7J2C5Yz dYN8hSvBncnkeCkNIp9t6zJ7+LvwifpIOG2ZoA+RWoKAKmL7Dxz2qsVPAMWgAJJxBVez 4UZA== X-Forwarded-Encrypted: i=1; AL+hErFY0Xkt99GFzSvqDfKsAnB2RLrLj1d8F1SvBQYl6vErPkLSVK536jjrHgz/Ke4N0VVAom9zuelad2GGOhg=@vger.kernel.org X-Gm-Message-State: APuU4Z9LcVvkAY21dlITE2pCLOYPnywJ/OgtDW2SIAMeCdEckZyPqoT9 5gjgDt//gQpuWqbmy58ANa6ZoIk4PjS8ca1F6o2/6KLs/OrOrFqKt5Ff58OiAqd/ X-Gm-Gg: AZFdTZc4SgiEcRK3JD8gu6hHhSn/sMZMIPnNhu4Uo6rsv+gcaygEK7n3D9bQmIMyJvV vT5ekM5DenigQHXVX7CNB7tfCP4aeHKyTfZcl9riMSnEPeG4FCR1juEtpLQaL5Po6BycpEbsp8n 7uJsCO3rQyCgADjSvt1quir/5PmzqG26x8MuQOr+uhjBKBWLR2dZZ4GnZDfSiBgwJnxgC1g4ZIe ZEygnjGVtFJFgIYDHaynrRlGUVyA9Hp+1AGt2ASDck3N2eTmiANvLkar0BmQU+H1bXmtZgwMRvS K6CYcNChmgCoF/HdPwFGYDvPvKT+dzxG0dbDyLUyBqcUwrJClTGQ+3B8C2s9RcZO+Nq3+ojlQPU otUa9AfVBb89Qskqx/pUoXoS8FalMGvbHaXqIHLp+zUTvRefb1YT208YPlbEqhH5T8QvaqvWcpB teXj05mjVKAQjzo7SWaxzyvSFl+ctGA+s0V6htnd6JCwAIKTSPhk8xkAac3PNWfQe8gCjshv7T/ rYIbQ9IGCynxnMT5jKsaB86Dg3krtvWTMgykXrTO8dKtqIo4HFNyAgFjLyb0PMuAU0Ug+xiozLH WJiyiH5Xhgw8MoqCrI9x9Mc1KvWrnXypDt9f5f2BsXpHMmVFnOMHgWCIminzqIs2 X-Received: by 2002:a05:600d:82f2:b0:4bb:6a5a:7834 with SMTP id 5b1f17b1804b1-4bbeb8ae149mr150849335e9.20.1796562489725; Sun, 06 Dec 2026 05:08:09 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbf17c5c11sm112743045e9.3.2026.12.06.05.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 05:08:09 -0800 (PST) Date: Sun, 6 Dec 2026 13:08:03 +0000 From: David Laight To: Willy Tarreau Cc: Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= , linux-kernel@vger.kernel.org, Danish Khateeb , hch@lst.de Subject: Re: [PATCH v2 3/4] tools/nolibc: add support for fcntl() Message-ID: <20261206130803.60d5f61d@pumpkin> In-Reply-To: References: <20261202-nolibc-fcntl-v2-0-651ff5781baa@weissschuh.net> <20261202-nolibc-fcntl-v2-3-651ff5781baa@weissschuh.net> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, 5 Dec 2026 15:25:36 +0100 Willy Tarreau wrote: Christoph - see note about MIPS32 'struct flock'. > Hi Thomas! >=20 > On Wed, Dec 02, 2026 at 08:29:48AM +0100, Thomas Wei=C3=9Fschuh wrote: > > Add the fcntl() function. > >=20 > > 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. > >=20 > > Signed-off-by: Thomas Wei=C3=9Fschuh =20 > (...) > > --- a/tools/include/nolibc/types.h > > +++ b/tools/include/nolibc/types.h > > @@ -32,6 +32,21 @@ struct timeval { > > #include > > #undef timeval > > =20 > > +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 > > +}; =20 >=20 > 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. My brain remembers something about sparc having an extra field. But I can't remember what it was used for, and it was __unused when the file was added to Linux for 1.3.44. The corresponding types.h has a 32bit pid_t - so it isn't just an explicit pad. (Although SunOS might have had a 16bit pid and made the pad reasonable.) I think it also pointless, The size of the structure isn't passed into the kernel (it would need and ioctl() that used IORW()) and the kernel doesn't seem to have ever cleared the user field. It might be relevant if you were compiling against the Linux headers but expected to run on some other OS - but that just won't work. (SYSV sparc binaries would 'just about' run on SunOS - but it was largely theoretical and was responsible for some nasty bugs.) Rather more problematic is MIPS32, change 9f79b8b7 'simplified' the pad. But managed to move the l_sysid field the other side of l_pid. David >=20 > 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 featur= es > with one depending on the other. >=20 > 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 sho= uld > first do just that with a test on its own that for example does GETFD/SET= FD > 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_LOCKI= NG > but which still have a properly working fcntl() implementation (which is > already not trivial to get right especially in compat mode from what I se= em > to remember). >=20 > Thanks, > Willy >=20