From patchwork Sun Aug 6 20:23:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 1817558 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=blzPW72v; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RJrWP3Fz5z1yXs for ; Mon, 7 Aug 2023 06:23:44 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D6883858D1E for ; Sun, 6 Aug 2023 20:23:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D6883858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691353422; bh=+uTyd+PrXwS3OGMdNqT8iBw2LGsWrULWWChpyEYU5TE=; h=Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=blzPW72vqSnHCZMFKcmUmeSq/MSgp/D2tkVndkX5LSvG8vCIivfAvfj+OHbVqLHbV oTqpzGytFWt7NkutH2MpLE5J+4Eu1w6p6quo3xNYSf6m2L8mU8L3Urb5Lva8Z4Li1i GhATWhSs9mOHtE607puQGEfs/ognqOhAjaFf84uU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) by sourceware.org (Postfix) with ESMTP id CC0003858D1E for ; Sun, 6 Aug 2023 20:23:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC0003858D1E Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 58840585A; Sun, 6 Aug 2023 22:23:25 +0200 (CEST) Date: Sun, 6 Aug 2023 22:23:24 +0200 Cc: Florian Weimer , libc-alpha@sourceware.org, Adhemerval Zanella Netto Subject: [PATCH v6 1/2] hurd: statvfs: __f_type -> f_type Message-ID: <5e96c8b1f617683af24953286ce646a8e6b996a4.1691259968.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20230517 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, MISSING_HEADERS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?b?0L3QsNCxIHZpYSBMaWJjLWFscGhh?= From: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= Reply-To: =?utf-8?b?0L3QsNCx?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" No further changes needed ([f]statvfs() just cast to struct statfs * and call [f]statfs()). Link: https://lore.kernel.org/linux-man/f54kudgblgk643u32tb6at4cd3kkzha6hslahv24szs4raroaz@ogivjbfdaqtb/t/#u Signed-off-by: Ahelenia Ziemiańska Reviewed-by: Samuel Thibault --- Clean rebase on 2.39. sysdeps/mach/hurd/bits/statvfs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/mach/hurd/bits/statvfs.h b/sysdeps/mach/hurd/bits/statvfs.h index 3fbfd93335..a94759ef55 100644 --- a/sysdeps/mach/hurd/bits/statvfs.h +++ b/sysdeps/mach/hurd/bits/statvfs.h @@ -29,7 +29,7 @@ struct statvfs { - unsigned int __f_type; + unsigned int f_type; unsigned long int f_bsize; #ifndef __USE_FILE_OFFSET64 __fsblkcnt_t f_blocks; @@ -59,7 +59,7 @@ struct statvfs #ifdef __USE_LARGEFILE64 struct statvfs64 { - unsigned int __f_type; + unsigned int f_type; unsigned long int f_bsize; __fsblkcnt64_t f_blocks; __fsblkcnt64_t f_bfree; From patchwork Sun Aug 6 20:23:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 1817559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=n14LY46j; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RJrWf0qTkz1yXs for ; Mon, 7 Aug 2023 06:23:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE1CA3858291 for ; Sun, 6 Aug 2023 20:23:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE1CA3858291 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691353434; bh=G1pDi+QBjBaUXN3rxg6d2/cGxdVmbTMh5E3hwQYYh5A=; h=Date:Cc:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=n14LY46jxsxdjPtwhAfrG2rDhSrHIMy1A7pFhbeQK14nHFEsDdF2im//yZ1pj8m4x Wg2uZXP0xhNkH8hrzY1Oq2DV+xyVmScmyNn4t29HFm+OtpHNoftLDT2tyfhzOHIUch EarkCQytxfaDmNZX6P5iRqQooYqx2Ll6CxBWiYM4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) by sourceware.org (Postfix) with ESMTP id 832CB3858433 for ; Sun, 6 Aug 2023 20:23:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 832CB3858433 Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id D2398585C; Sun, 6 Aug 2023 22:23:37 +0200 (CEST) Date: Sun, 6 Aug 2023 22:23:36 +0200 Cc: Florian Weimer , libc-alpha@sourceware.org, Adhemerval Zanella Netto Subject: [PATCH v6 2/2] linux: statvfs: allocate spare for f_type Message-ID: <82ec12978ff2b88fa8385ba00836060e4ea6424d.1691259968.git.nabijaczleweli@nabijaczleweli.xyz> References: <5e96c8b1f617683af24953286ce646a8e6b996a4.1691259968.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5e96c8b1f617683af24953286ce646a8e6b996a4.1691259968.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20230517 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, MISSING_HEADERS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?b?0L3QsNCxIHZpYSBMaWJjLWFscGhh?= From: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= Reply-To: =?utf-8?b?0L3QsNCx?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This is the only missing part in struct statvfs. The LSB calls [f]statfs() deprecated, and its weird types are definitely off-putting. However, its use is required to get f_type. Instead, allocate one of the six spares to f_type, copied directly from struct statfs. This then becomes a small glibc extension to the standard interface on Linux and the Hurd, instead of two different interfaces, one of which is quite odd due to being an ABI type, and there no longer is any reason to use statfs(). The underlying kernel type is a mess, but all architectures agree on u32 (or more) for the ABI, and all filesystem magicks are 32-bit integers. We don't lose any generality by using u32, and by doing so we both make the API consistent with the Hurd, and allow C++ switch(f_type) { case RAMFS_MAGIC: ...; } Also fix tst-statvfs so that it actually fails; as it stood, all it did was return 0 always. Test statfs()' and statvfs()' f_types are the same. Link: https://lore.kernel.org/linux-man/f54kudgblgk643u32tb6at4cd3kkzha6hslahv24szs4raroaz@ogivjbfdaqtb/t/#u Signed-off-by: Ahelenia Ziemiańska Reviewed-by: Adhemerval Zanella --- Clean rebase on 2.39, NEWS moved to the 2.39 sexion. NEWS | 5 ++++- io/tst-statvfs.c | 19 +++++++++++-------- sysdeps/unix/sysv/linux/bits/statvfs.h | 6 ++++-- sysdeps/unix/sysv/linux/internal_statvfs.c | 2 ++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 22875d5fa4..97379002f3 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,10 @@ Version 2.39 Major new features: - [Add new features here] +* struct statvfs now has an f_type member, equal to the f_type statfs member; + on the Hurd this was always available under a reserved name, + and under Linux a spare has been allocated: it was always zero + in previous versions of glibc, and zero is not a valid result. Deprecated and removed features, and other changes affecting compatibility: diff --git a/io/tst-statvfs.c b/io/tst-statvfs.c index 227c62d7da..f3097ce1a8 100644 --- a/io/tst-statvfs.c +++ b/io/tst-statvfs.c @@ -1,5 +1,7 @@ #include +#include #include +#include /* This test cannot detect many errors. But it will fail if the @@ -11,17 +13,18 @@ do_test (int argc, char *argv[]) for (int i = 1; i < argc; ++i) { struct statvfs st; - if (statvfs (argv[i], &st) != 0) - printf ("%s: failed (%m)\n", argv[i]); - else - printf ("%s: free: %llu, mandatory: %s\n", argv[i], - (unsigned long long int) st.f_bfree, + struct statfs stf; + TEST_COMPARE (statvfs (argv[i], &st), 0); + TEST_COMPARE (statfs (argv[i], &stf), 0); + TEST_COMPARE (st.f_type, stf.f_type); + printf ("%s: free: %llu, mandatory: %s, tp=%x\n", argv[i], + (unsigned long long int) st.f_bfree, #ifdef ST_MANDLOCK - (st.f_flag & ST_MANDLOCK) ? "yes" : "no" + (st.f_flag & ST_MANDLOCK) ? "yes" : "no", #else - "no" + "no", #endif - ); + st.f_type); } return 0; } diff --git a/sysdeps/unix/sysv/linux/bits/statvfs.h b/sysdeps/unix/sysv/linux/bits/statvfs.h index 8dfb5ce761..cf98460e00 100644 --- a/sysdeps/unix/sysv/linux/bits/statvfs.h +++ b/sysdeps/unix/sysv/linux/bits/statvfs.h @@ -51,7 +51,8 @@ struct statvfs #endif unsigned long int f_flag; unsigned long int f_namemax; - int __f_spare[6]; + unsigned int f_type; + int __f_spare[5]; }; #ifdef __USE_LARGEFILE64 @@ -71,7 +72,8 @@ struct statvfs64 #endif unsigned long int f_flag; unsigned long int f_namemax; - int __f_spare[6]; + unsigned int f_type; + int __f_spare[5]; }; #endif diff --git a/sysdeps/unix/sysv/linux/internal_statvfs.c b/sysdeps/unix/sysv/linux/internal_statvfs.c index 6a1b7b755f..112d3c241a 100644 --- a/sysdeps/unix/sysv/linux/internal_statvfs.c +++ b/sysdeps/unix/sysv/linux/internal_statvfs.c @@ -57,6 +57,7 @@ __internal_statvfs (struct statvfs *buf, const struct statfs *fsbuf) buf->__f_unused = 0; #endif buf->f_namemax = fsbuf->f_namelen; + buf->f_type = fsbuf->f_type; memset (buf->__f_spare, '\0', sizeof (buf->__f_spare)); /* What remains to do is to fill the fields f_favail and f_flag. */ @@ -99,6 +100,7 @@ __internal_statvfs64 (struct statvfs64 *buf, const struct statfs64 *fsbuf) buf->__f_unused = 0; #endif buf->f_namemax = fsbuf->f_namelen; + buf->f_type = fsbuf->f_type; memset (buf->__f_spare, '\0', sizeof (buf->__f_spare)); /* What remains to do is to fill the fields f_favail and f_flag. */