[Toybox] NFS mounting with toybox (kernel patch).

Rob Landley rob at landley.net
Wed Mar 9 13:06:11 PST 2016


The question came up about how to mount an nfs server with toybox. I
remembered from my contract with parallels in 2010 that I used to do
that: http://landley.livejournal.com/49382.html

So I gave it a go, and found out that the kernel guys broke the text
parsing, and I needed the attached patch (tested on linux-4.4) to fix
it.

Background: behind the scenes the mount -o options filter out a bunch
of flag values (which get passed to the mount syscall as an integer of
various MS_BLAH values or-ed together) and the rest of the values are
passed through as a comma separated text string.

I.E. for every filesystem EXCEPT nfs, options is a text string.

But for NFS it can can either be a text string or a binary blob with
the first digit being a low-ascii value indicating the version number.
If the first digit ISN'T a low-ascii value, it's treated as text and
parsed as text, and since there's nothing the binary blob can do that
the text string _can't_, there's NO REASON to ever use the binary
blob. It's there for historical reasons, and it has versions because
every time they added a new option they had to extend the structure
with more fields at the end, where string parsing just goes
",fruitbasket=42" and you're good.

I.E. NFS was historically stupid, but had a way not to be.

Naturally, the util-linux mount special cases NFS and produces a
binary blob, and so does busybox. Toybox doesn't because it's STUPID,
and so we're using the generic codepath which has been there
forever... and bit-rotted because nobody was testing it.
<the-aristocrats>NFS!</the-aristocrats>

Anyway, with that patch to the kernel and current toybox-git, I built
http://unfs3.sf.net and ran this on the host:

  $ echo "/home/landley (no_root_squash,insecure)" > blah.cfg
  $ ./unfsd -d -s -p -e $PWD/blah.cfg -l 127.0.0.1 -m 9999 -n 9999

And then in qemu:

  $ mount -t nfs -o ro,port=9999,mountport=9999,nolock,v3,udp \
    10.0.2.2:/home/landley /mnt

And it worked.

(The reason for specifying all that -m9999 stuff is telling it to use
a high port number so I don't have to run the nfs server as root on
the host. I'm aware there's a built-in kernel NFS server. I'm also
aware there used to be a built-in kernel httpd, and they're equally
bad ideas. No really, http://www.linuxjournal.com/article/4132 and it
died because it was a BAD IDEA. There aren't built-in kernel SMB or
DNS servers, v9fs doesn't have an in-kernel server, it's REALLY STUPID
that NFS does and I'm not messing with it. Hence testing against
unfs3.)

If somebody wants to send the kernel patch to linux-kernel, feel free
to add my signed-off-by. I'm still under the weather and really not up
to dealing with... them... right now.

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linux-fixnfs.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20160309/af3c2280/attachment-0004.bin>


More information about the Toybox mailing list