mailing list of musl libc
 help / color / mirror / code / Atom feed
From: наб <>
Subject: [musl] [PATCH] [f]statvfs: allocate spare for f_type
Date: Fri, 23 Jun 2023 22:36:11 +0200	[thread overview]
Message-ID: <2a5yr4pg5a2lt5enykfhqezpggsdhkn6j2cpslls5n26qaffss@jz5pftqutx6t> (raw)

[-- Attachment #1: Type: text/plain, Size: 1713 bytes --]

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 extension to the standard interface on Linux,
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.

 include/sys/statvfs.h | 3 ++-
 src/stat/statvfs.c    | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h
index 57a6b806..71d9d1f9 100644
--- a/include/sys/statvfs.h
+++ b/include/sys/statvfs.h
@@ -23,7 +23,8 @@ struct statvfs {
 	unsigned long f_fsid;
 	unsigned long f_flag, f_namemax;
-	int __reserved[6];
+	unsigned int f_type;
+	int __reserved[5];
 int statvfs (const char *__restrict, struct statvfs *__restrict);
diff --git a/src/stat/statvfs.c b/src/stat/statvfs.c
index bfbb5fee..bc12da8b 100644
--- a/src/stat/statvfs.c
+++ b/src/stat/statvfs.c
@@ -39,6 +39,7 @@ static void fixup(struct statvfs *out, const struct statfs *in)
 	out->f_fsid = in->f_fsid.__val[0];
 	out->f_flag = in->f_flags;
 	out->f_namemax = in->f_namelen;
+	out->f_type = in->f_type;
 int statvfs(const char *restrict path, struct statvfs *restrict buf)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2023-06-23 20:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 20:36 наб [this message]
2023-06-24  4:39 ` Szabolcs Nagy
2023-08-17 20:05   ` [musl] [PATCH v2] " наб

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:

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

  git send-email \
    --in-reply-to=2a5yr4pg5a2lt5enykfhqezpggsdhkn6j2cpslls5n26qaffss@jz5pftqutx6t \ \ \

* 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.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).