Previous: Invoking grpc-rpcinfo, Up: Stand-Alone Tools


5.3 Invoking grpc-nfs-export

Guile-RPC comes with an example NFS (Network File System) server, provided by the grpc-nfs-export command. More precisely, it implements NFS version 2, i.e., the NFS_PROGRAM RPC program version 2 along with the MOUNTPROG program version 1, which are closely related (see RFC 1094). It is a TCP server.

Enough technical details. The important thing about grpc-nfs-export is this: although it's of little use in one's everyday life, this NFS server is nothing less than life-changing. It's different from any file system you've seen before. It's the ultimate debugging aid for any good Guile hacker.

The “file hierarchy” served by grpc-nfs-export is—guess what?—Guile's module hierarchy! In other words, when mounting the file system exported by grpc-nfs-export, the available files are bindings, while directories represent modules (see The Guile module system). The module hierarchy can also be browsed from the REPL using Guile's nested-ref procedure. Here's a sample session:

     $ ./grpc-nfs-export &
     
     $ sudo mount -t nfs -o nfsvers=2,tcp,port=2049 localhost: /nfs/
     
     $ ls /nfs/%app/modules/
     guile/  guile-rpc/  guile-user/  ice-9/  r6rs/  rpc/  srfi/
     
     $ ls /nfs/%app/modules/rpc/rpc/portmap/%module-public-interface/
     lookup-rpc-service-name    %portmapper-port
     lookup-rpc-service-number  %portmapper-program-number
     portmapper-call-it         portmapper-set
     portmapper-dump            portmapper-unset
     portmapper-get-port        %portmapper-version-number
     portmapper-null            read-rpc-service-list
     
     $ cat /nfs/%app/modules/rpc/xdr/xdr-decode
     #<procedure xdr-decode (type port)>
     
     $ cat /nfs/%app/modules/rpc/xdr/%xdr-endianness
     big

Here is the option reference:

--help
Print a summary of the command-line options and exit.
--version
Print the version number of GNU Guile-RPC and exit.
--nfs-port=port
-p port
Listen for NFS connections on port (default: 2049).
--mount-port=mount-port
-P mount-port
Listen for mount connections on mount-port (default: 6666).
--debug
Produce debugging messages.

In addition, grpc-nfs-export can be passed the name of a Scheme source file, in which case it will load that file in a separate thread while still serving NFS and mount requests. This allows the program's global variables to be monitored via the NFS mount.

As of version 0.3, this toy server exhibits poor performance, notably when running ls (which translates into a few readdir and many lookup RPCs, the latter being costly) in directories containing a lot of files. This is probably partly due to the use of TCP, and partly due to other inefficiencies that we hope to fix soon.