I’m trying to write a user-space file system for a school project, and I’m going to do this on OS X. FUSE doesn’t seem to have been ported to OS X yet, so I’m trying instead to write it as a user-land NFS server. This seems to be problematic, though, so I’m asking you for help, my dear lazyweb:
I’ve used rpcgen on the NFS v2 XDF description to generate the stub code. This seems obvious enough: it generates a bunch of svc stubs that I need to implement, to implement the functionality of my file system. It does its magic by unregistering any other NFS server with portmap:
(void) pmap_unset(NFS_PROGRAM, NFS_VERSION);
Then it wraps up my socket (which I bind to 127.0.0.1, because I only want it available locally) into SVCXPRT object, and I pass this to:
svc_register(transp, NFS_PROGRAM, NFS_VERSION, nfs_program_2, IPPROTO_UDP)
Now, pmap_unset and svc_register both try to talk to the portmapper, which isn’t running on my machine, so they both hang for about a minute, then exit with a failure. Trying to launch portmap by hand results in:
portmap[1124]: PID 441 started this second instance of portmap (the first instance may not be running, as it launches on demand via launchd), exiting!
That’s nice. Thanks, Apple.
So, I have a variety of questions:
- Do I really need
portmap(andmountd, I guess) running? Or can I just write my damn NFS server, and tell Finder to mount it, with the port number I’m listening on? - Has anyone else ever successfully written a user-space NFS server to implement a file system like this? Is your code available?
- More generally, is there a toolkit that lets you more easily write NFS based file systems?
- Apple says that
launchdautomatically startsportmapwhen it is needed, which is full of lies. How can I really make it launchportmap?
Edit: why are all NFS-related packages dead on the Internet? Neither the “Universal” NFS server (a user-space NFS server), nor portmap seem to exist anywhere on the Internet. I can get the source for these from Debian, and through Apple’s open source page, but are these packages otherwise dead?

Loading...
David Lichteblau | 27-Oct-06 at 1:08 am | Permalink
If you read Lisp, you might want to look at the Franz NFS server code.
(LGPL Lisp-Preamble):
http://opensource.franz.com/nfs/
http://opensource.franz.com/nfs/nfs-dist/nfs-1.1.4-src.zip
csm | 27-Oct-06 at 1:06 pm | Permalink
The project is Objective-C, so I don’t know how much help a Lisp implementation would be.
FYI, starting portmapper on OS X means just doing:
In my code, I’m able to start up both a mount service and an NFS service now, so (in theory) all I have to do is fill in the server stubs for the protocol. Using
rpcgenon the mountd and nfs XDR specs *does* produce usable C code, which happily enough also happens to be valid Objective-C.Jimmy Johnson | 25-May-07 at 10:13 am | Permalink
I am trying to do the same thing, did you ever get this to work?
csm | 27-May-07 at 1:14 pm | Permalink
Yeah, I did get it (mostly) working. The code I wrote that uses this is here: http://code.google.com/p/birchfs/
This is a pain in the ass to do, though. If you can, you may want to consider using FUSE on Linux, or MacFUSE on OS X.