[Toybox] BSD support
Rob Landley
rob at landley.net
Mon Jan 20 06:30:04 PST 2014
On 01/20/14 02:36, ibid.ag at gmail.com wrote:
> On Sun, Jan 19, 2014 at 09:25:57PM -0700, Zack Breckenridge wrote:
>> Hello all,
>>
>> I understand that this project is Linux focused, but I can't help but
>> wonder if there would be any positive reception to 'porting' Toybox to
>> FreeBSD (and possibly OS X)?
>>
>> I would like to contribute to the project regardless (these are my
>> three main platforms), and I suppose this could be a much larger
>> undertaking than I'm prepared for. Simply curious. Has this been
>> discussed already and apologies if so.
>>
>
> As I recall, Rob has mentioned the idea of porting it, but ran into
> difficulties getting a QEMU image for testing.
I had a thread with Joe Nosay (cc'd). I met Kirk McKusick at Ohio
LinuxFest and told him I couldn't get net, free, or OpenBSD to install
under qemu, and he recommended PCBsd. I got that to install, but the
package management system in the thing doesn't work to install anything
not in the base image (such as mercurial).
Given that it's not 1997 anymore, I find this somewhat limiting...
> So the FreeBSD port should be welcome...if it's done cleanly.
>
> Anyhow, things to watch out for:
> #ifdef __PLATFORM:
> Somewhere, Rob's got a link to "#ifdef considered harmful".
It's linked from http://landley.net/toybox/code.html
There's more advice on http://landley.net/toybox/cleanup.html but that
page is still only half-done...
> We try to avoid #ifdef because it obscures the bigger picture, and
> when it's needed, we try to isolate it (better to have one header full
> of ifdefs than a dozen files...)
>
> Non-portable includes:
> These should _never_ go in toys.h.
> I suspect this might mean adding "toy-platform.h" or something similar.
>
> Non-portable functions:
> I think there's some sort of probing that the toybox build system does...
> See lib/portability.c for how we handle some missing functionality.
>
> "Portable" is more-or-less "That portion of POSIX 2008 that is widely
> implemented", afaict.
I'm using Posix, LSB, the Linux man pages, and actual testing against
other implementations (especially trying to build linux from scratch).
Posix is the only one where I need a good excuse _not_ to do what it
says (preferably including a comment in the command implementation that
we've deviated, such as the one in toys/posix/who.c). LSB and the man
pages are advisory.
> Also, be sure to check whether it makes sense to use a command on the
> kernel you are porting to. pivot_root may well be irrelevant for you.
I expect bsd will only ever support a subset of the commands, because
we're not afraid to be linux-specific. For example, things like ifconfig
make liberal use of /proc, my next wave of umount adds losetup -d
support (loopback) and -a support using /proc/mounts (or that horrible
/proc/mountinfo hack), my half-finished mount code grovels around in
/proc/filesystems trying to mount something you didn't tell it -t for...
That said there's no reason stuff like sort and sed can't work equally
well on bsd.
There is a lib/platform.h and lib/platform.c that you're welcome to add
as much bsd-specific glue to as you can stomach. Those are the places
for them.
Rob
1390228204.0
More information about the Toybox
mailing list