@@ -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