185ff872dSAneesh Kumar K.V /* 285ff872dSAneesh Kumar K.V * Copyright IBM Corporation, 2010 385ff872dSAneesh Kumar K.V * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> 485ff872dSAneesh Kumar K.V * 585ff872dSAneesh Kumar K.V * This program is free software; you can redistribute it and/or modify it 685ff872dSAneesh Kumar K.V * under the terms of version 2.1 of the GNU Lesser General Public License 785ff872dSAneesh Kumar K.V * as published by the Free Software Foundation. 885ff872dSAneesh Kumar K.V * 985ff872dSAneesh Kumar K.V * This program is distributed in the hope that it would be useful, but 1085ff872dSAneesh Kumar K.V * WITHOUT ANY WARRANTY; without even the implied warranty of 1185ff872dSAneesh Kumar K.V * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1285ff872dSAneesh Kumar K.V * 1385ff872dSAneesh Kumar K.V */ 1485ff872dSAneesh Kumar K.V 1585ff872dSAneesh Kumar K.V #include <linux/module.h> 1685ff872dSAneesh Kumar K.V #include <linux/fs.h> 1785ff872dSAneesh Kumar K.V #include <net/9p/9p.h> 1885ff872dSAneesh Kumar K.V #include <net/9p/client.h> 1985ff872dSAneesh Kumar K.V #include <linux/slab.h> 2022d8dcdfSAneesh Kumar K.V #include <linux/sched.h> 2185ff872dSAneesh Kumar K.V #include <linux/posix_acl_xattr.h> 2285ff872dSAneesh Kumar K.V #include "xattr.h" 2385ff872dSAneesh Kumar K.V #include "acl.h" 2476381a42SAneesh Kumar K.V #include "v9fs.h" 255ffc0cb3SAneesh Kumar K.V #include "v9fs_vfs.h" 2685ff872dSAneesh Kumar K.V 2785ff872dSAneesh Kumar K.V static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name) 2885ff872dSAneesh Kumar K.V { 2985ff872dSAneesh Kumar K.V ssize_t size; 3085ff872dSAneesh Kumar K.V void *value = NULL; 31009ca389SJoe Perches struct posix_acl *acl = NULL; 3285ff872dSAneesh Kumar K.V 3385ff872dSAneesh Kumar K.V size = v9fs_fid_xattr_get(fid, name, NULL, 0); 3485ff872dSAneesh Kumar K.V if (size > 0) { 3585ff872dSAneesh Kumar K.V value = kzalloc(size, GFP_NOFS); 3685ff872dSAneesh Kumar K.V if (!value) 3785ff872dSAneesh Kumar K.V return ERR_PTR(-ENOMEM); 3885ff872dSAneesh Kumar K.V size = v9fs_fid_xattr_get(fid, name, value, size); 3985ff872dSAneesh Kumar K.V if (size > 0) { 4085ff872dSAneesh Kumar K.V acl = posix_acl_from_xattr(value, size); 4185ff872dSAneesh Kumar K.V if (IS_ERR(acl)) 4285ff872dSAneesh Kumar K.V goto err_out; 4385ff872dSAneesh Kumar K.V } 4485ff872dSAneesh Kumar K.V } else if (size == -ENODATA || size == 0 || 4585ff872dSAneesh Kumar K.V size == -ENOSYS || size == -EOPNOTSUPP) { 4685ff872dSAneesh Kumar K.V acl = NULL; 4785ff872dSAneesh Kumar K.V } else 4885ff872dSAneesh Kumar K.V acl = ERR_PTR(-EIO); 4985ff872dSAneesh Kumar K.V 5085ff872dSAneesh Kumar K.V err_out: 5185ff872dSAneesh Kumar K.V kfree(value); 5285ff872dSAneesh Kumar K.V return acl; 5385ff872dSAneesh Kumar K.V } 5485ff872dSAneesh Kumar K.V 5585ff872dSAneesh Kumar K.V int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) 5685ff872dSAneesh Kumar K.V { 5785ff872dSAneesh Kumar K.V int retval = 0; 5885ff872dSAneesh Kumar K.V struct posix_acl *pacl, *dacl; 5976381a42SAneesh Kumar K.V struct v9fs_session_info *v9ses; 6085ff872dSAneesh Kumar K.V 6176381a42SAneesh Kumar K.V v9ses = v9fs_inode2v9ses(inode); 62e782ef71SVenkateswararao Jujjuri (JV) if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || 63e782ef71SVenkateswararao Jujjuri (JV) ((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) { 6476381a42SAneesh Kumar K.V set_cached_acl(inode, ACL_TYPE_DEFAULT, NULL); 6576381a42SAneesh Kumar K.V set_cached_acl(inode, ACL_TYPE_ACCESS, NULL); 6676381a42SAneesh Kumar K.V return 0; 6776381a42SAneesh Kumar K.V } 6885ff872dSAneesh Kumar K.V /* get the default/access acl values and cache them */ 6985ff872dSAneesh Kumar K.V dacl = __v9fs_get_acl(fid, POSIX_ACL_XATTR_DEFAULT); 7085ff872dSAneesh Kumar K.V pacl = __v9fs_get_acl(fid, POSIX_ACL_XATTR_ACCESS); 7185ff872dSAneesh Kumar K.V 7285ff872dSAneesh Kumar K.V if (!IS_ERR(dacl) && !IS_ERR(pacl)) { 7385ff872dSAneesh Kumar K.V set_cached_acl(inode, ACL_TYPE_DEFAULT, dacl); 7485ff872dSAneesh Kumar K.V set_cached_acl(inode, ACL_TYPE_ACCESS, pacl); 7585ff872dSAneesh Kumar K.V } else 7685ff872dSAneesh Kumar K.V retval = -EIO; 7785ff872dSAneesh Kumar K.V 78c61fa0d6SVenkateswararao Jujjuri (JV) if (!IS_ERR(dacl)) 79c61fa0d6SVenkateswararao Jujjuri (JV) posix_acl_release(dacl); 80c61fa0d6SVenkateswararao Jujjuri (JV) 81c61fa0d6SVenkateswararao Jujjuri (JV) if (!IS_ERR(pacl)) 82c61fa0d6SVenkateswararao Jujjuri (JV) posix_acl_release(pacl); 83c61fa0d6SVenkateswararao Jujjuri (JV) 8485ff872dSAneesh Kumar K.V return retval; 8585ff872dSAneesh Kumar K.V } 8685ff872dSAneesh Kumar K.V 8785ff872dSAneesh Kumar K.V static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type) 8885ff872dSAneesh Kumar K.V { 8985ff872dSAneesh Kumar K.V struct posix_acl *acl; 9085ff872dSAneesh Kumar K.V /* 9185ff872dSAneesh Kumar K.V * 9p Always cache the acl value when 9285ff872dSAneesh Kumar K.V * instantiating the inode (v9fs_inode_from_fid) 9385ff872dSAneesh Kumar K.V */ 9485ff872dSAneesh Kumar K.V acl = get_cached_acl(inode, type); 9585ff872dSAneesh Kumar K.V BUG_ON(acl == ACL_NOT_CACHED); 9685ff872dSAneesh Kumar K.V return acl; 9785ff872dSAneesh Kumar K.V } 9885ff872dSAneesh Kumar K.V 994e34e719SChristoph Hellwig struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type) 10085ff872dSAneesh Kumar K.V { 10176381a42SAneesh Kumar K.V struct v9fs_session_info *v9ses; 10276381a42SAneesh Kumar K.V 10376381a42SAneesh Kumar K.V v9ses = v9fs_inode2v9ses(inode); 104e782ef71SVenkateswararao Jujjuri (JV) if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || 105e782ef71SVenkateswararao Jujjuri (JV) ((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) { 10676381a42SAneesh Kumar K.V /* 107e782ef71SVenkateswararao Jujjuri (JV) * On access = client and acl = on mode get the acl 10876381a42SAneesh Kumar K.V * values from the server 10976381a42SAneesh Kumar K.V */ 1104e34e719SChristoph Hellwig return NULL; 11176381a42SAneesh Kumar K.V } 1124e34e719SChristoph Hellwig return v9fs_get_cached_acl(inode, type); 11385ff872dSAneesh Kumar K.V 11485ff872dSAneesh Kumar K.V } 1157a4566b0SAneesh Kumar K.V 1166e8dc555SAneesh Kumar K.V static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl) 1176e8dc555SAneesh Kumar K.V { 1186e8dc555SAneesh Kumar K.V int retval; 1196e8dc555SAneesh Kumar K.V char *name; 1206e8dc555SAneesh Kumar K.V size_t size; 1216e8dc555SAneesh Kumar K.V void *buffer; 1226e8dc555SAneesh Kumar K.V struct inode *inode = dentry->d_inode; 1236e8dc555SAneesh Kumar K.V 1246e8dc555SAneesh Kumar K.V set_cached_acl(inode, type, acl); 125d344b0fbSVenkateswararao Jujjuri (JV) 126d344b0fbSVenkateswararao Jujjuri (JV) if (!acl) 127d344b0fbSVenkateswararao Jujjuri (JV) return 0; 128d344b0fbSVenkateswararao Jujjuri (JV) 1296e8dc555SAneesh Kumar K.V /* Set a setxattr request to server */ 1306e8dc555SAneesh Kumar K.V size = posix_acl_xattr_size(acl->a_count); 1316e8dc555SAneesh Kumar K.V buffer = kmalloc(size, GFP_KERNEL); 1326e8dc555SAneesh Kumar K.V if (!buffer) 1336e8dc555SAneesh Kumar K.V return -ENOMEM; 1346e8dc555SAneesh Kumar K.V retval = posix_acl_to_xattr(acl, buffer, size); 1356e8dc555SAneesh Kumar K.V if (retval < 0) 1366e8dc555SAneesh Kumar K.V goto err_free_out; 1376e8dc555SAneesh Kumar K.V switch (type) { 1386e8dc555SAneesh Kumar K.V case ACL_TYPE_ACCESS: 1396e8dc555SAneesh Kumar K.V name = POSIX_ACL_XATTR_ACCESS; 1406e8dc555SAneesh Kumar K.V break; 1416e8dc555SAneesh Kumar K.V case ACL_TYPE_DEFAULT: 1426e8dc555SAneesh Kumar K.V name = POSIX_ACL_XATTR_DEFAULT; 1436e8dc555SAneesh Kumar K.V break; 1446e8dc555SAneesh Kumar K.V default: 1456e8dc555SAneesh Kumar K.V BUG(); 1466e8dc555SAneesh Kumar K.V } 1476e8dc555SAneesh Kumar K.V retval = v9fs_xattr_set(dentry, name, buffer, size, 0); 1486e8dc555SAneesh Kumar K.V err_free_out: 1496e8dc555SAneesh Kumar K.V kfree(buffer); 1506e8dc555SAneesh Kumar K.V return retval; 1516e8dc555SAneesh Kumar K.V } 1526e8dc555SAneesh Kumar K.V 1536e8dc555SAneesh Kumar K.V int v9fs_acl_chmod(struct dentry *dentry) 1546e8dc555SAneesh Kumar K.V { 1556e8dc555SAneesh Kumar K.V int retval = 0; 156bc26ab5fSAl Viro struct posix_acl *acl; 1576e8dc555SAneesh Kumar K.V struct inode *inode = dentry->d_inode; 1586e8dc555SAneesh Kumar K.V 1596e8dc555SAneesh Kumar K.V if (S_ISLNK(inode->i_mode)) 1606e8dc555SAneesh Kumar K.V return -EOPNOTSUPP; 1616e8dc555SAneesh Kumar K.V acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); 1626e8dc555SAneesh Kumar K.V if (acl) { 163bc26ab5fSAl Viro retval = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 164bc26ab5fSAl Viro if (retval) 165bc26ab5fSAl Viro return retval; 166bc26ab5fSAl Viro retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, acl); 1676e8dc555SAneesh Kumar K.V posix_acl_release(acl); 1686e8dc555SAneesh Kumar K.V } 1696e8dc555SAneesh Kumar K.V return retval; 1706e8dc555SAneesh Kumar K.V } 1716e8dc555SAneesh Kumar K.V 172ad77dbceSAneesh Kumar K.V int v9fs_set_create_acl(struct dentry *dentry, 1731ec95bf3SAl Viro struct posix_acl **dpacl, struct posix_acl **pacl) 174ad77dbceSAneesh Kumar K.V { 1751ec95bf3SAl Viro if (dentry) { 1761ec95bf3SAl Viro v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, *dpacl); 1771ec95bf3SAl Viro v9fs_set_acl(dentry, ACL_TYPE_ACCESS, *pacl); 1781ec95bf3SAl Viro } 1791ec95bf3SAl Viro posix_acl_release(*dpacl); 1801ec95bf3SAl Viro posix_acl_release(*pacl); 1811ec95bf3SAl Viro *dpacl = *pacl = NULL; 182ad77dbceSAneesh Kumar K.V return 0; 183ad77dbceSAneesh Kumar K.V } 184ad77dbceSAneesh Kumar K.V 185*d3fb6120SAl Viro int v9fs_acl_mode(struct inode *dir, umode_t *modep, 186ad77dbceSAneesh Kumar K.V struct posix_acl **dpacl, struct posix_acl **pacl) 187ad77dbceSAneesh Kumar K.V { 188ad77dbceSAneesh Kumar K.V int retval = 0; 189*d3fb6120SAl Viro umode_t mode = *modep; 190ad77dbceSAneesh Kumar K.V struct posix_acl *acl = NULL; 191ad77dbceSAneesh Kumar K.V 192ad77dbceSAneesh Kumar K.V if (!S_ISLNK(mode)) { 193ad77dbceSAneesh Kumar K.V acl = v9fs_get_cached_acl(dir, ACL_TYPE_DEFAULT); 194ad77dbceSAneesh Kumar K.V if (IS_ERR(acl)) 195ad77dbceSAneesh Kumar K.V return PTR_ERR(acl); 196ad77dbceSAneesh Kumar K.V if (!acl) 197ad77dbceSAneesh Kumar K.V mode &= ~current_umask(); 198ad77dbceSAneesh Kumar K.V } 199ad77dbceSAneesh Kumar K.V if (acl) { 200ad77dbceSAneesh Kumar K.V if (S_ISDIR(mode)) 2011ec95bf3SAl Viro *dpacl = posix_acl_dup(acl); 202826cae2fSAl Viro retval = posix_acl_create(&acl, GFP_NOFS, &mode); 203826cae2fSAl Viro if (retval < 0) 204826cae2fSAl Viro return retval; 205ad77dbceSAneesh Kumar K.V if (retval > 0) 206826cae2fSAl Viro *pacl = acl; 2071ec95bf3SAl Viro else 208826cae2fSAl Viro posix_acl_release(acl); 209ad77dbceSAneesh Kumar K.V } 210ad77dbceSAneesh Kumar K.V *modep = mode; 211ad77dbceSAneesh Kumar K.V return 0; 212ad77dbceSAneesh Kumar K.V } 213ad77dbceSAneesh Kumar K.V 21476381a42SAneesh Kumar K.V static int v9fs_remote_get_acl(struct dentry *dentry, const char *name, 21576381a42SAneesh Kumar K.V void *buffer, size_t size, int type) 21676381a42SAneesh Kumar K.V { 21776381a42SAneesh Kumar K.V char *full_name; 21876381a42SAneesh Kumar K.V 21976381a42SAneesh Kumar K.V switch (type) { 22076381a42SAneesh Kumar K.V case ACL_TYPE_ACCESS: 22176381a42SAneesh Kumar K.V full_name = POSIX_ACL_XATTR_ACCESS; 22276381a42SAneesh Kumar K.V break; 22376381a42SAneesh Kumar K.V case ACL_TYPE_DEFAULT: 22476381a42SAneesh Kumar K.V full_name = POSIX_ACL_XATTR_DEFAULT; 22576381a42SAneesh Kumar K.V break; 22676381a42SAneesh Kumar K.V default: 22776381a42SAneesh Kumar K.V BUG(); 22876381a42SAneesh Kumar K.V } 22976381a42SAneesh Kumar K.V return v9fs_xattr_get(dentry, full_name, buffer, size); 23076381a42SAneesh Kumar K.V } 23176381a42SAneesh Kumar K.V 2327a4566b0SAneesh Kumar K.V static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, 2337a4566b0SAneesh Kumar K.V void *buffer, size_t size, int type) 2347a4566b0SAneesh Kumar K.V { 23576381a42SAneesh Kumar K.V struct v9fs_session_info *v9ses; 2367a4566b0SAneesh Kumar K.V struct posix_acl *acl; 2377a4566b0SAneesh Kumar K.V int error; 2387a4566b0SAneesh Kumar K.V 2397a4566b0SAneesh Kumar K.V if (strcmp(name, "") != 0) 2407a4566b0SAneesh Kumar K.V return -EINVAL; 2417a4566b0SAneesh Kumar K.V 24242869c8aSAneesh Kumar K.V v9ses = v9fs_dentry2v9ses(dentry); 24376381a42SAneesh Kumar K.V /* 24476381a42SAneesh Kumar K.V * We allow set/get/list of acl when access=client is not specified 24576381a42SAneesh Kumar K.V */ 24676381a42SAneesh Kumar K.V if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) 24776381a42SAneesh Kumar K.V return v9fs_remote_get_acl(dentry, name, buffer, size, type); 24876381a42SAneesh Kumar K.V 2497a4566b0SAneesh Kumar K.V acl = v9fs_get_cached_acl(dentry->d_inode, type); 2507a4566b0SAneesh Kumar K.V if (IS_ERR(acl)) 2517a4566b0SAneesh Kumar K.V return PTR_ERR(acl); 2527a4566b0SAneesh Kumar K.V if (acl == NULL) 2537a4566b0SAneesh Kumar K.V return -ENODATA; 2547a4566b0SAneesh Kumar K.V error = posix_acl_to_xattr(acl, buffer, size); 2557a4566b0SAneesh Kumar K.V posix_acl_release(acl); 2567a4566b0SAneesh Kumar K.V 2577a4566b0SAneesh Kumar K.V return error; 2587a4566b0SAneesh Kumar K.V } 2597a4566b0SAneesh Kumar K.V 26076381a42SAneesh Kumar K.V static int v9fs_remote_set_acl(struct dentry *dentry, const char *name, 26176381a42SAneesh Kumar K.V const void *value, size_t size, 26276381a42SAneesh Kumar K.V int flags, int type) 26376381a42SAneesh Kumar K.V { 26476381a42SAneesh Kumar K.V char *full_name; 26576381a42SAneesh Kumar K.V 26676381a42SAneesh Kumar K.V switch (type) { 26776381a42SAneesh Kumar K.V case ACL_TYPE_ACCESS: 26876381a42SAneesh Kumar K.V full_name = POSIX_ACL_XATTR_ACCESS; 26976381a42SAneesh Kumar K.V break; 27076381a42SAneesh Kumar K.V case ACL_TYPE_DEFAULT: 27176381a42SAneesh Kumar K.V full_name = POSIX_ACL_XATTR_DEFAULT; 27276381a42SAneesh Kumar K.V break; 27376381a42SAneesh Kumar K.V default: 27476381a42SAneesh Kumar K.V BUG(); 27576381a42SAneesh Kumar K.V } 27676381a42SAneesh Kumar K.V return v9fs_xattr_set(dentry, full_name, value, size, flags); 27776381a42SAneesh Kumar K.V } 27876381a42SAneesh Kumar K.V 27976381a42SAneesh Kumar K.V 2807a4566b0SAneesh Kumar K.V static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name, 2817a4566b0SAneesh Kumar K.V const void *value, size_t size, 2827a4566b0SAneesh Kumar K.V int flags, int type) 2837a4566b0SAneesh Kumar K.V { 28422d8dcdfSAneesh Kumar K.V int retval; 28522d8dcdfSAneesh Kumar K.V struct posix_acl *acl; 28676381a42SAneesh Kumar K.V struct v9fs_session_info *v9ses; 28722d8dcdfSAneesh Kumar K.V struct inode *inode = dentry->d_inode; 28822d8dcdfSAneesh Kumar K.V 28922d8dcdfSAneesh Kumar K.V if (strcmp(name, "") != 0) 29022d8dcdfSAneesh Kumar K.V return -EINVAL; 29176381a42SAneesh Kumar K.V 29242869c8aSAneesh Kumar K.V v9ses = v9fs_dentry2v9ses(dentry); 29376381a42SAneesh Kumar K.V /* 29476381a42SAneesh Kumar K.V * set the attribute on the remote. Without even looking at the 29576381a42SAneesh Kumar K.V * xattr value. We leave it to the server to validate 29676381a42SAneesh Kumar K.V */ 29776381a42SAneesh Kumar K.V if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) 29876381a42SAneesh Kumar K.V return v9fs_remote_set_acl(dentry, name, 29976381a42SAneesh Kumar K.V value, size, flags, type); 30076381a42SAneesh Kumar K.V 30122d8dcdfSAneesh Kumar K.V if (S_ISLNK(inode->i_mode)) 30222d8dcdfSAneesh Kumar K.V return -EOPNOTSUPP; 3032e149670SSerge E. Hallyn if (!inode_owner_or_capable(inode)) 30422d8dcdfSAneesh Kumar K.V return -EPERM; 30522d8dcdfSAneesh Kumar K.V if (value) { 30622d8dcdfSAneesh Kumar K.V /* update the cached acl value */ 30722d8dcdfSAneesh Kumar K.V acl = posix_acl_from_xattr(value, size); 30822d8dcdfSAneesh Kumar K.V if (IS_ERR(acl)) 30922d8dcdfSAneesh Kumar K.V return PTR_ERR(acl); 31022d8dcdfSAneesh Kumar K.V else if (acl) { 31122d8dcdfSAneesh Kumar K.V retval = posix_acl_valid(acl); 31222d8dcdfSAneesh Kumar K.V if (retval) 31322d8dcdfSAneesh Kumar K.V goto err_out; 31422d8dcdfSAneesh Kumar K.V } 31522d8dcdfSAneesh Kumar K.V } else 31622d8dcdfSAneesh Kumar K.V acl = NULL; 31722d8dcdfSAneesh Kumar K.V 31822d8dcdfSAneesh Kumar K.V switch (type) { 31922d8dcdfSAneesh Kumar K.V case ACL_TYPE_ACCESS: 32022d8dcdfSAneesh Kumar K.V name = POSIX_ACL_XATTR_ACCESS; 32122d8dcdfSAneesh Kumar K.V if (acl) { 32222d8dcdfSAneesh Kumar K.V mode_t mode = inode->i_mode; 32322d8dcdfSAneesh Kumar K.V retval = posix_acl_equiv_mode(acl, &mode); 32422d8dcdfSAneesh Kumar K.V if (retval < 0) 32522d8dcdfSAneesh Kumar K.V goto err_out; 32622d8dcdfSAneesh Kumar K.V else { 32722d8dcdfSAneesh Kumar K.V struct iattr iattr; 32822d8dcdfSAneesh Kumar K.V if (retval == 0) { 32922d8dcdfSAneesh Kumar K.V /* 33022d8dcdfSAneesh Kumar K.V * ACL can be represented 33122d8dcdfSAneesh Kumar K.V * by the mode bits. So don't 33222d8dcdfSAneesh Kumar K.V * update ACL. 33322d8dcdfSAneesh Kumar K.V */ 33422d8dcdfSAneesh Kumar K.V acl = NULL; 33522d8dcdfSAneesh Kumar K.V value = NULL; 33622d8dcdfSAneesh Kumar K.V size = 0; 33722d8dcdfSAneesh Kumar K.V } 33822d8dcdfSAneesh Kumar K.V /* Updte the mode bits */ 33922d8dcdfSAneesh Kumar K.V iattr.ia_mode = ((mode & S_IALLUGO) | 34022d8dcdfSAneesh Kumar K.V (inode->i_mode & ~S_IALLUGO)); 34122d8dcdfSAneesh Kumar K.V iattr.ia_valid = ATTR_MODE; 34222d8dcdfSAneesh Kumar K.V /* FIXME should we update ctime ? 34322d8dcdfSAneesh Kumar K.V * What is the following setxattr update the 34422d8dcdfSAneesh Kumar K.V * mode ? 34522d8dcdfSAneesh Kumar K.V */ 34622d8dcdfSAneesh Kumar K.V v9fs_vfs_setattr_dotl(dentry, &iattr); 34722d8dcdfSAneesh Kumar K.V } 34822d8dcdfSAneesh Kumar K.V } 34922d8dcdfSAneesh Kumar K.V break; 35022d8dcdfSAneesh Kumar K.V case ACL_TYPE_DEFAULT: 35122d8dcdfSAneesh Kumar K.V name = POSIX_ACL_XATTR_DEFAULT; 35222d8dcdfSAneesh Kumar K.V if (!S_ISDIR(inode->i_mode)) { 3536f81c115SAneesh Kumar K.V retval = acl ? -EINVAL : 0; 35422d8dcdfSAneesh Kumar K.V goto err_out; 35522d8dcdfSAneesh Kumar K.V } 35622d8dcdfSAneesh Kumar K.V break; 35722d8dcdfSAneesh Kumar K.V default: 35822d8dcdfSAneesh Kumar K.V BUG(); 35922d8dcdfSAneesh Kumar K.V } 36022d8dcdfSAneesh Kumar K.V retval = v9fs_xattr_set(dentry, name, value, size, flags); 36122d8dcdfSAneesh Kumar K.V if (!retval) 36222d8dcdfSAneesh Kumar K.V set_cached_acl(inode, type, acl); 36322d8dcdfSAneesh Kumar K.V err_out: 36422d8dcdfSAneesh Kumar K.V posix_acl_release(acl); 36522d8dcdfSAneesh Kumar K.V return retval; 3667a4566b0SAneesh Kumar K.V } 3677a4566b0SAneesh Kumar K.V 3687a4566b0SAneesh Kumar K.V const struct xattr_handler v9fs_xattr_acl_access_handler = { 3697a4566b0SAneesh Kumar K.V .prefix = POSIX_ACL_XATTR_ACCESS, 3707a4566b0SAneesh Kumar K.V .flags = ACL_TYPE_ACCESS, 3717a4566b0SAneesh Kumar K.V .get = v9fs_xattr_get_acl, 3727a4566b0SAneesh Kumar K.V .set = v9fs_xattr_set_acl, 3737a4566b0SAneesh Kumar K.V }; 3747a4566b0SAneesh Kumar K.V 3757a4566b0SAneesh Kumar K.V const struct xattr_handler v9fs_xattr_acl_default_handler = { 3767a4566b0SAneesh Kumar K.V .prefix = POSIX_ACL_XATTR_DEFAULT, 3777a4566b0SAneesh Kumar K.V .flags = ACL_TYPE_DEFAULT, 3787a4566b0SAneesh Kumar K.V .get = v9fs_xattr_get_acl, 3797a4566b0SAneesh Kumar K.V .set = v9fs_xattr_set_acl, 3807a4566b0SAneesh Kumar K.V }; 381