From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Djalal Harouni To: Alexander Viro , Chris Mason , , Serge Hallyn , Josh Triplett , "Eric W. Biederman" , Andy Lutomirski , Seth Forshee , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Dongsu Park , David Herrmann , Miklos Szeredi , Alban Crequy Cc: Djalal Harouni , Djalal Harouni Subject: [RFC v2 PATCH 8/8] btrfs: add support for vfs_shift_uids and vfs_shift_gids mount options Date: Wed, 4 May 2016 16:26:54 +0200 Message-Id: <1462372014-3786-9-git-send-email-tixxdz@gmail.com> In-Reply-To: <1462372014-3786-1-git-send-email-tixxdz@gmail.com> References: <1462372014-3786-1-git-send-email-tixxdz@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: Make btrfs able to parse vfs_shift_uids and vfs_shift_gids options and set the appropriate flags into the super_block structure. vfs_shift_uids and vfs_shift_gids allow mounts that show up in a mount namespace that supports VFS UID/GID shifts on inodes to perform translation from in kernel virtual view into on-disk view and vice versa. This allows user namespaces users to be able to access, read and write inodes on these mounts. Signed-off-by: Dongsu Park Signed-off-by: Djalal Harouni --- fs/btrfs/super.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 00b8f37..20e7223 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -304,7 +304,8 @@ enum { Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard, Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow, Opt_datasum, Opt_treelog, Opt_noinode_cache, Opt_usebackuproot, - Opt_nologreplay, Opt_norecovery, + Opt_nologreplay, Opt_norecovery, Opt_vfs_shift_uids, + Opt_vfs_shift_gids, #ifdef CONFIG_BTRFS_DEBUG Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all, #endif @@ -364,6 +365,8 @@ static const match_table_t tokens = { {Opt_rescan_uuid_tree, "rescan_uuid_tree"}, {Opt_fatal_errors, "fatal_errors=%s"}, {Opt_commit_interval, "commit=%d"}, + {Opt_vfs_shift_uids, "vfs_shift_uids"}, + {Opt_vfs_shift_gids, "vfs_shift_gids"}, #ifdef CONFIG_BTRFS_DEBUG {Opt_fragment_data, "fragment=data"}, {Opt_fragment_metadata, "fragment=metadata"}, @@ -786,6 +789,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options, info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL; } break; + case Opt_vfs_shift_uids: + root->fs_info->sb->s_iflags |= SB_I_VFS_SHIFT_UIDS; + break; + case Opt_vfs_shift_gids: + root->fs_info->sb->s_iflags |= SB_I_VFS_SHIFT_GIDS; + break; #ifdef CONFIG_BTRFS_DEBUG case Opt_fragment_all: btrfs_info(root->fs_info, "fragmenting all space"); @@ -1279,6 +1288,10 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) if (btrfs_test_opt(root, FRAGMENT_METADATA)) seq_puts(seq, ",fragment=metadata"); #endif + if (root->fs_info->sb->s_iflags & SB_I_VFS_SHIFT_UIDS) + seq_puts(seq, ",vfs_shift_uids"); + if (root->fs_info->sb->s_iflags & SB_I_VFS_SHIFT_GIDS) + seq_puts(seq, ",vfs_shift_gids"); seq_printf(seq, ",subvolid=%llu", BTRFS_I(d_inode(dentry))->root->root_key.objectid); seq_puts(seq, ",subvol="); -- 2.5.5