
From: NeilBrown <neilb@cse.unsw.edu.au>

The nfs4 attributes supported_attrs and aclsupport should not be static; they
need to depend on the exported filesystem's acl support.  Test the latter by
attempting to get an acl, and adjust the returned attributes apropriately.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/nfsd/nfs4xdr.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff -puN fs/nfsd/nfs4xdr.c~nfsd4-support-acl_support-attribute fs/nfsd/nfs4xdr.c
--- 25/fs/nfsd/nfs4xdr.c~nfsd4-support-acl_support-attribute	2004-09-02 20:28:50.890955616 -0700
+++ 25-akpm/fs/nfsd/nfs4xdr.c	2004-09-02 20:28:50.896954704 -0700
@@ -1414,6 +1414,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, s
 	u64 dummy64;
 	u32 *p = buffer;
 	int status;
+	int aclsupport = 0;
 	struct nfs4_acl *acl = NULL;
 
 	BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1);
@@ -1437,12 +1438,16 @@ nfsd4_encode_fattr(struct svc_fh *fhp, s
 			goto out;
 		fhp = &tempfh;
 	}
-	if (bmval0 & FATTR4_WORD0_ACL) {
+	if (bmval0 & (FATTR4_WORD0_ACL | FATTR4_WORD0_ACLSUPPORT
+			| FATTR4_WORD0_SUPPORTED_ATTRS)) {
 		status = nfsd4_get_nfs4_acl(rqstp, dentry, &acl);
-		if (status == -EOPNOTSUPP)
-			bmval0 &= ~FATTR4_WORD0_ACL;
-		else if (status < 0)
-			goto out_nfserr;
+		aclsupport = (status == 0);
+		if (bmval0 & FATTR4_WORD0_ACL) {
+			if (status == -EOPNOTSUPP)
+				bmval0 &= ~FATTR4_WORD0_ACL;
+			else if (status != 0)
+				goto out_nfserr;
+		}
 	}
 	if ((buflen -= 16) < 0)
 		goto out_resource;
@@ -1456,9 +1461,9 @@ nfsd4_encode_fattr(struct svc_fh *fhp, s
 		if ((buflen -= 12) < 0)
 			goto out_resource;
 		WRITE32(2);
-		/* XXX Should depend on exported filesystem (e.g.
-		 * for acl support) */
-		WRITE32(NFSD_SUPPORTED_ATTRS_WORD0);
+		WRITE32(aclsupport ?
+			NFSD_SUPPORTED_ATTRS_WORD0 :
+			NFSD_SUPPORTED_ATTRS_WORD0 & ~FATTR4_WORD0_ACL);
 		WRITE32(NFSD_SUPPORTED_ATTRS_WORD1);
 	}
 	if (bmval0 & FATTR4_WORD0_TYPE) {
@@ -1565,8 +1570,8 @@ out_acl:
 	if (bmval0 & FATTR4_WORD0_ACLSUPPORT) {
 		if ((buflen -= 4) < 0)
 			goto out_resource;
-		/* XXX: should depend on exported filesystem: */
-		WRITE32(ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL);
+		WRITE32(aclsupport ?
+			ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL : 0);
 	}
 	if (bmval0 & FATTR4_WORD0_CANSETTIME) {
 		if ((buflen -= 4) < 0)
_
