From patchwork Tue Jun 1 22:15:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 103656 X-Patchwork-Delegate: ericvh@gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o51MCXC7021768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 1 Jun 2010 22:13:09 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 1OJZhF-0006gX-V4; Tue, 01 Jun 2010 22:12:29 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OJZhE-0006gK-A7 for v9fs-developer@lists.sourceforge.net; Tue, 01 Jun 2010 22:12:28 +0000 X-ACL-Warn: Received: from e38.co.us.ibm.com ([32.97.110.159]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1OJZhD-0006Gb-6e for v9fs-developer@lists.sourceforge.net; Tue, 01 Jun 2010 22:12:28 +0000 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o51M5lru014082 for ; Tue, 1 Jun 2010 16:05:47 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o51MC3Hn135790 for ; Tue, 1 Jun 2010 16:12:05 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o51MC2eA023639 for ; Tue, 1 Jun 2010 16:12:03 -0600 Received: from localhost.localdomain (elm9m80.beaverton.ibm.com [9.47.81.80]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o51MC1cL023539; Tue, 1 Jun 2010 16:12:02 -0600 From: "Venkateswararao Jujjuri (JV)" To: v9fs-developer@lists.sourceforge.net Date: Tue, 1 Jun 2010 15:15:46 -0700 Message-Id: <1275430547-32523-2-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1275430547-32523-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1275430547-32523-1-git-send-email-jvrao@linux.vnet.ibm.com> X-Spam-Score: -0.3 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.3 AWL AWL: From: address is in the auto white-list X-Headers-End: 1OJZhD-0006Gb-6e Subject: [V9fs-developer] [PATCH 1/2] [9p] Add a helper function to get egid for a file create. 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 (demeter.kernel.org [140.211.167.41]); Tue, 01 Jun 2010 22:13:09 +0000 (UTC) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 0c9f103..03e751b 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -236,6 +236,43 @@ void v9fs_destroy_inode(struct inode *inode) #endif /** + * v9fs_get_egid - Helper function to get the gid for creating a new file + * system object. This checks the S_ISGID to determine the owning group of the + * new file system object. + */ + +gid_t v9fs_get_egid(struct v9fs_session_info *v9ses, struct p9_fid *dfid, + struct dentry *dir_dentry) +{ + if (v9ses->cache != CACHE_LOOSE && v9ses->cache != CACHE_FSCACHE) { + /* No caching. Get attributes from server */ + if (v9fs_proto_dotl(v9ses)) { + struct p9_stat_dotl *st; + st = p9_client_getattr_dotl(dfid); + if (IS_ERR(st)) + return PTR_ERR(st); + v9fs_stat2inode_dotl(st, dir_dentry->d_inode); + kfree(st); + } else { + struct p9_wstat *st; + st = p9_client_stat(dfid); + if (IS_ERR(st)) + return PTR_ERR(st); + v9fs_stat2inode(st, dir_dentry->d_inode, + dir_dentry->d_inode->i_sb); + kfree(st); + } + } + + if (dir_dentry->d_inode->i_mode & S_ISGID) { + /* set_gid bit is set.*/ + return dir_dentry->d_inode->i_gid; + } + + return current_fsgid(); +} + +/** * v9fs_get_inode - helper function to setup an inode * @sb: superblock * @mode: mode to setup inode with