[PATCH v7 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-20 Thread Tomohiro Misono
Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns the information of subvolume containing this inode. (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.) Reviewed-by: Gu Jinxiang <g...@cn.fujitsu.com> Tested-by: Gu Jinxiang <g...@cn.fujitsu.com> Signed-off-

[PATCH v7 0/3] btrfs: Add three new unprivileged ioctls to allow normal users to call "sub list/show" etc.

2018-05-20 Thread Tomohiro Misono
mentation of btrfs-progs can be found in the ML titled as follows: [PATCH 0/11] btrfs-progs: Rework of "subvolume list/show" and relax the root privileges of them Tomohiro Misono (3): btrfs: Add unprivileged ioctl which returns subvolume information btrfs: Add unprivileged ioctl whic

[PATCH v7 2/3] btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

2018-05-20 Thread Tomohiro Misono
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 <w...@suse.com> Reviewed-by: Gu Jinxiang <g...@cn.fujitsu.com> Tested-by: Gu Jinxiang <g...@cn.fujitsu.com> Signe

[PATCH v7 3/3] btrfs: Add unprivileged version of ino_lookup ioctl

2018-05-20 Thread Tomohiro Misono
ted-by: Gu Jinxiang <g...@cn.fujitsu.com> Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- fs/btrfs/ioctl.c | 204 + include/uapi/linux/btrfs.h | 17 2 files changed, 221 insertions(+) diff --git a/fs/btrfs/ioctl.c b/f

[PATCH v6 3/3] btrfs: Add unprivileged version of ino_lookup ioctl

2018-05-17 Thread Tomohiro Misono
subvolume is also searched and filled. Note that the maximum length of path is shorter 256 (BTRFS_VOL_NAME_MAX+1) bytes than ino_lookup ioctl because of space of subvolume's name. Reviewed-by: Gu Jinxiang <g...@cn.fujitsu.com> Reviewed-by: Qu Wenruo <w...@suse.com> Signed-o

[PATCH v6 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Tomohiro Misono
Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns the information of subvolume containing this inode. (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.) Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- v5 -> v6 - Use brfs_read_fs_roo

[PATCH v6 0/3] btrfs: Add three new unprivileged ioctls to allow normal users to call "sub list/show" etc.

2018-05-17 Thread Tomohiro Misono
relax the root privileges of them Tomohiro Misono (3): btrfs: Add unprivileged ioctl which returns subvolume information btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF btrfs: Add unprivileged version of ino_lookup ioctl fs/btrfs/ioctl.c | 431

[PATCH v6 2/3] btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

2018-05-17 Thread Tomohiro Misono
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 <w...@suse.com> Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- v4 -> v5 - Update

[PATCH v2 2/2] btrfs: sysfs: Add entry which shows rmdir(2) can work for subvolume

2018-05-16 Thread Tomohiro Misono
es which only depend on kernel version. New attribute_group "btrfs_static_feature_attr_group" is created for this purpose. Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- fs/btrfs/sysfs.c | 29 + 1 file changed, 29 insertions(+) diff

[PATCH v2 0/2] btrfs: sysfs: Add entry which shows rmdir(2) can work for subvolume

2018-05-16 Thread Tomohiro Misono
nup and the second one is a main part. Tomohiro Misono (2): btrfs: sysfs: Use enum/define value intead of magic number btrfs: sysfs: Add entry which shows rmdir(2) can work for subvolume fs/btrfs/sysfs.c | 40 +++- fs/btrfs/sysfs.h | 4 ++-- 2 files chan

[PATCH v2 1/2] btrfs: sysfs: Use enum/define value intead of magic number

2018-05-16 Thread Tomohiro Misono
Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- fs/btrfs/sysfs.c | 11 ++- fs/btrfs/sysfs.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index fa6c8c88b250..217d401fe8ae 100644 --- a/fs/btrfs/s

[PATCH v5 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-15 Thread Tomohiro Misono
Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns the information of subvolume containing this inode. (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.) Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- v4 -> v5 - Update error

[PATCH v5 0/3] btrfs: Add three new unprivileged ioctls to allow normal users to call "sub list/show" etc.

2018-05-15 Thread Tomohiro Misono
it log for more detals. The implementation of btrfs-progs can be found in the ML titled as follows: [PATCH 0/11] btrfs-progs: Rework of "subvolume list/show" and relax the root privileges of them Tomohiro Misono (3): btrfs: Add unprivileged ioctl which returns subvolume information btr

[PATCH v5 2/3] btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

2018-05-15 Thread Tomohiro Misono
BTRFS_MAX_ROOTREF_BUFFER_NUM, -EOVERFLOW is returned. Therefore the caller can just call this ioctl again without changing the argument to continue search. Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- v4 -> v5 - Update error handling of btrfs_next_leaf() to cover all cases

[PATCH v5 3/3] btrfs: Add unprivileged version of ino_lookup ioctl

2018-05-15 Thread Tomohiro Misono
of bottom subvolume is also searched and filled. Note that the maximum length of path is shorter 256 (BTRFS_VOL_NAME_MAX+1) bytes than ino_lookup ioctl because of space of subvolume's name. Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- fs/btrfs/ioctl.c

[PATCH 00/11] btrfs-progs: Rework of "subvolume list/show" and relax the root privileges of them

2018-05-11 Thread Tomohiro Misono
and list them as well - Remove obsolete field (i.e. top-level) from output Any comments are welcome. Thanks, Tomohiro Misono [1] https://www.spinics.net/lists/linux-btrfs/msg76008.html [2] https://www.spinics.net/lists/linux-btrfs/msg74917.html Tomohiro Misono (11): btrfs-prog

[PATCH 11/11] btrfs-porgs: test: Add cli-test/009 to check subvolume list for both root and normal user

2018-05-11 Thread Tomohiro Misono
Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- tests/cli-tests/009-subvolume-list/test.sh | 136 + 1 file changed, 136 insertions(+) create mode 100755 tests/cli-tests/009-subvolume-list/test.sh diff --git a/tests/cli-tests/009-subvolum

[PATCH 03/11] btrfs-porgs: libbtrfsutil: Relax the privileges of util_subvolume_info()

2018-05-11 Thread Tomohiro Misono
By using new ioctl (BTRFS_IOC_GET_SUBVOL_INFO), this commit allows non-privileged user to call util_subvolume_info() as long as @id is zero (user can only get the information of the subvolume which he can open). Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- libbtr

[PATCH 04/11] btrfs-progs: libbtrfsuitl: Factor out btrfs_util_subvolume_iterator_next()

2018-05-11 Thread Tomohiro Misono
Factor out the main logic of btrfs_util_subvolume_iterator_next(). This is a prepareation work to update the behavior of this function and relax the required root privilege. No functional change happens. Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- libbtr

[PATCH 05/11] btrfs-progs: libbtrfsutil: Update the behavior of subvolume iterator and relax the privileges

2018-05-11 Thread Tomohiro Misono
, non-privileged user can also use the iterator. If @top is specified, the behavior is the same as before (and thus non-privileged user cannot use). Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- libbtrfsutil/btrfsutil.h | 19 ++- libbtrfsutil/errors.c| 4 + libbtr

[PATCH 06/11] btrfs-progs: sub list: Use libbtrfsuitl for subvolume list

2018-05-11 Thread Tomohiro Misono
Sandoval <osan...@fb.com> Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- cmds-subvolume.c | 961 +-- 1 file changed, 934 insertions(+), 27 deletions(-) diff --git a/cmds-subvolume.c b/cmds-subvolume.c index 45363a

[PATCH 01/11] btrfs-progs: ioctl/libbtrfsutil: Add 3 definitions of new unprivileged ioctl

2018-05-11 Thread Tomohiro Misono
Add 3 definitions of new unprivileged ioctl (BTRFS_IOC_GET_SUBVOL_INFO, BTRFS_IOC_GET_SUBVOL_ROOTREF and BTRFS_IOC_INO_LOOKUP_USER). They will be used to implement the user version of "btrfs subvolume list" etc. Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com&

[PATCH 08/11] btrfs-progs: utils: Fallback to open without O_NOATIME flag in find_mount_root():

2018-05-11 Thread Tomohiro Misono
Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.c b/utils.c index d81d4980..84b81311 100644 --- a/utils.c +++ b/utils.c @@ -2048,6 +2048,9 @@ int find_mount_root(const char *path, char **mount_ro

[PATCH 07/11] btrfs-progs: sub list: Change the default behavior of "subvolume list" and allow non-privileged user to call it

2018-05-11 Thread Tomohiro Misono
T_SUBVOL_INFO/BTRFS_IOC_GET_ROOTREF/ BTRFS_IOC_INO_LOOKUP_USER), - the specified path can be non-subvolume directory. - non-privileged user can also call it. Note that root user can list all the subvolume in the fs with -a option (the same behavior as before). Signed-off-by: Tomohiro Misono

[PATCH 09/11] btrfs-progs: sub show: Allow non-privileged user to call "subvolume show"

2018-05-11 Thread Tomohiro Misono
list all snapshots in the fs (inc. non-accessible ones) user ... subvolume path is from mount point list snapshots under the mountpoint (to which the user has appropriate privileges) Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> ---

[PATCH v4 2/3] btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

2018-05-11 Thread Tomohiro Misono
BTRFS_MAX_ROOTREF_BUFFER_NUM, -EOVERFLOW is returned. Therefore the caller can just call this ioctl again without changing the argument to continue search. Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- fs/btrfs/ioctl.c | 102 + i

[PATCH v4 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-11 Thread Tomohiro Misono
Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns the information of subvolume containing this inode. (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.) Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- fs/btrfs/ioctl.c

[PATCH v4 3/3] btrfs: Add unprivileged version of ino_lookup ioctl

2018-05-11 Thread Tomohiro Misono
of bottom subvolume is also searched and filled. Note that the maximum length of path is shorter 256 (BTRFS_VOL_NAME_MAX+1) bytes than ino_lookup ioctl because of space of subvolume's name. Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- fs/btrfs/ioctl.c

[PATCH v4 0/3] btrfs: Add three new unprivileged ioctls to allow normal users to call "sub list/show" etc.

2018-05-11 Thread Tomohiro Misono
quot;subvolume list/show" and relax the root privileges of them Tomohiro Misono (3): btrfs: Add unprivileged ioctl which returns subvolume information btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF btrfs: Add unprivileged version of ino_lookup ioctl fs/