[Toybox] [PATCH] Fix Mac build.

enh enh at google.com
Wed Mar 11 19:15:35 PDT 2020


okay, so that was an investigation well worth doing...

i tested all the block devices on my mac and linux laptops, and found
(a) i was incorrectly letting the linux <<9 apply to darwin's
already-in-bytes result ... and then realized that the linux result is
already in bytes too (BLKGETSIZE is blocks, but BLKGETSIZE64 is
bytes). patch sent.

but with that fixed, i get the same results for the ioctls and the
seeks on all my block devices, fwiw.

(we could always remove the binary search, see if anyone notices, and
only bring it back if they do... has it been 7 years since you last
saw a broken kernel?)

On Wed, Mar 11, 2020 at 7:37 AM Rob Landley <rob at landley.net> wrote:
>
> On 3/10/20 11:20 AM, enh via Toybox wrote:
> > The recent re-enablement of the BLKGETSIZE64 code broke the Mac
> > build. Use the equivalent <sys/disk.h> ioctl() pair instead.
> > ---
> >  lib/lib.c         |  5 +----
> >  lib/portability.c | 20 ++++++++++++++++++++
> >  lib/portability.h |  2 ++
> >  3 files changed, 23 insertions(+), 4 deletions(-)
>
> I wonder if fdlength() should just move to portability.c at this point?
> (Does the mac ever need the fallback binary search? It was a workaround for a
> linux bug I hit which I'm not 100% sure is still relevant, but "regression test
> with all the block devices out there" is hard to do so I've left it...)
>
> Anyway, applied,
>
> Rob



More information about the Toybox mailing list