nfs2acl.c (bf61c8840efe60fd8f91446860b63338fb424158) | nfs2acl.c (4ac7249ea5a0ceef9f8269f63f33cc873c3fac61) |
---|---|
1/* 2 * Process version 2 NFSACL requests. 3 * 4 * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de> 5 */ 6 7#include "nfsd.h" 8/* FIXME: nfsacl.h is a broken header */ --- 16 unchanged lines hidden (view full) --- 25} 26 27/* 28 * Get the Access and/or Default ACL of a file. 29 */ 30static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp, 31 struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp) 32{ | 1/* 2 * Process version 2 NFSACL requests. 3 * 4 * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de> 5 */ 6 7#include "nfsd.h" 8/* FIXME: nfsacl.h is a broken header */ --- 16 unchanged lines hidden (view full) --- 25} 26 27/* 28 * Get the Access and/or Default ACL of a file. 29 */ 30static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp, 31 struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp) 32{ |
33 svc_fh *fh; | |
34 struct posix_acl *acl; | 33 struct posix_acl *acl; |
34 struct inode *inode; 35 svc_fh *fh; |
|
35 __be32 nfserr = 0; 36 37 dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 38 39 fh = fh_copy(&resp->fh, &argp->fh); 40 nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 41 if (nfserr) 42 RETURN_STATUS(nfserr); 43 | 36 __be32 nfserr = 0; 37 38 dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 39 40 fh = fh_copy(&resp->fh, &argp->fh); 41 nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 42 if (nfserr) 43 RETURN_STATUS(nfserr); 44 |
45 inode = fh->fh_dentry->d_inode; 46 |
|
44 if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) 45 RETURN_STATUS(nfserr_inval); 46 resp->mask = argp->mask; 47 48 nfserr = fh_getattr(fh, &resp->stat); 49 if (nfserr) 50 goto fail; 51 52 if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { | 47 if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) 48 RETURN_STATUS(nfserr_inval); 49 resp->mask = argp->mask; 50 51 nfserr = fh_getattr(fh, &resp->stat); 52 if (nfserr) 53 goto fail; 54 55 if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { |
53 acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS); | 56 acl = get_acl(inode, ACL_TYPE_ACCESS); |
54 if (IS_ERR(acl)) { | 57 if (IS_ERR(acl)) { |
55 int err = PTR_ERR(acl); 56 57 if (err == -ENODATA || err == -EOPNOTSUPP) 58 acl = NULL; 59 else { 60 nfserr = nfserrno(err); 61 goto fail; 62 } | 58 nfserr = nfserrno(PTR_ERR(acl)); 59 goto fail; |
63 } 64 if (acl == NULL) { 65 /* Solaris returns the inode's minimum ACL. */ | 60 } 61 if (acl == NULL) { 62 /* Solaris returns the inode's minimum ACL. */ |
66 67 struct inode *inode = fh->fh_dentry->d_inode; | |
68 acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); 69 } 70 resp->acl_access = acl; 71 } 72 if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) { 73 /* Check how Solaris handles requests for the Default ACL 74 of a non-directory! */ | 63 acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); 64 } 65 resp->acl_access = acl; 66 } 67 if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) { 68 /* Check how Solaris handles requests for the Default ACL 69 of a non-directory! */ |
75 76 acl = nfsd_get_posix_acl(fh, ACL_TYPE_DEFAULT); | 70 acl = get_acl(inode, ACL_TYPE_DEFAULT); |
77 if (IS_ERR(acl)) { | 71 if (IS_ERR(acl)) { |
78 int err = PTR_ERR(acl); 79 80 if (err == -ENODATA || err == -EOPNOTSUPP) 81 acl = NULL; 82 else { 83 nfserr = nfserrno(err); 84 goto fail; 85 } | 72 nfserr = nfserrno(PTR_ERR(acl)); 73 goto fail; |
86 } 87 resp->acl_default = acl; 88 } 89 90 /* resp->acl_{access,default} are released in nfssvc_release_getacl. */ 91 RETURN_STATUS(0); 92 93fail: --- 4 unchanged lines hidden (view full) --- 98 99/* 100 * Set the Access and/or Default ACL of a file. 101 */ 102static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp, 103 struct nfsd3_setaclargs *argp, 104 struct nfsd_attrstat *resp) 105{ | 74 } 75 resp->acl_default = acl; 76 } 77 78 /* resp->acl_{access,default} are released in nfssvc_release_getacl. */ 79 RETURN_STATUS(0); 80 81fail: --- 4 unchanged lines hidden (view full) --- 86 87/* 88 * Set the Access and/or Default ACL of a file. 89 */ 90static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp, 91 struct nfsd3_setaclargs *argp, 92 struct nfsd_attrstat *resp) 93{ |
94 struct inode *inode; |
|
106 svc_fh *fh; 107 __be32 nfserr = 0; | 95 svc_fh *fh; 96 __be32 nfserr = 0; |
97 int error; |
|
108 109 dprintk("nfsd: SETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 110 111 fh = fh_copy(&resp->fh, &argp->fh); 112 nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); | 98 99 dprintk("nfsd: SETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 100 101 fh = fh_copy(&resp->fh, &argp->fh); 102 nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); |
103 if (nfserr) 104 goto out; |
|
113 | 105 |
114 if (!nfserr) { 115 nfserr = nfserrno( nfsd_set_posix_acl( 116 fh, ACL_TYPE_ACCESS, argp->acl_access) ); | 106 inode = fh->fh_dentry->d_inode; 107 if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) { 108 error = -EOPNOTSUPP; 109 goto out_errno; |
117 } | 110 } |
118 if (!nfserr) { 119 nfserr = nfserrno( nfsd_set_posix_acl( 120 fh, ACL_TYPE_DEFAULT, argp->acl_default) ); 121 } 122 if (!nfserr) { 123 nfserr = fh_getattr(fh, &resp->stat); 124 } | |
125 | 111 |
112 error = fh_want_write(fh); 113 if (error) 114 goto out_errno; 115 116 error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS); 117 if (error) 118 goto out_drop_write; 119 error = inode->i_op->set_acl(inode, argp->acl_default, 120 ACL_TYPE_DEFAULT); 121 if (error) 122 goto out_drop_write; 123 124 fh_drop_write(fh); 125 126 nfserr = fh_getattr(fh, &resp->stat); 127 128out: |
|
126 /* argp->acl_{access,default} may have been allocated in 127 nfssvc_decode_setaclargs. */ 128 posix_acl_release(argp->acl_access); 129 posix_acl_release(argp->acl_default); 130 return nfserr; | 129 /* argp->acl_{access,default} may have been allocated in 130 nfssvc_decode_setaclargs. */ 131 posix_acl_release(argp->acl_access); 132 posix_acl_release(argp->acl_default); 133 return nfserr; |
134out_drop_write: 135 fh_drop_write(fh); 136out_errno: 137 nfserr = nfserrno(error); 138 goto out; |
|
131} 132 133/* 134 * Check file attributes 135 */ 136static __be32 nfsacld_proc_getattr(struct svc_rqst * rqstp, 137 struct nfsd_fhandle *argp, struct nfsd_attrstat *resp) 138{ --- 232 unchanged lines hidden --- | 139} 140 141/* 142 * Check file attributes 143 */ 144static __be32 nfsacld_proc_getattr(struct svc_rqst * rqstp, 145 struct nfsd_fhandle *argp, struct nfsd_attrstat *resp) 146{ --- 232 unchanged lines hidden --- |