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>


authored by Chris Ball and committed by Chris Mason 8c087b51 bd56b302

+8 -1
+8 -1
fs/btrfs/inode.c
··· 3472 3472 root->highest_inode = objectid; 3473 3473 3474 3474 inode->i_uid = current_fsuid(); 3475 - inode->i_gid = current_fsgid(); 3475 + 3476 + if (dir->i_mode & S_ISGID) { 3477 + inode->i_gid = dir->i_gid; 3478 + if (S_ISDIR(mode)) 3479 + mode |= S_ISGID; 3480 + } else 3481 + inode->i_gid = current_fsgid(); 3482 + 3476 3483 inode->i_mode = mode; 3477 3484 inode->i_ino = objectid; 3478 3485 inode_set_bytes(inode, 0);