A hackish NFS2 server

Because I wanted to have some fun.

Download

nfs2-0.1.tar.gz (2014-10-08).

Documentation

This is a big hack.

Ah, in the README below I forgot to mention that the readdir function might be buggy. I don't know if I compute the size correctly. I only calculate the size of the XDR structure I return. Maybe I should take into account other bytes? Anyway, so be it.

You can dig for "nfs-server-2.0.tar.gz" on the internet for an old nfs2 implementation. I doubt it will work though. (My computer is a 64 bits machine and nfs-server-2.0 does not seem to work with such machines.) (Digging for "nfs-server-2.0.tar.gz tsx-11" is better.) There is also the linux kernel code to look at for some documentation/implementation.

Here is the README file included:

This is a hackish nfs2 userland server.
Might work with an ext2/3/4 filesystem.
You must run:
  mount/mount_server localhost /tmp/debian.stable
and as root:
  nfs/nfs_server /tmp/debian.stable
to serve /tmp/debian.stable to some host.

I could make only one program by mixing those two I guess...

There are surely bugs in there.

Each lookup/create/mkdir calls new_file, which smokes a bit
of memory. If the client lookups the same name several times,
each time some memory is wasted. On the other hand, retrieving
the filename from a "fhandle" is O(1).

Ah yes, the code is non-portable, full of stuff like
"*(unsigned long *)fhandle = ul".

There is also a "cookie cache" to store 64 bits cookies
returned by telldir. NFS2 deals with cookies of 32 bits,
so a translation is required. Veeeeeery hackish once
again, eats lots of memory. But, THIS IS A HACK!

THERE IS NO SECURITY AT ALL, DON'T USE IN PRODUCTION!

http://sed.free.fr/debian486/nfs2.html
public domain stuff

to generate code from .x files:
rpcgen -a -C <file>.x

Contact: sed@free.fr

Created: Wed, 08 Oct 2014 12:05:08 +0200
Last update: Wed, 08 Oct 2014 12:05:08 +0200