From patchwork Mon Aug 31 11:07:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 275127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A80EAC433E6 for ; Mon, 31 Aug 2020 11:10:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73B372072D for ; Mon, 31 Aug 2020 11:10:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73B372072D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChhr-0004up-L5 for qemu-devel@archiver.kernel.org; Mon, 31 Aug 2020 07:10:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChes-00072a-Bt for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:30 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:47647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChep-0000Qy-D2 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:30 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MD9Gh-1kLoKJ1c2L-009BmA; Mon, 31 Aug 2020 13:07:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 2/8] linux-user: Add support for a group of btrfs ioctls used for snapshots Date: Mon, 31 Aug 2020 13:07:10 +0200 Message-Id: <20200831110716.536808-3-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:EzA98sguEbHWsaMgKalaPTLyEYD/KlsQ4v+9uyJDCi+wZ1+V2Ih iUCcgkBxqend/NaEu0CJ2K8OEbJXqbEnkTce+/alSJh5cIAfI2fa7rYeQxoiPUDmBnp2bcg 2AZP1SVTbhIoSrT7tA2i5RPPV9G9k0vwJeKxCoG1h8/6iHA19+d1wNx3uV+7lP8wDzuS2Kn CZ0lS0PaCeHgmZVS533Jw== X-UI-Out-Filterresults: notjunk:1; V03:K0:wyznPZP/ip4=:HPgBjFCkUwa3b3eVEEtpBx hZoDst76CmkRSp3uYMIIiZCZh50HH/YqObRCt/RXTa7RVZY2uhVBvkpR1Bkz3mjb1EytS1XLc YyELD3Uu2EJc/42HNrKSEsk20Fnr5FZTiJR6GbTaspxnykEjKMJXRPDrnYkgm1eYUntlsYiAX xBjO5hfpKl9HhbMQ4rn1vCpzS2SDKheHo5sn+X/uPHlEds+VypnCrEc+7CaDtgeCY/G9qph3a 3iqF6KNpvmu31N4Pi1LulQ3m97pCldWJ3IYYFctAi/DoOj2fl4XioDj5m5p7T5fkm2OrCWI38 VGdimf23pLb5GWkGpdAvuKxJ/8juE6DM0H/wqt6Vu6fduq/Ql27GfXX9CMaMz2aVwGlKZ5exB 2RLi47gqU4ZwnDo1W0MWSjJuYImGFh1Qv0Z8wMZOUeXX927ttXvGZpL3XZIGHo8rCwBQ77TPm vkDacS2AXHu6xHo0Y6o85CwlwHHpVZkZm4fWpPSWzqaFMlzKxR3OjcyE29TGIG0i25f1o/cTu A7sGL5xAc6i0+rRfa31sUCRAmqmAZxu2TgBWrZXM2kuaivR04OdFavCW9rVevYxXv07/TnWNl w2ZctmPnyvYHusgfwgTmMO2/nyWRUuoYY9AXLMVxh/ZbgXi6fY63cuubjTBHTRtmjxNzqVfSp Ww+JjKWnx2L3yvaZrv0k3uS6T+AVE7QL9EQQtLwm6tkBy8+kZ2LCP83ecVKXjWn0sK8MNmV6U 5mw4I0aw7Anlngw/iqPw951cPKzQMUK6zPnuwobzpKkNTYdW49ijK6PEUjNSsfn0hkkZHH4wG yvL5mUDE5AbzCaRPpNpvqFM/wUfE8J5bbqKC6sw3wQiSaT2vyMtjvxOcYuaK9Sh8k0yUppx Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_SNAP_CREATE - Creating a subvolume snapshot Create a snapshot of a btrfs subvolume. The snapshot is created using the ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_args' (which was mentioned in the previous patch). Before calling this ioctl, the fields of the structure should be filled with aproppriate values for the file descriptor and path of the subvolume for which the snapshot is to be created. BTRFS_IOC_SNAP_DESTROY - Removing a subvolume snapshot Delete a snapshot of a btrfs subvolume. The snapshot is deleted using the ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_args' (which was mentioned in the previous patch). Before calling this ioctl, the fields of the structure should be filled with aproppriate values for the file descriptor and path of the subvolume for which the snapshot is to be deleted. Implementation notes: Since the thunk type 'struct btrfs_ioctl_vol_args' is defined in the previous patch, the implementation for these ioctls was straightforward. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrangé Message-Id: <20200823195014.116226-3-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 8 ++++++++ linux-user/syscall_defs.h | 2 ++ linux-user/syscall_types.h | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index bf89b96d27b0..bddeaca9e7ec 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -174,10 +174,18 @@ IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) +#ifdef BTRFS_IOC_SNAP_CREATE + IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_CREATE IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_SNAP_DESTROY + IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) #endif diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index cae79f8492e1..1519de7a5565 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1006,7 +1006,9 @@ struct target_rtc_pll_info { #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) /* btrfs ioctls */ +#define TARGET_BTRFS_IOC_SNAP_CREATE TARGET_IOWU(BTRFS_IOCTL_MAGIC, 1) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MAGIC, 14) +#define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MAGIC, 15) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAGIC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, 26,\ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 0ce58d77727c..853b91d21275 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -358,7 +358,8 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */ MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ -#ifdef BTRFS_IOC_SUBVOL_CREATE +#if defined(BTRFS_IOC_SUBVOL_CREATE) || defined(BTRFS_IOC_SNAP_CREATE) || \ + defined(BTRFS_IOC_SNAP_DESTROY) STRUCT(btrfs_ioctl_vol_args, TYPE_LONGLONG, /* fd */ MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */ From patchwork Mon Aug 31 11:07:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 275128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 190F8C433E2 for ; Mon, 31 Aug 2020 11:09:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D4B6D2137B for ; Mon, 31 Aug 2020 11:09:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4B6D2137B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChh9-0003bz-1j for qemu-devel@archiver.kernel.org; Mon, 31 Aug 2020 07:09:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCheu-00077B-44 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:32 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:60799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCheq-0000RQ-P1 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:31 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N6t3Z-1kepiW1t4p-018JXs; Mon, 31 Aug 2020 13:07:23 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 4/8] linux-user: Add support for btrfs ioctls used to get/set features Date: Mon, 31 Aug 2020 13:07:12 +0200 Message-Id: <20200831110716.536808-5-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:j7ljY1ww8JtvgeUo2cgQ8ZbxgFvaHXLSn/jZDDAC4x4mVl6qKvd r56KwoOnLAcQkE1El/MgVpqneMS4/G4nteP5EszreOlTT1IJwUXAY30rwlUz2z4JV+5aD0L hJrjqpwOSdxdn5f1ITySPlNq5BqR+lkyeXOt7IB9+K9tL8NFrIwpXUk2KZYNy6ef4g7DhRY q5cWd4jbYUA48bUO+A2zQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:2WQC4smgRqA=:4dMe/2waTPp/dgZZUUlVon opmtgt06MAfHNydlUmf4l1eE1fdwrfWodVxD5ZXu7hzc70gL/ABH3PbFO7hx+GWL/pgxrcPMS L09y/3K6Ik25dMf03C0R+z98EbKfTnUyOfn6If1n66VW+26xhiS27fdHMaRKV0qYSRWaa+kcg glYS0lN6X9nFcXFh1neFoHEwD8obDfeO7B/BvQF8Mf1Bpmlh6ap5CE82ENOgLJxh+eLGsEwjm 3IsRdXjDWCjxhhNbpwdcNj1vrV/q6DIhPjcZINpQMxj5Ocqx/mCNI3yu7SXGskOdA84W5yt8N J6O9zMgt7fm2vHk7j5JIVegArGE/i7VFJhH/9+7Eu1BsiCWRLm4AtyNAAnQ+zL99dakfWJ2ta W5ITEkMxBN5lU3b8geSIdA9KecuMZ35cipJgZsvTgZwnQaijV3RiEQ3IycNc+Y7V2/6g7je3k GpcPaxLWUCBrqxZnfyANw0EAJyNvf0nGJjIXQnyhsW4hpPxZ2mIcx4H2eGkT9+tLZIb0/Hzrj 8P4I+qqhJiWOG7MchAD4F3fKCrEQXjNWXd2IT+5fK8cfzEAnMtK7ggDaQiatGjaB79236CsQk qgjgPM8UFgOachEzuHEu38xgoE6ko5cOKunD1zJ8JAdXWqmgYYghW4cRHmkZ0NhdkkwtcrcyX MGS/B9qwK7QKhjoiS4Ne38oxjNJJgWV04Nvn4V76UJXUWpy/D/UVc6V/ajxEIb6sI1Z8cge2C HzlBjDNr8kqcOi6v11n3CbJdI3+ePpPP0DreH3y/1WFx2meVyVaufuKWvRU1Etd/WYSsufNT7 KkdX9wUwD6yGduxKcrraKrYsVId6wxc9mELtNDFJzsjKgQN6ssZVdFdq8kHVMXMl199cQxh Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_GET_FEATURES - Getting feature flags Read feature flags for a btrfs filesystem. The feature flags are returned inside the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_feature_flags { __u64 compat_flags; __u64 compat_ro_flags; __u64 incompat_flags; }; All of the structure field represent bit masks that can be composed of values which can be found on: https://elixir.bootlin.com/linux/latest/source/fs/btrfs/ctree.h#L282 BTRFS_IOC_SET_FEATURES - Setting feature flags Set and clear feature flags for a btrfs filesystem. The feature flags are set using the ioctl's third argument which represents a 'struct btrfs_ioctl_feature_flags[2]' array. The first element of the array represent flags which are to be cleared and the second element of the array represent flags which are to be set. The second element has the priority over the first, which means that if there are matching flags in the elements, they will be set in the filesystem. If the flag values in the third argument aren't correctly set to be composed of the available predefined flag values, errno ENOPERM ("Operation not permitted") is returned. BTRFS_IOC_GET_SUPPORTED_FEATURES - Getting supported feature flags Read supported feature flags for a btrfs filesystem. The supported feature flags are read using the ioctl's third argument which represents a 'struct btrfs_ioctl_feature_flags[3]' array. The first element of this array represents all of the supported flags in the btrfs filesystem. The second element represents flags that can be safely set and third element represent flags that can be safely clearead. Implementation notes: All of the implemented ioctls use 'struct btrfs_ioctl_feature_flags' as third argument. That is the reason why a corresponding defintion was added in file 'linux-user/syscall_types.h'. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrangé Message-Id: <20200823195014.116226-5-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 12 ++++++++++++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 74d73994f691..11d7361848dd 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -216,6 +216,18 @@ IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) #endif +#ifdef BTRFS_IOC_GET_FEATURES + IOCTL(BTRFS_IOC_GET_FEATURES, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags))) +#endif +#ifdef BTRFS_IOC_SET_FEATURES + IOCTL(BTRFS_IOC_SET_FEATURES, IOC_W, + MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 2))) +#endif +#ifdef BTRFS_IOC_GET_SUPPORTED_FEATURES + IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R, + MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3))) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index d11279b78bbe..f70138979704 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1019,6 +1019,9 @@ struct target_rtc_pll_info { abi_ullong) #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 30) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 52) +#define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 57) +#define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MAGIC, 57) +#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 57) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MAGIC, 60) /* usb ioctls */ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 7e52b7aec5d9..eba0c43d4493 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -413,6 +413,11 @@ STRUCT(btrfs_ioctl_get_dev_stats, 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ #endif +STRUCT(btrfs_ioctl_feature_flags, + TYPE_ULONGLONG, /* compat_flags */ + TYPE_ULONGLONG, /* compat_ro_flags */ + TYPE_ULONGLONG) /* incompat_flags */ + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ From patchwork Mon Aug 31 11:07:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 275126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDE43C433E2 for ; Mon, 31 Aug 2020 11:12:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 933A92145D for ; Mon, 31 Aug 2020 11:12:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 933A92145D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChjU-00087j-PZ for qemu-devel@archiver.kernel.org; Mon, 31 Aug 2020 07:12:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChet-00075F-CE for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:31 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:47565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCheq-0000RN-ND for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:31 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MvaO8-1kTYFh3yOU-00sb29; Mon, 31 Aug 2020 13:07:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 5/8] linux-user: Add support for a group of btrfs inode ioctls Date: Mon, 31 Aug 2020 13:07:13 +0200 Message-Id: <20200831110716.536808-6-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:YahWqIzfLLaLcM1gKYs4gubZlC155B+nnqbrUDUZTHoUz9x+PUf GO8tHUtyd24HOwdJUflp5yFP3cYYlyJ2/g2QSCq6sIkM8Dcl+xq/aK1AgRX5wpaY5mHnwc+ isYut4voHXUo2YsVfh45DpviINVmLojRLx/3iKqSjoXWKuJwEV13/kaXAavgrV4SJUCK66X LawlX0AJE2Ow2T0l7lw4w== X-UI-Out-Filterresults: notjunk:1; V03:K0:yTiZlOj97aE=:JRfklhmXTNy+vxzF4PG4nb 78hjw0DD+dYqF/cokQSCB4z/ZdGOWywjfWZjnNA74VZyJUjxbZiSWWgIs3iPIcPx77dbr+n3+ cwgHpEd1TOuOaBRtFDrwFY2WyP+Oa6X/7qQeYLTWLYtGo7z5OH2oPq65mWaLjekeNAjquaDdk CyzYnx7ZF+WQflkwN1FY1fQ+YrgMJHExCyvFGPsEDBZisnqp74w0qSIYsnt0dlQm/uPvYNtyP 0PKDxkhDhHAI88agwiQkEyu3KDzMVAIdswKu9jHFn9Qqy1BtqkTxWssUfT8OJhbISS5C2IHVU HDNQkZ5bvy/0tl+BhceAb5r0kJx4z4LW68Rom78NdoSRO3F0c+xKVKs5HE/nPD0rL9+uCpra7 BKWKFxJXksNFr/3W6a28Iez2FMwF0oKtg0JmFNVto3SkXo7ReuJkvuhkVvekR7Xmf84a52nlm exSz4hadlesCBg8Sqov+SPLdRjDlBRqHY6VDKbkbQ2dpSE5+CznuUVx0QOi2bpv2eAAuz+EJR 8HalO1uvQ8aqqL7gyG5rUyQvozBVyWnTaXTZ7WnbP7onvYIvbdWDxxL81k6HoGBGZUYkiBnNh qu5i26KMHKcStg8bBrRyCk33wJxlhiuvfR/pvml2WfmzHH7cE8yxS56I42CslNeJHhSnJseMi bgF/ByrBS3SO5B0kuE/6vmq3bezLT8YayUPUyM/IU1TtXUK0Rk+fiW+f9z2brK67VvtKdjukT RgmiQePTStFa2Yrjdc93SrP80gXJQuuLjd1/Puz6GQGibcqbhWYwFsTXYo8uxJHmApJD8Lz46 FvZgM6NUSY/tWskUW8zvwMj8O/inuTNyegqjOwvSowvymzWkjeHUFG82GKqcCmYibJJ2bAS Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality of following ioctls: BTRFS_IOC_INO_LOOKUP - Reading tree root id and path Read tree root id and path for a given file or directory. The name and tree root id are returned in an ioctl's third argument that represents a pointer to a following type: struct btrfs_ioctl_ino_lookup_args { __u64 treeid; __u64 objectid; char name[BTRFS_INO_LOOKUP_PATH_MAX]; }; Before calling this ioctl, field 'objectid' should be filled with the object id value for which the tree id and path are to be read. Value 'BTRFS_FIRST_FREE_OBJECTID' represents the object id for the first available btrfs object (directory or file). BTRFS_IOC_INO_PATHS - Reading paths to all files Read path to all files with a certain inode number. The paths are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_ino_path_args { __u64 inum; /* in */ __u64 size; /* in */ __u64 reserved[4]; /* struct btrfs_data_container *fspath; out */ __u64 fspath; /* out */ }; Before calling this ioctl, the 'inum' and 'size' field should be filled with the aproppriate inode number and size of the directory where file paths should be looked for. For now, the paths are returned in an '__u64' (unsigned long long) value 'fspath'. BTRFS_IOC_LOGICAL_INO - Reading inode numbers Read inode numbers for files on a certain logical adress. The inode numbers are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_logical_ino_args { __u64 logical; /* in */ __u64 size; /* in */ __u64 reserved[3]; /* must be 0 for now */ __u64 flags; /* in, v2 only */ /* struct btrfs_data_container *inodes; out */ __u64 inodes; }; Before calling this ioctl, the 'logical' and 'size' field should be filled with the aproppriate logical adress and size of where the inode numbers of files should be looked for. For now, the inode numbers are returned in an '__u64' (unsigned long long) value 'inodes'. BTRFS_IOC_LOGICAL_INO_V2 - Reading inode numbers Same as the above mentioned ioctl except that it allows passing a flags 'BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET'. BTRFS_IOC_INO_LOOKUP_USER - Reading subvolume name and path Read name and path of a subvolume. The tree root id and path are read in an ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_ino_lookup_user_args { /* in, inode number containing the subvolume of 'subvolid' */ __u64 dirid; /* in */ __u64 treeid; /* out, name of the subvolume of 'treeid' */ 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]; }; Before calling this ioctl, the 'dirid' and 'treeid' field should be filled with aproppriate values which represent the inode number of the directory that contains the subvolume and treeid of the subvolume. Implementation notes: All of the ioctls in this patch use structure types as third arguments. That is the reason why aproppriate thunk definitions were added in file 'syscall_types.h'. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrangé Message-Id: <20200823195014.116226-6-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall_defs.h | 5 +++++ linux-user/syscall_types.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 11d7361848dd..23807513eed1 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -202,6 +202,10 @@ IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_INO_LOOKUP + IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) #endif @@ -212,6 +216,14 @@ IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args))) #endif +#ifdef BTRFS_IOC_INO_PATHS + IOCTL(BTRFS_IOC_INO_PATHS, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_path_args))) +#endif +#ifdef BTRFS_IOC_LOGICAL_INO + IOCTL(BTRFS_IOC_LOGICAL_INO, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) +#endif #ifdef BTRFS_IOC_GET_DEV_STATS IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) @@ -228,10 +240,18 @@ IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R, MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3))) #endif +#ifdef BTRFS_IOC_LOGICAL_INO_V2 + IOCTL(BTRFS_IOC_LOGICAL_INO_V2, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) #endif +#ifdef BTRFS_IOC_INO_LOOKUP_USER + IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args))) +#endif #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index f70138979704..4929121956c6 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1013,16 +1013,21 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_RM_DEV TARGET_IOWU(BTRFS_IOCTL_MAGIC, 11) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MAGIC, 14) #define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MAGIC, 15) +#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 18) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAGIC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, 26,\ abi_ullong) #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 30) +#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 35) +#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 36) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 52) #define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 57) #define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MAGIC, 57) #define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 57) +#define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 59) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MAGIC, 60) +#define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 62) /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index eba0c43d4493..dab2c16bcac7 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -393,6 +393,38 @@ STRUCT(btrfs_ioctl_get_subvol_info_args, MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ #endif +#ifdef BTRFS_IOC_INO_LOOKUP +STRUCT(btrfs_ioctl_ino_lookup_args, + TYPE_ULONGLONG, /* treeid */ + TYPE_ULONGLONG, /* objectid */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_PATH_MAX)) /* name */ +#endif + +#ifdef BTRFS_IOC_INO_PATHS +STRUCT(btrfs_ioctl_ino_path_args, + TYPE_ULONGLONG, /* inum */ + TYPE_ULONGLONG, /* size */ + MK_ARRAY(TYPE_ULONGLONG, 4), /* reserved */ + TYPE_ULONGLONG) /* fspath */ +#endif + +#if defined(BTRFS_IOC_LOGICAL_INO) || defined(BTRFS_IOC_LOGICAL_INO_V2) +STRUCT(btrfs_ioctl_logical_ino_args, + TYPE_ULONGLONG, /* logical */ + TYPE_ULONGLONG, /* size */ + MK_ARRAY(TYPE_ULONGLONG, 3), /* reserved */ + TYPE_ULONGLONG, /* flags */ + TYPE_ULONGLONG) /* inodes */ +#endif + +#ifdef BTRFS_IOC_INO_LOOKUP_USER +STRUCT(btrfs_ioctl_ino_lookup_user_args, + TYPE_ULONGLONG, /* dirid */ + TYPE_ULONGLONG, /* treeid */ + MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), /* name */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ +#endif + #ifdef BTRFS_IOC_DEV_INFO STRUCT(btrfs_ioctl_dev_info_args, TYPE_ULONGLONG, /* devid */