[Toybox] [PATCH] stat: fix macOS build and behavior.

enh enh at google.com
Mon Feb 22 18:26:34 PST 2021


On Mon, Feb 22, 2021 at 5:39 PM Rob Landley <rob at landley.net> wrote:

> On 2/22/21 4:27 PM, enh via Toybox wrote:
> > My patch to fix df behavior on macOS broke the stat build on macOS.
> >
> > First off, we had %s and %S the wrong way round compared to coreutils,
> > though since Linux always seems to use the same value for both,
> > no-one will ever have noticed.
> >
> > Annoyingly, Linux and macOS disagree about what statfs::f_bsize
> > means, and whether statfs::f_iosize and statfs::f_frsize exist (each
> > has one or the other, depending on what f_bsize *doesn't* mean to
> > them). This mess is presumably why statvfs exists.
>
> Oh that's ugly.
>
> > Unfortunately, statvfs on macOS at least doesn't contain the file
> > system type information.  So we either need to do *both* statfs()
> > and statvfs() for macOS, or we need to take into account the different
> > fields.
> >
> > This patch adds an #ifdef outside of portability.h because I wasn't
> > sure we actually wanted to add statfs_best_transfer_size() and
> > statfs_real_block_size() functions to lib for this. But that's an
> > easy cleanup if desired.
>
> I moved it to static inline wrappers in portability.h, let me know if I
> typoed
> something in the apple part I can't test.
>

github's nice green check mark shows that it _builds_ at least, but, yes,
i've tried with your patch and both stat and df lgtm on macOS now. (i've
sent a patch to add df to the macOS default configuration.)


> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210222/2046b132/attachment-0001.html>


More information about the Toybox mailing list