January 21st, 2011

I hate NFS.

I've been reading the NFS RFC documents written by Sun, a company that apparently could not express itself clearly, or proofread its work.

Let's summarize RFC 1014:

Data is sent in multiples of 4 bytes, everything big endian. Ints are 4 bytes, longs are 8 bytes ala the LP64 standard. Enums are signed integers. Boolean type is an integer with 0 for false and 1 for true.

There are IEEE 754 floating points (single precision is 1 sign bit, 8 exponent bits, 23 data bits. Double is 1 sign bit, 11 exponent bits, 52 data bits). And if NFS ever sends them for anything Sun was even more screwed up than I thought, but if they do there's an existing standard for them.

Fixed length opaque data blobs get zero padded at the end to multiples of 4 bytes. Variable length opaque data blobs start with an unsigned int length, followed by the data (again zero padded to a multiple of 4 bytes). Strings are sent as variable length opaque data blobs.

They have a definition of arrays in here that, as far as I can tell, contains no actual information. Variable length arrays are just like opaque data blobs except the size of each element isn't in bytes. (What is it? Magical a-priori knowledge on the part of whoever is sending the data. Rounded up to the nearest four bytes, of course.) A structure is indistinguishable from sending the structure's components in order.

They have something called a "discriminant union" which is an int followed by a structure, the int specifying which structure. Of course the structures don't have to be the same size. Oh, and this can have a default value in case the int has a crazy value in it, but it isn't required to.

They define a void type, which is zero bytes long. (Yes really. Section 3.15.) They follow it with declaring constants and typedefs that don't go across the wire either, despite the title of the RFC being about a wire protocol.

All of this takes them many, many pages to say. Just getting through "Big endian, 4 byte alignment, LP64, with IEEE 754 floats." takes well over a dozen pages.

It's been like this all week...