Find anything useful on this site? Then drop me an email and let me know.

JNFSD

Download by clicking here. Contribution section is here.

A completely free, working NFS V2 server. If you use this, send me a quick email!

"WHAT THE HECK IS NFS?". If this is what you're thinking, the chances are you don't actually need an nfs service, but here's a quick description anyway. If you have 2 windows "boxes" (call them 'Fred' and 'Ginger') on a network and you want to e.g. access the C drive from Fred on Ginger, you can type "net use \\Fred\C$ H:" on Ginger. Now if you click on the H drive on Ginger, you get the contents of the C drive of Fred. If you do this you're using a network file service called SMB. If you're on a unix box, and want to access a directory on another unix box you can do the same using "sharefs / share / exportfs" and "mount". This is using NFS. What if you want to share between Windows and Unix? Most people use a free package called Samba - this is SMB for unix. Suppose (for whatever reason) you didn't want your unix box to talk SMB, you want your windows box to talk NFS? Windows doesn't come with an NFS server (unless you've got NT 4 and the unix utils pack), so you have to use someone else's product. I'm a someone else, and Jnfsd is my product. As java is cross platform you can use it on any OS that runs a full Java runtime environment, not just Windows.

Why did I write jnfsd? I wanted some way adding some storage space to a unix box at home from a Windows 98 box (samba's excellent, but works the other way around). Like most other people would I tried a few search engines for NFS and although I got a lot of hits, all (that I found) were either not free, or didn't actually provide a full read write NFSD. Try searching for yourself and see if you have better luck than I did. Thanks to remotetea it took about 2 days part time to write, then another 2 days trying (and not succeeding) to come up with a better solution for the rename problem. It hasn't been revised to cure any of it's problems or to be tidied up, and I probably won't do any more work on it unless there's a good reason to.

Why am I giving it/the source away? It was simple to write and has a number of issues which means it falls short of any other NFS server I've seen. If you're at all interested in Java, and need something like this then download the source, see how simple it is to write, then write something better.

JNFSD is ENTIRELY thanks to RemoteTea - an ONCRPC implementation for Java. BTW - thanks to remotetea's creator Harald Albrecht for the supportive email!

Licensing

NOTE that nfsserver.jar contains the oncrpc library from remotetea, so if you're worried about licensing, read remote tea's GPL statement.

JNFSD's free! Go nuts with it.

Disclaimer

JNFSD was written for general use at home. If I get any email saying it did anything bad I'll claim that someone else wrote it then ran away. Just see if I don't.

Note - while the word 'mount' is used frequently on this page, the Popeye & Olive joke is not.

Why it's good
Why it's bad
Running JNFSD

Ok, you've downloaded it, you've designated a machine to be the NFS server and you have a machine that can perform NFS mounts. Now what the hell do you do? If you've got the java runtime environment installed, a portmapper running and no existing nfsd/mountd, then just run 'java -jar nfsserver.jar'. Otherwise, here's a checklist:

  1. Download nfsserver.jar and put it somewhere on the server machine.
  2. Download the latest Java runtime environment for free, then install it.
  3. If you haven't got a portmapper installed on the server: get one. For Windows, download one free. Note windows 2000 has its own, portmap.exe is for NT, pm_ascii.exe works for 98. Install and run the portmapper.
  4. If you're running a server that already runs a nfsd and or mountd: disable them. For unix this usually means either disabling whatever starts them up in /etc/rc*.d/*, or by editing /etc/inetd.conf to stop inetd starting them up.
  5. Run 'java -jar nfsserver.jar' on your server.
  6. On the client, check all is well by running 'rpcinfo -p the_nfs_server' (where the_nfs_server is er... the name or IP of nfs server) - you should see a tcp and udp entry both for mountd version1, and nfs version 2.
  7. On the client, do the mount. The export is a single letter which is the same as the single letter of any root filesystem on the server. For example: The C drive of a windows machine could be mounted with 'mount the_nfs_server:C /mntpt', or the root of a Linux machine mounted with 'mount the_nfs_server:/ /mntpt'.
  8. Hammer the server by running something like: 'find /mntpt -type f -exec sum {} \;' to check it works.
  9. Don't forget in windows, a jar is associated with javaw - just double click on your portmapper, double click on nfsserver.jar and you're done.
The source

Want to build the source but don't know how? Here's a checklist:

  1. Download the source, unzip it.
  2. Download the latest Java development environment for free, then install it.
  3. Download the superb remotetea for java.
  4. Run make with either 'Makefile' for unix or 'Makefile.win' for windows. Note Makefile.win doesn't generate the .jar file properly - it's a manifest problem that I haven't looked into. Also, it doesn't correct the port number for nfsd to 2049 (which actually won't matter for most NFS clients as they use the portmapper - read Makefile.win for more information).
  5. If you don't have a make utility: copy oncrpc.jar and jrpcgen.jar from the classes directory of the remotetea installation into the same directory as the unzipped source, then type:

    java -jar jrpcgen.jar -s mount_absserver mount.x

    java -jar jrpcgen.jar -s nfs_absserver nfs_prot.x

    *

    javac -classpath oncrpc.jar;. mainline.java

    java -classpath oncrpc.jar;. mainline

    * - At this point you could hand edit nfs_absserver.java to change the lines:

    FROM:

  6. OncRpcUdpServerTransport(this, 0, nfs_prot.NFS_PROGRAM, 2, 32768), OncRpcTcpServerTransport(this, 0, nfs_prot.NFS_PROGRAM, 2, 32768),

TO:

    OncRpcUdpServerTransport(this, 2049, nfs_prot.NFS_PROGRAM, 2, 32768), OncRpcTcpServerTransport(this, 2049, nfs_prot.NFS_PROGRAM, 2, 32768),

If you don't change the port number to 2049, some nfs clients will not communicate with jnfsd as they don't use the portmapper. Most clients do use the portmapper however, so this won't be necessary. Whatever works for you.

A few comments about the source:

Want to write your own?
  1. Download the latest Java development environment for free, then install it.
  2. Download the superb remotetea for java.
  3. Find a unix box, copy any '.x' file (usually from /usr/include rpcsvc) or write your own.
  4. Run: java -jar jrpcgen.jar <your X file>
  5. If you get errors, try changing a few of the types - e.g. unsigned to u_int.
  6. If all's well you should now have a client and server. Want your client / server to talk to a client / server written in a native language like 'C'? Run your OS's 'rpcgen -a <your X file>' (or download and rpcgen executable if you haven't got one installed), and you'll now have a matching client / server in 'C'. Mix and match e.g. the java client with the 'C' server and away you go - java RPC without RMI, CORBA, etc. Albeit without any 'object orientatedness'. Again, remotetea is very, very cool. I'll write and post a step by step tutorial on writing e.g. a server in C and a client in Java if anyone asks for it.
JNFSD download.

Firstly, read the license and the disclaimer.

jnfsd

jnfsd source

Contributions.

It's great that people are spending time and messing around with this stuff, but I just can't be arsed to try this stuff out right now. I'm a married guy, so my weekends comprise of walking around DIY centres, and looking interested while contemplating driveway paving, I'm too busy for owt else.

However, it'd be a crime (not an exciting crime like stealing from a bank, but a stightly dull crime like putting out a cigar in a short man's hat) to just leave this stuff by the wayside when people have put some effort into it, so I'll just forward any modifications here and leave the original page and source as is. If you email me a mod and don't want part of the email included, let me know.

Bernhard Fastenrath's virtual java desktop project: http://javadesktop.sourceforge.net/

Here's an email from David Budworth:

Hello, My name is David Budworth, and I started playing with JNFSD today.

I just wanted to let you know, that the current version of ONCRPC does not auto start it's services

That may not be the correct terminology, but I found that I had to do: new nfs_server().run(); new mount_server().run(); in order for the NFS server to register itself. This may be because I integrated jportmap and jnfsd into one app.

I'm attaching my revised version of "mainline.java".

Aside from the format change (Sorry, I had a hard time following the code with it's indent style, so I reformatted it all), I added the following:

1) Check for running portmap

2) If portmap isn't running, start remotetea's jportmap server.

3) Added "new xxx_server().run" to the startup threads.

Actually, I nuked your mainline.java thread code, and added back different stuff. Originally, I saw that when you do "new xxx_server()" that those constructors return, so I took out the thread code.

I hadn't realized that they weren't actually starting. So, anywho, Here's my little contribution to the cause.

Thank you, -David

Dave Brand is using JNFSD with his Rio Receiver (how cool is that?). He did find a couple of issues, so here's his description of the source revisions. Note - there are a couple of OS specific lines (e.g. fully qualified pathnames starting with "/"). If there are any more worthwhile mods I may start releasing diff patches instead.

Here you go. There are 2 bug fixes:

1. In nfs_server, we will now return only as many bytes as were requested.

2. In nfs_misc, I fixed the calculation of the number of blocks.

The "enhancements" I added were:

1. It will first look for the directory to mount in the current directory, eg. mounting "/usr" will first look in "usr" in the current directory. It was a quick and simple way to allow names other than drive letters. It really wouldn't be hard to add an alias file (eg. export d:\windows as /windows) but this was good enough for me. The old drive letter stuff will still be used if the current directory doesn't contain the mount.

2. It will treat any files in directories named "dev" as special files. Right now, only block and character special files are supported. I started on symbolic links but stopped when I realized I didn't need them. Feel free to finish it up.