From: Chris Ball Date: Wed, 4 Feb 2009 14:29:54 +0000 (-0500) Subject: Btrfs: Handle SGID bit when creating inodes X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8c087b5183adab186a298f2d6ed39aefdcae413c;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git 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 Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 95ea58cb3065..5792816d4fca 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);