return to first page linux journal archive
keywordscontents

NFS Implementor's Primer

Table 2

NFS servers are stupid, NFS clients are smart. Most caching of NFS results happens on the NFS client. NFS requests contain an operation code and arguments. The server processes the request and returns the result. NFS identifies filesystem entries like files and directories in two ways, by ``NFS file handles'' and ``file names''. When an operation wants both a file name and a file handle, the file handle usually points to the directory the file name is in. All NFS operations return a success/failure code. In addition, many NFS operations return data created or modified by the operation.

File handles are 32-byte opaque cookies that have meaning only to the NFS server. Most NFS servers fill cookies with data like hostname, inode number, etc., in a conventional order, but Pgfs doesn't follow this convention.

File names contain only the rightmost path name component. Full path names are not used because a path contains a path name separator, and path name separators vary between operating systems. To make NFS operating system-independent, path separators have been engineered out of the protocol. (Each component of a path name could be a separate RPC data item, but obviously nobody thought of that.)

Some data fields that are normally positive values like userid and mtime may contain -1, which means to use existing values from sensible places. Depending on the NFS operation it could pull defaults from the existing file, the uid/gid associated with the NFS request, or the current time. An NFS server will believe any values you hand it in a packet for userid and groupid, even if you're wearing a black hat. Generating arbitrary NFS packets is most easily done by using a Linux you have root access on and su'ing to the user and group you want your requests to come from.

Symlinks are expanded on the NFS client. On many NFS clients symlink expansions are not put into the client cache, causing them to be re-expanded each time they are referenced. This is the reason symlinks are discouraged in NFS mounting schemes. If you want to use symlinks in your NFS mount scheme, put them on the client's local disk.

Sun Remote Procedure Calls are a library that models communication as a procedure call to a subroutine on another machine. Each argument to the subroutine is declared to the RPC library by data type, such as signed integer. The RPC library translates the arguments from the local binary representation of a signed int to the remote representation of a signed int. Thus, a Pentium can call a routine on an Alpha and the integers come out as the same numerical value in both places.