Introduction

Pinefs is a user-space NFS server, written entirely in Python. It provides three sample filesystems: pyfs, which provides a view of the entire Python namespace as a file system, allowing you to change variables in a running Python program by writing to the corresponding file, or to use Unix tools like find; memfs, a fairly trivial in-memory filesystem; and tarfs, which populates memfs from a tar file specified by the mount command (requires tarfile, included in Python 2.3, or available separately). The package also includes rpcgen.py, a Python compiler from ONC RPC IDL to Python source. Pinefs requires Python 2.2 or later, and has been developed on Linux and lightly tested on Win 98. You can download it here.

Running the Pinefs pyfs Server

srv.py takes a single option, '-f', which defaults to 'py' for the Python filesystem, but can be 'mem' for the memory filesystem or 'tar' for the tar filesystem. When the Python filesystem is specified, the server runs a Python interactive loop.

The mount server runs on port 5555, and the NFS server on 2049. (Both register with the portmapper.) On my Linux box, I use the following command to mount the server for pyfs:

mount -t nfs -o noac 127.0.0.1:/ /mnt/nfs

Once the Python filesystem is mounted, you can try:

echo 1 > <mount point>/rpchelp/trace_rpc

to set the global trace_rpc in module rpchelp to 1, which causes information about rpc calls to be printed. You should see trace information for the NFSPROC_WRITE call. After you've looked around the filesystem for a bit, you can turn off tracing by either:

echo 0 > <mount point>/rpchelp/trace_rpc

or typing into the Python interaction loop:

import rpchelp
rpchelp.trace_rpc = 0

See here for more information on the mapping implemented by pyfs. The mapping isn't perfect, but works well enough to use emacs, or to untar, configure, and compile, e.g., my Dissociated Studio package. (Note: if you want a production-quality monitoring/debugging system, you should probably use something built for that purpose (like manhole from Twisted), since you could get more functionality, Pinefs doesn't address synchronization issues, and pyfs filehandles aren't persistent across restarts).)

Running the Pinefs tarfs Server

This works much as above, except that instead of 127.0.0.1:/, substitute for / the pathname to a tar file. Now you can, change directory to the mount point and browse, or, if it's a software package, e.g., ./configure; make.

Running rpcgen.py

rpcgen.py takes an IDL filename as a parameter, and writes Python code implementing that IDL on stdout. The generated code imports rpchelp and rpc from the Pinefs distribution, which thus must be present at runtime. rpcgen.py requires Dave Beazley's PLY package, licensed under the LGPL. Pinefs includes a precompiled rfc1094.py (generated from rfc1094.idl), so you don't need PLY in order to run Pinefs. See here for more information on rpcgen.

Talks

Slides for my PyCon 2005 Lightning talk

Notes

There are several other related progr