From patchwork Mon Apr 23 05:08:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 10356141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A2376019D for ; Mon, 23 Apr 2018 05:10:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECE25289B4 for ; Mon, 23 Apr 2018 05:10:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDC9D289AF; Mon, 23 Apr 2018 05:10:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38297289AF for ; Mon, 23 Apr 2018 05:10:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751259AbeDWFId (ORCPT ); Mon, 23 Apr 2018 01:08:33 -0400 Received: from mgwkm02.jp.fujitsu.com ([202.219.69.169]:13254 "EHLO mgwkm02.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751061AbeDWFIc (ORCPT ); Mon, 23 Apr 2018 01:08:32 -0400 Received: from kw-mxoi2.gw.nic.fujitsu.com (unknown [192.168.231.133]) by mgwkm02.jp.fujitsu.com with smtp id 6a88_1db4_85711d05_f411_4d0d_866c_a8f9d8b89266; Mon, 23 Apr 2018 14:08:30 +0900 Received: from g01jpfmpwyt02.exch.g01.fujitsu.local (g01jpfmpwyt02.exch.g01.fujitsu.local [10.128.193.56]) by kw-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id F311CAC00D4 for ; Mon, 23 Apr 2018 14:08:29 +0900 (JST) Received: from g01jpexchyt33.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt02.exch.g01.fujitsu.local (Postfix) with ESMTP id 1EEA9584278 for ; Mon, 23 Apr 2018 14:08:29 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: 4e7546bdbd954a49bab89c3ffffb91f2 Subject: [RFC PATCH v4 2/6] btrfs-progs: ioctl: Add 3 definitions of new unprivileged ioctl From: Misono Tomohiro To: linux-btrfs References: <70590827-0c29-75ea-5e43-2e53264b3d4c@jp.fujitsu.com> Message-ID: <580f49ab-7025-6819-6801-3afb90a90134@jp.fujitsu.com> Date: Mon, 23 Apr 2018 14:08:25 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <70590827-0c29-75ea-5e43-2e53264b3d4c@jp.fujitsu.com> Content-Language: en-US X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 user version of "btrfs subvolume list" etc. Signed-off-by: Tomohiro Misono --- ioctl.h | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/ioctl.h b/ioctl.h index 709e996f..c6624352 100644 --- a/ioctl.h +++ b/ioctl.h @@ -320,6 +320,22 @@ struct btrfs_ioctl_ino_lookup_args { }; BUILD_ASSERT(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096); +#define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080-BTRFS_VOL_NAME_MAX-1) +struct btrfs_ioctl_ino_lookup_user_args { + /* in, inode number containing the subvolume of 'subvolid' */ + __u64 dirid; + /* in */ + __u64 subvolid; + /* out, name of the subvolume of 'subvolid' */ + char name[BTRFS_VOL_NAME_MAX + 1]; + /* + * out, constructed path from the directory with which + * the ioctl is called to dirid + */ + char path[BTRFS_INO_LOOKUP_USER_PATH_MAX]; +}; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096); + struct btrfs_ioctl_search_key { /* which root are we searching. 0 is the tree of tree roots */ __u64 tree_id; @@ -672,6 +688,70 @@ BUILD_ASSERT(sizeof(struct btrfs_ioctl_send_args_64) == 72); #define BTRFS_IOC_SEND_64_COMPAT_DEFINED 1 +struct btrfs_ioctl_get_subvol_info_args { + /* All filed is out */ + /* Id of this subvolume */ + __u64 id; + /* Name of this subvolume, used to get the real name at mount point */ + char name[BTRFS_VOL_NAME_MAX + 1]; + /* + * Id of the subvolume which contains this subvolume. + * Zero for top-level subvolume or deleted subvolume + */ + __u64 parent_id; + /* + * Inode number of the directory which contains this subvolume. + * Zero for top-level subvolume or deleted subvolume + */ + __u64 dirid; + + /* Latest transaction id of this subvolume */ + __u64 generation; + /* Flags of this subvolume */ + __u64 flags; + + /* uuid of this subvolume */ + __u8 uuid[BTRFS_UUID_SIZE]; + /* + * uuid of the subvolume of which this subvolume is a snapshot. + * All zero for non-snapshot subvolume + */ + __u8 parent_uuid[BTRFS_UUID_SIZE]; + /* + * uuid of the subvolume from which this subvolume is received. + * All zero for non-received subvolume + */ + __u8 received_uuid[BTRFS_UUID_SIZE]; + + /* Transaction id indicates when change/create/send/receive happens */ + __u64 ctransid; + __u64 otransid; + __u64 stransid; + __u64 rtransid; + /* Time corresponds to c/o/s/rtransid */ + struct btrfs_ioctl_timespec ctime; + struct btrfs_ioctl_timespec otime; + struct btrfs_ioctl_timespec stime; + struct btrfs_ioctl_timespec rtime; + + __u64 reserved[8]; +}; + +#define BTRFS_MAX_ROOTREF_BUFFER_NUM 255 +struct btrfs_ioctl_get_subvol_rootref_args { + /* in/out, min id of rootref's subvolid to be searched */ + __u64 min_id; + /* out */ + struct { + __u64 subvolid; + __u64 dirid; + } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM]; + /* out, number of found items */ + __u8 num_items; + __u8 align[7]; +}; +BUILD_ASSERT(sizeof(struct btrfs_ioctl_get_subvol_rootref_args) == 4096); + /* Error codes as returned by the kernel */ enum btrfs_err_code { notused, @@ -828,6 +908,12 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code) struct btrfs_ioctl_feature_flags[3]) #define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \ struct btrfs_ioctl_vol_args_v2) +#define BTRFS_IOC_GET_SUBVOL_INFO _IOR(BTRFS_IOCTL_MAGIC, 60, \ + struct btrfs_ioctl_get_subvol_info_args) +#define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \ + struct btrfs_ioctl_get_subvol_rootref_args) +#define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \ + struct btrfs_ioctl_ino_lookup_user_args) #ifdef __cplusplus } #endif