Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c087b51 authored by Chris Ball's avatar Chris Ball Committed by Chris Mason
Browse files

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: default avatarChris Ball <cjb@laptop.org>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent bd56b302
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -3472,7 +3472,14 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
		root->highest_inode = objectid;

	inode->i_uid = current_fsuid();

	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);