OSDN Git Service

btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF
authorTomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Mon, 21 May 2018 01:09:43 +0000 (10:09 +0900)
committerDavid Sterba <dsterba@suse.com>
Thu, 31 May 2018 09:35:23 +0000 (11:35 +0200)
commit42e4b520c812daaf5e6177c2e4beec012ce1e2ce
tree84dd5c98cf91db85fc13c84bff3a688b996f35fa
parentb64ec075bded2b30bcd90af5aa5256d2237c885d
btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

Add unprivileged ioctl BTRFS_IOC_GET_SUBVOL_ROOTREF which returns
ROOT_REF information of the subvolume containing this inode except the
subvolume name (this is because to prevent potential name leak). The
subvolume name will be gained by user version of ino_lookup ioctl
(BTRFS_IOC_INO_LOOKUP_USER) which also performs permission check.

The min id of root ref's subvolume to be searched is specified by
@min_id in struct btrfs_ioctl_get_subvol_rootref_args. After the search
ends, @min_id is set to the last searched root ref's subvolid + 1. Also,
if there are more root refs than BTRFS_MAX_ROOTREF_BUFFER_NUM,
-EOVERFLOW is returned. Therefore the caller can just call this ioctl
again without changing the argument to continue search.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Tested-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
[ style fixes and struct item renames ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c
include/uapi/linux/btrfs.h