Like every other website on the planet, SmallNetBuilder uses cookies. Our cookies track login status, but we only allow admins to log in anyway, so those don't apply to you. Any other cookies you pick up during your visit come from advertisers, which we don't control.
If you continue to use the site, you agree to tolerate our use of cookies. Thank you!

Router Charts

Click for Router Charts

Mesh Charts

Click for Mesh Charts

Modifying and Building the Portmapper

Now we can move on to bigger and better things. It may seem a big step to go from "Hello World" to NFS, but it's not too bad. First we need to install and setup the Linux source tree in order to access the required include files. The source tree can be found in the snapgear tar file included on the CD distributed with the NSLU2.

First untar the snapgear tar file in your build area. Since we are not going to be building the kernel, we'll take a shortcut setting up for an ARM architecture. Create and execute the following script from within the snapgear/linux-2.4.x directory :

#!/bin/bash rm -f include/asm rm -f include/asm-arm/proc rm -f include/asm-arm/arch ( cd include; ln -s asm-arm asm ) ( cd include/asm-arm; ln -s proc-armv proc ) ( cd include/asm-arm; ln -s arch-ixp425 arch )

Now we should be set up for more complex builds. NFS is based on a Remote Procedure Call architecture. In order for RPC to function, it needs a helper daemon called the portmapper. I found portmapper source code here, and source for an NFS server here. After untarring the source trees you should end up with portmap_4 directory, a snapgear directory and a nfs-server-2.2beta47 directory along with the original gpl_code_2.03 directory.

Next let's build the portmapper. I had to make a few changes to the Makefile to simplify the build. First, I commented out the line : HOSTS_ACCESS= -DHOSTS_ACCESS, to reduce an external library dependence. Everywhere I saw a reference to libwrap.a I also commented it out for the same reason. For a more secure server, these can be put back, but additional libraries will be needed.

I then modified the CFLAGS line to point to my snapgear linux source tree :

CFLAGS = $(COPT) -O $(NSARCHS) $(SETPGRP) -I /home/jbuzbee/snapgear/linux-2.4.x/include/

Finally, in the top of the makefile, I added the following line in order to invoke the cross compiler:


In addition to the makefile changes, I needed to make a small source change. In the file portmap.c, there's a perror function defined that overrides the standard perror. I changed the argument definition from const char to __const char so as to match the stdio.h definition in our cross compilation tree.

Now, all that is required is a "make". This produces a number of warnings, but the build should run to completion. Next strip the binary to save memory for our little box:

# armv4b-hardhat-linux-strip portmap

Support Us!

If you like what we do and want to thank us, just buy something on Amazon. We'll get a small commission on anything you buy. Thanks!

Don't Miss These

  • 1
  • 2