Author: rmacklem
Date: Fri May  6 01:29:14 2011
New Revision: 221517
URL: http://svn.freebsd.org/changeset/base/221517

Log:
  Change the new NFS server so that it returns 0 when the f_bavail
  or f_ffree fields of "struct statfs" are negative, since the
  values that go on the wire are unsigned and will appear to be
  very large positive values otherwise. This makes the handling
  of a negative f_bavail compatible with the old/regular NFS server.
  
  MFC after:    2 weeks

Modified:
  head/sys/fs/nfsserver/nfs_nfsdport.c

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdport.c        Thu May  5 23:09:17 2011        
(r221516)
+++ head/sys/fs/nfsserver/nfs_nfsdport.c        Fri May  6 01:29:14 2011        
(r221517)
@@ -1280,8 +1280,23 @@ nfsvno_fsync(struct vnode *vp, u_int64_t
 int
 nfsvno_statfs(struct vnode *vp, struct statfs *sf)
 {
+       int error;
 
-       return (VFS_STATFS(vp->v_mount, sf));
+       error = VFS_STATFS(vp->v_mount, sf);
+       if (error == 0) {
+               /*
+                * Since NFS handles these values as unsigned on the
+                * wire, there is no way to represent negative values,
+                * so set them to 0. Without this, they will appear
+                * to be very large positive values for clients like
+                * Solaris10.
+                */
+               if (sf->f_bavail < 0)
+                       sf->f_bavail = 0;
+               if (sf->f_ffree < 0)
+                       sf->f_ffree = 0;
+       }
+       return (error);
 }
 
 /*
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to