summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2009-02-04 09:29:54 -0500
committerChris Mason <chris.mason@oracle.com>2009-02-04 09:29:54 -0500
commit8c087b5183adab186a298f2d6ed39aefdcae413c (patch)
treeee0ee85c27516f24d4456efed5f8561ee34b82f0 /fs
parentbd56b30205bc09da0beb80d4ba3d4c7309792da5 (diff)
downloadlinux-3.10-8c087b5183adab186a298f2d6ed39aefdcae413c.tar.gz
linux-3.10-8c087b5183adab186a298f2d6ed39aefdcae413c.tar.bz2
linux-3.10-8c087b5183adab186a298f2d6ed39aefdcae413c.zip
Btrfs: Handle SGID bit when creating inodes
Before this patch, new files/dirs would ignore the SGID bit on their parent directory and always be owned by the creating user's uid/gid. Signed-off-by: Chris Ball <cjb@laptop.org> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/inode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 95ea58cb306..5792816d4fc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3472,7 +3472,14 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
root->highest_inode = objectid;
inode->i_uid = current_fsuid();
- inode->i_gid = current_fsgid();
+
+ if (dir->i_mode & S_ISGID) {
+ inode->i_gid = dir->i_gid;
+ if (S_ISDIR(mode))
+ mode |= S_ISGID;
+ } else
+ inode->i_gid = current_fsgid();
+
inode->i_mode = mode;
inode->i_ino = objectid;
inode_set_bytes(inode, 0);