Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Process version 3 NFSACL requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "nfsd.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) /* FIXME: nfsacl.h is a broken header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/nfsacl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "cache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "xdr3.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "vfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * NULL call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static __be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) nfsd3_proc_null(struct svc_rqst *rqstp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	return rpc_success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * Get the Access and/or Default ACL of a file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static __be32 nfsd3_proc_getacl(struct svc_rqst *rqstp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct nfsd3_getaclargs *argp = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct nfsd3_getaclres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct posix_acl *acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	svc_fh *fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	fh = fh_copy(&resp->fh, &argp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (resp->status != nfs_ok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	inode = d_inode(fh->fh_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	if (argp->mask & ~NFS_ACL_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		resp->status = nfserr_inval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	resp->mask = argp->mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		acl = get_acl(inode, ACL_TYPE_ACCESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		if (acl == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 			/* Solaris returns the inode's minimum ACL. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		if (IS_ERR(acl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 			resp->status = nfserrno(PTR_ERR(acl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		resp->acl_access = acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		/* Check how Solaris handles requests for the Default ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		   of a non-directory! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		acl = get_acl(inode, ACL_TYPE_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		if (IS_ERR(acl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			resp->status = nfserrno(PTR_ERR(acl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		resp->acl_default = acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	/* resp->acl_{access,default} are released in nfs3svc_release_getacl. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	return rpc_success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	posix_acl_release(resp->acl_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	posix_acl_release(resp->acl_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * Set the Access and/or Default ACL of a file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static __be32 nfsd3_proc_setacl(struct svc_rqst *rqstp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct nfsd3_setaclargs *argp = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	struct nfsd3_attrstat *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	svc_fh *fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	fh = fh_copy(&resp->fh, &argp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	if (resp->status != nfs_ok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	inode = d_inode(fh->fh_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	error = fh_want_write(fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		goto out_errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	fh_lock(fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	error = set_posix_acl(inode, ACL_TYPE_ACCESS, argp->acl_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		goto out_drop_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	error = set_posix_acl(inode, ACL_TYPE_DEFAULT, argp->acl_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) out_drop_lock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	fh_unlock(fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	fh_drop_write(fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) out_errno:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	resp->status = nfserrno(error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	/* argp->acl_{access,default} may have been allocated in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	   nfs3svc_decode_setaclargs. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	posix_acl_release(argp->acl_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	posix_acl_release(argp->acl_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return rpc_success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * XDR decode functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct nfsd3_getaclargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	p = nfs3svc_decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	args->mask = ntohl(*p); p++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	struct nfsd3_setaclargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	struct kvec *head = rqstp->rq_arg.head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	unsigned int base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	int n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	p = nfs3svc_decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	args->mask = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (args->mask & ~NFS_ACL_MASK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	    !xdr_argsize_check(rqstp, p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	base = (char *)p - (char *)head->iov_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	n = nfsacl_decode(&rqstp->rq_arg, base, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			  (args->mask & NFS_ACL) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			  &args->acl_access : NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	if (n > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		n = nfsacl_decode(&rqstp->rq_arg, base + n, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 				  (args->mask & NFS_DFACL) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				  &args->acl_default : NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	return (n > 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * XDR encode functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /* GETACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct nfsd3_getaclres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct dentry *dentry = resp->fh.fh_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	*p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (resp->status == 0 && dentry && d_really_is_positive(dentry)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		struct inode *inode = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		struct kvec *head = rqstp->rq_res.head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		unsigned int base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		int n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		int w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		*p++ = htonl(resp->mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		if (!xdr_ressize_check(rqstp, p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		base = (char *)p - (char *)head->iov_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		rqstp->rq_res.page_len = w = nfsacl_size(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			(resp->mask & NFS_ACL)   ? resp->acl_access  : NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			(resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		while (w > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			if (!*(rqstp->rq_next_page++))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			w -= PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		n = nfsacl_encode(&rqstp->rq_res, base, inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 				  resp->acl_access,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 				  resp->mask & NFS_ACL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (n > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			n = nfsacl_encode(&rqstp->rq_res, base + n, inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 					  resp->acl_default,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 					  resp->mask & NFS_DFACL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 					  NFS_ACL_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		if (n <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		if (!xdr_ressize_check(rqstp, p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) /* SETACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	struct nfsd3_attrstat *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	*p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  * XDR release functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static void nfs3svc_release_getacl(struct svc_rqst *rqstp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct nfsd3_getaclres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	fh_put(&resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	posix_acl_release(resp->acl_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	posix_acl_release(resp->acl_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) struct nfsd3_voidargs { int dummy; };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #define ST 1		/* status*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #define AT 21		/* attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define pAT (1+AT)	/* post attributes - conditional */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #define ACL (1+NFS_ACL_MAX_ENTRIES*3)  /* Access Control List */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static const struct svc_procedure nfsd_acl_procedures3[3] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	[ACLPROC3_NULL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		.pc_func = nfsd3_proc_null,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		.pc_decode = nfs3svc_decode_voidarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		.pc_encode = nfs3svc_encode_voidres,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		.pc_argsize = sizeof(struct nfsd3_voidargs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		.pc_ressize = sizeof(struct nfsd3_voidargs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		.pc_cachetype = RC_NOCACHE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		.pc_xdrressize = ST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	[ACLPROC3_GETACL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		.pc_func = nfsd3_proc_getacl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		.pc_decode = nfs3svc_decode_getaclargs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		.pc_encode = nfs3svc_encode_getaclres,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		.pc_release = nfs3svc_release_getacl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		.pc_argsize = sizeof(struct nfsd3_getaclargs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		.pc_ressize = sizeof(struct nfsd3_getaclres),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		.pc_cachetype = RC_NOCACHE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		.pc_xdrressize = ST+1+2*(1+ACL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	[ACLPROC3_SETACL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		.pc_func = nfsd3_proc_setacl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		.pc_decode = nfs3svc_decode_setaclargs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		.pc_encode = nfs3svc_encode_setaclres,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		.pc_release = nfs3svc_release_fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		.pc_argsize = sizeof(struct nfsd3_setaclargs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		.pc_ressize = sizeof(struct nfsd3_attrstat),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		.pc_cachetype = RC_NOCACHE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		.pc_xdrressize = ST+pAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static unsigned int nfsd_acl_count3[ARRAY_SIZE(nfsd_acl_procedures3)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) const struct svc_version nfsd_acl_version3 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	.vs_vers	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	.vs_nproc	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	.vs_proc	= nfsd_acl_procedures3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	.vs_count	= nfsd_acl_count3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	.vs_dispatch	= nfsd_dispatch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	.vs_xdrsize	= NFS3_SVC_XDRSIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)