From patchwork Tue Jun 8 06:31:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 104885 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 o586SRB3019111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 8 Jun 2010 06:29:03 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OLsIO-0005aC-Rs; Tue, 08 Jun 2010 06:28:20 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OLsIN-0005Zw-Fe for v9fs-developer@lists.sourceforge.net; Tue, 08 Jun 2010 06:28:19 +0000 X-ACL-Warn: Received: from e33.co.us.ibm.com ([32.97.110.151]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1OLsIM-000425-9e for v9fs-developer@lists.sourceforge.net; Tue, 08 Jun 2010 06:28:19 +0000 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e33.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o586NveO028067 for ; Tue, 8 Jun 2010 00:23:57 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o586SCSF135340 for ; Tue, 8 Jun 2010 00:28:12 -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 o586SBRT008006 for ; Tue, 8 Jun 2010 00:28:11 -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 o586SBw1007958; Tue, 8 Jun 2010 00:28:11 -0600 From: "Venkateswararao Jujjuri (JV)" To: v9fs-developer@lists.sourceforge.net Date: Mon, 7 Jun 2010 23:31:56 -0700 Message-Id: <1275978716-5633-1-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 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: 1OLsIM-000425-9e Subject: [V9fs-developer] [PATCH-V3] [fs/9p] Add a wstat after TCREATE to fix the gid. 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, 08 Jun 2010 06:29:04 +0000 (UTC) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 0c9f103..bf42f28 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -236,6 +236,23 @@ void v9fs_destroy_inode(struct inode *inode) #endif /** + * v9fs_get_fsgid_for_create - 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_fsgid_for_create(struct inode *dir_inode) +{ + BUG_ON(dir_inode == NULL); + + if (dir_inode->i_mode & S_ISGID) { + /* set_gid bit is set.*/ + return dir_inode->i_gid; + } + return current_fsgid(); +} + +/** * v9fs_get_inode - helper function to setup an inode * @sb: superblock * @mode: mode to setup inode with @@ -572,6 +589,23 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, goto error; } + /* Server grabs uid information from the fid but we need to fix + * gid as dotu doesn't support sending gid on the wire with Tcreate. + * hardlink is an exception as it inherits all credentials. + */ + if (v9fs_proto_dotu(v9ses) && !(perm & P9_DMLINK)) { + struct p9_wstat wstat; + + v9fs_blank_wstat(&wstat); + wstat.n_gid = v9fs_get_fsgid_for_create(dir); + err = p9_client_wstat(fid, &wstat); + if (err < 0) { + P9_DPRINTK(P9_DEBUG_VFS, "p9_client_wstat failed %d\n", + err); + goto error; + } + } + /* instantiate inode and assign the unopened fid to the dentry */ inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb); if (IS_ERR(inode)) {