mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: наб <nabijaczleweli@nabijaczleweli.xyz>
Cc: Szabolcs Nagy <nsz@port70.net>, musl@lists.openwall.com
Subject: Re: [musl] [PATCH v2] [f]statvfs: allocate spare for f_type
Date: Sat, 24 Aug 2024 11:00:50 -0400	[thread overview]
Message-ID: <20240824150050.GC10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <asc2xecbzzsppxz2lixxhdu4cklfroel4ep34uxlsc7jfyrqii@gfhzy4jgsf6u>

On Thu, Aug 17, 2023 at 10:05:14PM +0200, наб wrote:
> 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.

Revisiting this, the commit message was incorrect, particularly the
wording:

    "This is the only missing part in struct statvfs."

struct statvfs has unsigned long f_fsid, which is only a 32-bit field
and does not represent the full (total 64-bit) pair fsid_t from struct
statfs that Linux provides.

I did some digging into what this actually is, and on filesystems that
have a uuid in the superblock, it's a very basic hash (xor of upper
and lower half) of the uuid into a 64-bit value.

glibc combines the upper and lower half to a single 64-bit unsigned
long on 64-bit archs, but uses only the first 32-bit part on 32-bit
archs. On musl, I intentionally only used the first part to avoid a
functionality discrepancy between 32- and 64-bit archs.

Since then, gnu coreutils has switched from using statfs to statvfs,
producing a "regression" on musl and 32-bit glibc archs. Arguably this
"regression" does not matter, since the value itself is not meaningful
and there's really nothing useful you can do with it, but it's
probably worth noting.

Rich

      reply	other threads:[~2024-08-24 15:01 UTC|newest]

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

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=20240824150050.GC10433@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    --cc=nsz@port70.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).