Skip to content

Commit

Permalink
Btrfs: Handle SGID bit when creating inodes
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
cjb authored and chrismason-xx committed Feb 4, 2009
1 parent bd56b30 commit 8c087b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8c087b5

Please sign in to comment.