4 #include <linux/nfs3.h>
5 #include <linux/nfs_fs.h>
7 #include <linux/nfsacl.h>
11 #define NFSDBG_FACILITY NFSDBG_PROC
19 # define output(s) do { \
20 if (pos + sizeof(s) <= size) { \
21 memcpy(buffer + pos, s, sizeof(s)); \
31 output(
"system.posix_acl_access");
32 posix_acl_release(acl);
40 output(
"system.posix_acl_default");
41 posix_acl_release(acl);
47 if (!buffer ||
len <= size)
74 posix_acl_release(acl);
99 posix_acl_release(acl);
119 static void __nfs3_forget_cached_acls(
struct nfs_inode *nfsi)
121 if (!IS_ERR(nfsi->acl_access)) {
122 posix_acl_release(nfsi->acl_access);
123 nfsi->acl_access = ERR_PTR(-
EAGAIN);
125 if (!IS_ERR(nfsi->acl_default)) {
126 posix_acl_release(nfsi->acl_default);
127 nfsi->acl_default = ERR_PTR(-
EAGAIN);
133 dprintk(
"NFS: nfs3_forget_cached_acls(%s/%ld)\n", inode->
i_sb->s_id,
135 spin_lock(&inode->
i_lock);
136 __nfs3_forget_cached_acls(NFS_I(inode));
137 spin_unlock(&inode->
i_lock);
145 spin_lock(&inode->
i_lock);
148 acl = nfsi->acl_access;
152 acl = nfsi->acl_default;
161 acl = posix_acl_dup(acl);
163 spin_unlock(&inode->
i_lock);
164 dprintk(
"NFS: nfs3_get_cached_acl(%s/%ld, %d) = %p\n", inode->
i_sb->s_id,
165 inode->
i_ino, type, acl);
169 static void nfs3_cache_acls(
struct inode *inode,
struct posix_acl *acl,
174 dprintk(
"nfs3_cache_acls(%s/%ld, %p, %p)\n", inode->
i_sb->s_id,
175 inode->
i_ino, acl, dfacl);
176 spin_lock(&inode->
i_lock);
177 __nfs3_forget_cached_acls(NFS_I(inode));
179 nfsi->acl_access = posix_acl_dup(acl);
181 nfsi->acl_default = posix_acl_dup(dfacl);
182 spin_unlock(&inode->
i_lock);
187 struct nfs_server *server = NFS_SERVER(inode);
209 return ERR_PTR(status);
210 acl = nfs3_get_cached_acl(inode, type);
211 if (acl != ERR_PTR(-
EAGAIN))
235 dprintk(
"NFS reply getacl: %d\n", status);
247 dprintk(
"NFS_V3_ACL extension not supported; disabling\n");
265 nfs3_cache_acls(inode,
283 nfs_free_fattr(res.
fattr);
286 posix_acl_release(acl);
287 acl = ERR_PTR(status);
292 static int nfs3_proc_setacls(
struct inode *inode,
struct posix_acl *acl,
295 struct nfs_server *server = NFS_SERVER(inode);
324 args.
len = nfsacl_size(acl, dfacl);
326 args.
len = nfsacl_size(acl,
NULL);
337 }
while (args.
npages < npages);
351 dprintk(
"NFS reply setacl: %d\n", status);
356 nfs3_cache_acls(inode, acl, dfacl);
360 dprintk(
"NFS_V3_ACL SETACL RPC not supported"
361 "(will not retry)\n");
366 nfs_free_fattr(fattr);
368 while (args.
npages != 0) {
409 status = nfs3_proc_setacls(inode, acl, dfacl);
410 posix_acl_release(alloc);
414 return PTR_ERR(alloc);
425 error = PTR_ERR(dfacl);
430 acl = posix_acl_dup(dfacl);
433 goto out_release_dfacl;
434 error = nfs3_proc_setacls(inode, acl,
S_ISDIR(inode->
i_mode) ?
436 posix_acl_release(acl);
438 posix_acl_release(dfacl);