diff mbox

[V9fs-developer,PATCH-V2,1/2,9p] Add a helper function to get fsgid for a file create.

Message ID 1275592343-326-2-git-send-email-jvrao@linux.vnet.ibm.com (mailing list archive)
State Accepted, archived
Delegated to: Eric Van Hensbergen
Headers show

Commit Message

jvrao June 3, 2010, 7:12 p.m. UTC
None
diff mbox

Patch

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 0c9f103..03aa4b0 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 dentry *dir_dentry)
+{
+	BUG_ON(dir_dentry->d_inode == NULL);
+
+	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