Skip to content

Linux NFS Stupidity

There’s a story on Mac OS X Hints about people who NFS mount their home directories are having problems in Panther if they use a Linux NFS Server (must… control… stuck… up… snicker… argh… who am I kidding). Anyways there’s a link to the NFS Source code with a patch for fixing this problem in Linux. You can look at that here.
Looking through the patch is rather educational in seeing how things are fixed. But looking at this particular code fragment (the comments in particular) just made me laugh.

 /*
- *	NLM cookies. Technically they can be 1K, Nobody uses over 8 bytes
- *	however.
+ *	NLM cookies. Technically they can be 1K, Few people use over 8 bytes,
+ *	FreeBSD uses 16, Apple Mac OS-X 10.3 uses 20.
  */
  
 struct nlm_cookie
 {
-	unsigned char data[8];
 	unsigned int len;
+#define NLM_MAXCOOKIELEN    	32
+	unsigned char data[NLM_MAXCOOKIELEN];
 };
 



I can understand at one point the person that implemented the NFS Server probably thought no one else used more than 8 bytes for passing these things known as MLN cookies. I bet he never really bothered to look at BSD code until this Panther problem came up rather recently. But it’s nice that they got around to fixing it. The summary of the fix is to fix up the cookie declaration to use up to 32 bytes (and hope that’s large enough for all implementations) as shown above
And also change accesses to a cookie data with a function accessor rather than pulling it directly from the pointer (ick). Here’s a small code snippet to show the differences:

-				*(unsigned int*)(block->b_call.a_args.cookie.data));
+				nlmdbg_cookie2a(&block->b_call.a_args.cookie));



Hopefully the patch will make it upstream to prevent all the other poor Linux server users who use OS X as clients from continuously suffering. However, on reflection as an ordinary user I wouldn’t be flipping through all the NFS code in the Linux kernel JUST to find out compatibility issues like this nor even would I know where to start looking (unless there was a nice document with a comparison chart for all of this) so I’d probably assume things are okay and just go ahead and try it. But when people ask why I use FreeBSD over Linux it’s exactly for stuff like this that I worry about. Insidious evil interaction problems that would be really hard to catch unless you put it through certain circumstances. Or the simpler solution is just run one platform (but that’s boring).

Be Sociable, Share!