From patchwork Tue Sep 7 10:28:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 160271 X-Patchwork-Delegate: ericvh@gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o87ATH31028399 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 7 Sep 2010 10:29:55 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OsvQC-00024c-SJ; Tue, 07 Sep 2010 10:29:00 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OsvQB-00024K-Fv for v9fs-developer@lists.sourceforge.net; Tue, 07 Sep 2010 10:28:59 +0000 X-ACL-Warn: Received: from e28smtp04.in.ibm.com ([122.248.162.4]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1OsvQ8-0006sd-E0 for v9fs-developer@lists.sourceforge.net; Tue, 07 Sep 2010 10:28:59 +0000 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp04.in.ibm.com (8.14.4/8.13.1) with ESMTP id o87AShMS000354 for ; Tue, 7 Sep 2010 15:58:43 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o87AShIX3674366 for ; Tue, 7 Sep 2010 15:58:43 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o87AShbf020069 for ; Tue, 7 Sep 2010 15:58:43 +0530 Received: from localhost.localdomain ([9.77.212.73]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o87ASWNl019198; Tue, 7 Sep 2010 15:58:40 +0530 From: "Aneesh Kumar K.V" To: v9fs-developer@lists.sourceforge.net Date: Tue, 7 Sep 2010 15:58:22 +0530 Message-Id: <1283855304-22472-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1283855304-22472-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1283855304-22472-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Spam-Score: -0.2 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.1 AWL AWL: From: address is in the auto white-list X-Headers-End: 1OsvQ8-0006sd-E0 Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [V9fs-developer] [PATCH -V3 4/6] fs/9p: Update ACL on chmod X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Sep 2010 10:29:56 +0000 (UTC) diff --git a/fs/9p/acl.c b/fs/9p/acl.c index cad38bc..203da2b 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c @@ -97,6 +97,61 @@ int v9fs_check_acl(struct inode *inode, int mask) return -EAGAIN; } +static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl) +{ + int retval; + char *name; + size_t size; + void *buffer; + struct inode *inode = dentry->d_inode; + + set_cached_acl(inode, type, acl); + /* Set a setxattr request to server */ + size = posix_acl_xattr_size(acl->a_count); + buffer = kmalloc(size, GFP_KERNEL); + if (!buffer) + return -ENOMEM; + retval = posix_acl_to_xattr(acl, buffer, size); + if (retval) + goto err_free_out; + switch (type) { + case ACL_TYPE_ACCESS: + name = POSIX_ACL_XATTR_ACCESS; + break; + case ACL_TYPE_DEFAULT: + name = POSIX_ACL_XATTR_DEFAULT; + break; + default: + BUG(); + } + retval = v9fs_xattr_set(dentry, name, buffer, size, 0); +err_free_out: + kfree(buffer); + return retval; +} + +int v9fs_acl_chmod(struct dentry *dentry) +{ + int retval = 0; + struct posix_acl *acl, *clone; + struct inode *inode = dentry->d_inode; + + if (S_ISLNK(inode->i_mode)) + return -EOPNOTSUPP; + acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); + if (acl) { + clone = posix_acl_clone(acl, GFP_KERNEL); + posix_acl_release(acl); + if (!clone) + return -ENOMEM; + retval = posix_acl_chmod_masq(clone, inode->i_mode); + if (!retval) + retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, clone); + posix_acl_release(clone); + } + return retval; +} + static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, size_t size, int type) { diff --git a/fs/9p/acl.h b/fs/9p/acl.h index b1414f7..0adcc43 100644 --- a/fs/9p/acl.h +++ b/fs/9p/acl.h @@ -17,11 +17,16 @@ #ifdef CONFIG_9P_FS_POSIX_ACL extern int v9fs_get_acl(struct inode *, struct p9_fid *); extern int v9fs_check_acl(struct inode *inode, int mask); +extern int v9fs_acl_chmod(struct dentry *); #else #define v9fs_check_acl NULL static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) { return 0; } +static inline int v9fs_acl_chmod(struct dentry *dentry) +{ + return 0; +} #endif #endif /* FS_9P_XATTR_H */ diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index df5c6fa..7983698 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1284,6 +1284,12 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) setattr_copy(dentry->d_inode, iattr); mark_inode_dirty(dentry->d_inode); + if (iattr->ia_valid & ATTR_MODE) { + /* We also want to update ACL when we update mode bits */ + retval = v9fs_acl_chmod(dentry); + if (retval < 0) + return retval; + } return 0; }