acl.c (03ab8e6297acd1bc0eedaa050e2a1635c576fd11) | acl.c (6cd4d4e8b6e1495eb0cafa3a59d1fde137a98d22) |
---|---|
1// SPDX-License-Identifier: LGPL-2.1 2/* 3 * Copyright IBM Corporation, 2010 4 * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> 5 */ 6 7#include <linux/module.h> 8#include <linux/fs.h> 9#include <net/9p/9p.h> 10#include <net/9p/client.h> 11#include <linux/slab.h> 12#include <linux/sched.h> 13#include <linux/posix_acl_xattr.h> 14#include "xattr.h" 15#include "acl.h" 16#include "v9fs.h" 17#include "v9fs_vfs.h" 18#include "fid.h" 19 | 1// SPDX-License-Identifier: LGPL-2.1 2/* 3 * Copyright IBM Corporation, 2010 4 * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> 5 */ 6 7#include <linux/module.h> 8#include <linux/fs.h> 9#include <net/9p/9p.h> 10#include <net/9p/client.h> 11#include <linux/slab.h> 12#include <linux/sched.h> 13#include <linux/posix_acl_xattr.h> 14#include "xattr.h" 15#include "acl.h" 16#include "v9fs.h" 17#include "v9fs_vfs.h" 18#include "fid.h" 19 |
20static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name) | 20static struct posix_acl *v9fs_fid_get_acl(struct p9_fid *fid, const char *name) |
21{ 22 ssize_t size; 23 void *value = NULL; 24 struct posix_acl *acl = NULL; 25 26 size = v9fs_fid_xattr_get(fid, name, NULL, 0); | 21{ 22 ssize_t size; 23 void *value = NULL; 24 struct posix_acl *acl = NULL; 25 26 size = v9fs_fid_xattr_get(fid, name, NULL, 0); |
27 if (size > 0) { 28 value = kzalloc(size, GFP_NOFS); 29 if (!value) 30 return ERR_PTR(-ENOMEM); 31 size = v9fs_fid_xattr_get(fid, name, value, size); 32 if (size > 0) { 33 acl = posix_acl_from_xattr(&init_user_ns, value, size); 34 if (IS_ERR(acl)) 35 goto err_out; 36 } 37 } else if (size == -ENODATA || size == 0 || 38 size == -ENOSYS || size == -EOPNOTSUPP) { 39 acl = NULL; 40 } else 41 acl = ERR_PTR(-EIO); | 27 if (size < 0) 28 return ERR_PTR(size); 29 if (size == 0) 30 return ERR_PTR(-ENODATA); |
42 | 31 |
43err_out: | 32 value = kzalloc(size, GFP_NOFS); 33 if (!value) 34 return ERR_PTR(-ENOMEM); 35 36 size = v9fs_fid_xattr_get(fid, name, value, size); 37 if (size < 0) 38 acl = ERR_PTR(size); 39 else if (size == 0) 40 acl = ERR_PTR(-ENODATA); 41 else 42 acl = posix_acl_from_xattr(&init_user_ns, value, size); |
44 kfree(value); 45 return acl; 46} 47 | 43 kfree(value); 44 return acl; 45} 46 |
47static struct posix_acl *v9fs_acl_get(struct dentry *dentry, const char *name) 48{ 49 struct p9_fid *fid; 50 struct posix_acl *acl = NULL; 51 52 fid = v9fs_fid_lookup(dentry); 53 if (IS_ERR(fid)) 54 return ERR_CAST(fid); 55 56 acl = v9fs_fid_get_acl(fid, name); 57 p9_fid_put(fid); 58 return acl; 59} 60 61static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, const char *name) 62{ 63 int retval; 64 struct posix_acl *acl = NULL; 65 66 acl = v9fs_fid_get_acl(fid, name); 67 if (!IS_ERR(acl)) 68 return acl; 69 70 retval = PTR_ERR(acl); 71 if (retval == -ENODATA || retval == -ENOSYS || retval == -EOPNOTSUPP) 72 return NULL; 73 74 /* map everything else to -EIO */ 75 return ERR_PTR(-EIO); 76} 77 |
|
48int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) 49{ 50 int retval = 0; 51 struct posix_acl *pacl, *dacl; 52 struct v9fs_session_info *v9ses; 53 54 v9ses = v9fs_inode2v9ses(inode); 55 if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || --- 28 unchanged lines hidden (view full) --- 84 * 9p Always cache the acl value when 85 * instantiating the inode (v9fs_inode_from_fid) 86 */ 87 acl = get_cached_acl(inode, type); 88 BUG_ON(is_uncached_acl(acl)); 89 return acl; 90} 91 | 78int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) 79{ 80 int retval = 0; 81 struct posix_acl *pacl, *dacl; 82 struct v9fs_session_info *v9ses; 83 84 v9ses = v9fs_inode2v9ses(inode); 85 if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || --- 28 unchanged lines hidden (view full) --- 114 * 9p Always cache the acl value when 115 * instantiating the inode (v9fs_inode_from_fid) 116 */ 117 acl = get_cached_acl(inode, type); 118 BUG_ON(is_uncached_acl(acl)); 119 return acl; 120} 121 |
92struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type, bool rcu) | 122struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type, bool rcu) |
93{ 94 struct v9fs_session_info *v9ses; 95 96 if (rcu) 97 return ERR_PTR(-ECHILD); 98 99 v9ses = v9fs_inode2v9ses(inode); 100 if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || 101 ((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) { 102 /* 103 * On access = client and acl = on mode get the acl 104 * values from the server 105 */ 106 return NULL; 107 } 108 return v9fs_get_cached_acl(inode, type); 109 110} 111 | 123{ 124 struct v9fs_session_info *v9ses; 125 126 if (rcu) 127 return ERR_PTR(-ECHILD); 128 129 v9ses = v9fs_inode2v9ses(inode); 130 if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || 131 ((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) { 132 /* 133 * On access = client and acl = on mode get the acl 134 * values from the server 135 */ 136 return NULL; 137 } 138 return v9fs_get_cached_acl(inode, type); 139 140} 141 |
142struct posix_acl *v9fs_iop_get_acl(struct user_namespace *mnt_userns, 143 struct dentry *dentry, int type) 144{ 145 struct v9fs_session_info *v9ses; 146 147 v9ses = v9fs_dentry2v9ses(dentry); 148 /* We allow set/get/list of acl when access=client is not specified. */ 149 if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) 150 return v9fs_acl_get(dentry, posix_acl_xattr_name(type)); 151 return v9fs_get_cached_acl(d_inode(dentry), type); 152} 153 |
|
112static int v9fs_set_acl(struct p9_fid *fid, int type, struct posix_acl *acl) 113{ 114 int retval; 115 char *name; 116 size_t size; 117 void *buffer; 118 119 if (!acl) --- 211 unchanged lines hidden --- | 154static int v9fs_set_acl(struct p9_fid *fid, int type, struct posix_acl *acl) 155{ 156 int retval; 157 char *name; 158 size_t size; 159 void *buffer; 160 161 if (!acl) --- 211 unchanged lines hidden --- |