From patchwork Wed Sep 2 23:26:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1356228 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Bhg8V6ks1z9sTS for ; Thu, 3 Sep 2020 09:27:38 +1000 (AEST) Received: from localhost ([::1]:44502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDcAC-000439-Rj for incoming@patchwork.ozlabs.org; Wed, 02 Sep 2020 19:27:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDc9q-0003yC-Rz for qemu-devel@nongnu.org; Wed, 02 Sep 2020 19:27:14 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:43415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDc9n-0004rB-6h for qemu-devel@nongnu.org; Wed, 02 Sep 2020 19:27:14 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Macay-1kpgnI0ej4-00c9oQ; Thu, 03 Sep 2020 01:27:06 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 5/9] linux-user: Add support for btrfs ioctls used to get/set features Date: Thu, 3 Sep 2020 01:26:57 +0200 Message-Id: <20200902232701.13299-6-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200902232701.13299-1-laurent@vivier.eu> References: <20200902232701.13299-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:gG2r/H+rBXfZoOpQc5Jmx+QrUTVWoZ6p91ttUrw+Ri8Raw1AL/+ USGqtP7jI3MrFzri+1GMSpkRmUMKmUbXmvIw1iZh1VGzhuV4mkx3cXTIgCN9kUOkE6blBPo urTkUC7dF4Su+oPEefYzrtrUrgaELTzcx8k17ZKsRbePT5eBlMZPDux0qZBBIe3h0G8ESOV 8JiYY/yQecRviT6Sh1D8A== X-UI-Out-Filterresults: notjunk:1;V03:K0:OPXeMJHN4L0=:z6zH9ZDTB765fRkUMskNhK pTrC/wlekthK5ZfPYAw0BaJtSMvm4/RJPwFarJxO/ITfC2g5AVKmUVTaWZBqHwT1WCp0/ZmLU dLYuz/okB5BJNAV4iWklvxv8NoquJK6TBmew2lX2zrpiP57RbPusfbnXiqsV9Hrlz8uBZovl4 Inw3F9SZz+u2V0x9KPXMn0QwDShpbe1y89+XihWz9ovba8XyNtkYs7dFw6K2Bfs4I7JfoQ6Ob BKjCATeRSIQV8rPBjvSAowNc/KD7zfSn9d87SupJdF0nMcYG1vPjP7ujQxtaRNfy/SCtw0mR9 qujQhh46GOGM5C6PPmStALDfh5N8uJPpgyITJl4x4Cn273CR6+u2zu5LXAbQq+Wy06B2iNpoL b6alwuZ5ViGDFlvN8nrKqIftyGsvBTODN+FnjHGx5ClqoQ3X4i3ggN0GDxHxf0/KZykzpTLcT eB80L9FkAjKdvFUzYHfpCENtNXLpL/yfFStyKeYuyVG01ivuZ8j4i3Lhf4MoPDa3DEOErXHfy 31VABnh/wFMfBkUqOcfnWb+vSDKZHophhJFkdtDMEY0UOWvnVU7wv/smjoO4bhfcYIIepZA8B 3FIBBwNqVUg9dDSR/7SPhetlxplEHVWanGO8CdOVhUPv7jxIr3iHHuaKVQqqspCQtz4UODsXG 10RsgBbbCMSw0dRZrzfMi9GBfpfTIaEJLErvoKAMmjeKLSUUPI3gcsen/lraXCOWNrfC44Gkr Au9fuUlLhvWsT2BBuEUDQl7iXQQuGvJzih5zgpyXo9bgZOpnMGe/Mlq+5ObnVQm7XOBnRomo5 3mraw5W/gC5lhdj/sSC0b13eUHqDqrRY41s+aq6hc3/K0yiw/4Eqa6SS9/ouZpViRPCptVw Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/02 19:27:09 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+incoming=patchwork.ozlabs.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 */