From nobody Sat May 4 01:12:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1594310197; cv=pass; d=zohomail.com; s=zohoarc; b=VGkacAVpGf9RCM8V9jO2ytbpTN6+3rPMtjJXkC+V0eRuiKUylwNNnZ7LaqDR7fLr4gtVMV74v+jOT3auMyxxj3vgYYFk6b8VOvLZ3xmHrQC0Zbf4emfhx+uWM8jrGCYvTisZlrrDtd0ifUz4G/PRQGA0alMx+Kjjaubx99gLFaU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594310197; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HPLAH/G9vgWPTku/SYzbQHovQwheNJ2U+WpCD4xjPRc=; b=A+/7XdR3jMtOBJK1LBd2gwyTHvqU42O0cJi0H6BLdrzij3PkiFwpKYmTrJvpqF13kREE5ydS5WbLY7wGrX7ikfuD65IusZ0V9XP+flDs3ijDF8QT53yqQvyfDLQGgBvcB/aLZ87JRh+lOtvsV37sjt4ZX0XmuREL4wXc2Y9cZBk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159431019744041.46252245356902; Thu, 9 Jul 2020 08:56:37 -0700 (PDT) Received: from localhost ([::1]:39520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtYua-0007LM-2g for importer@patchew.org; Thu, 09 Jul 2020 11:56:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtYr4-0002kU-S0 for qemu-devel@nongnu.org; Thu, 09 Jul 2020 11:52:58 -0400 Received: from mail-eopbgr40114.outbound.protection.outlook.com ([40.107.4.114]:3260 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtYr2-0006dz-Ux for qemu-devel@nongnu.org; Thu, 09 Jul 2020 11:52:58 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR0302MB3223.eurprd03.prod.outlook.com (2603:10a6:209:1d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Thu, 9 Jul 2020 15:52:21 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 15:52:21 +0000 Received: from localhost.localdomain (109.245.225.24) by AM3PR07CA0147.eurprd07.prod.outlook.com (2603:10a6:207:8::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.8 via Frontend Transport; Thu, 9 Jul 2020 15:52:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O++m3JLR4iVEhYz43pWNEtNK1WSdGxVZHsKi8kDr4Owlo2C5pkE+Y3Oh5sX4+b0cFr3L9mBayrlwEMv4g8NG5B1ZrrkHfJA+oFT66QrMERWwwm0N0bogigP7PJBiXLSQLYSFVv/0Cs18zy61+HPH62zrFlnnucUdqS5o226wk5yc15p8AoMg75gPJdbeftqJ/2eKnGBpWgBw6wNDPJBk2DRZ1P9bCG/F7xNxP5ZASn+FaoXnL9BpwRvzz0VSmUkHY/oH1HIFWdcHo/BF6lFuEvWYKwz3RDZBxYnz6wd6o98KgS5oWz9ng+k2pm6MRZuDNKGmzVETxRXHiqeANpGSfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HPLAH/G9vgWPTku/SYzbQHovQwheNJ2U+WpCD4xjPRc=; b=mZLC04FXvYsO3S0LAGdVklfPxwmmP+GgTnx9T5d1Erbra+Ae6s/qnsK+dlRe1q84lVBvVdriSUdhmCZ/LPclGYqgNlAVpwrgggFZhlBvXZwXpeBI9qtavrwkDn/9K4H9QVEhGXzTLI4sEMmic+JMoeKvWyz+eRaL/D8EG07gN4ywE3aEIiYB5KHexqfTtfr8ZE95Hrum281qdN4d7freTnybFcWiuePHu578IPObU2lHW1JeiIGhLUf7j85gNhf9M28kjKRg/WMzmuXHW4BKJl3F3C0LQGSUYKxTI5GtlyWRFR5OKkEB4LWMRGmQA+kKtYIbjxTUIJJItiuTye6I8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HPLAH/G9vgWPTku/SYzbQHovQwheNJ2U+WpCD4xjPRc=; b=iD49jeqp2QCb7opGMx10n6YASqnWXv2LQdqIlOdwsIvm7p7o/iMuqKBMy9F0lUrXnEaqvRiHz2oMvRUwJgejVtJHLA8VYbtpunjiTL+U2miOxmCc0Xf5jiQN9W82AyeE5dx4nk4zVJ8pcOlBjErsR4zay4zsF0RQZUbV1apQfDo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 1/4] linux-user: Add support for a group of btrfs ioctls used for subvolumes Date: Thu, 9 Jul 2020 17:52:00 +0200 Message-Id: <20200709155203.21106-2-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709155203.21106-1-Filip.Bozuta@syrmia.com> References: <20200709155203.21106-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM3PR07CA0147.eurprd07.prod.outlook.com (2603:10a6:207:8::33) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [109.245.225.24] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 947df85a-4bd5-4844-523d-08d8242010a8 X-MS-TrafficTypeDiagnostic: AM6PR0302MB3223: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 04599F3534 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OgCMJg9JFLintZH0/OolZPYTISyAD5euEpFFkY0rnsql/SmFSsYpmcSH00bOwf2wRuybGktmNLOXcAJwxhz+AW17XwFwew57qf3LRbLl8dlfqZhrI+4kIjdwe6mPuTfmdX1rlw6sGtUfwdWtS8tBTxudx1ptNfYGQN3W1y7dFbozAKMB3FQaTakgcWbqa5kYEKtFa/vtT7VNzs3yy+F/jWs3qJEJ716WSHdG130/ZSNWoS73GCVj40RR0IhsBfeJPa17gBaEF6Q7jpyVJjfgRvCx6I0qmDc4dXfdD4pZg0qJ1Jj+YzwY4LelsX3bNa6KJ8I/2igTEme0HnOXBassA5AAQkqEaQGvBuAE1ZSwQ6cg6CromDE7haBwIb+8XGSk X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(376002)(396003)(39830400003)(366004)(136003)(346002)(66946007)(66476007)(16526019)(186003)(66556008)(26005)(36756003)(52116002)(2616005)(956004)(6506007)(6916009)(107886003)(2906002)(6486002)(83380400001)(54906003)(6512007)(86362001)(1076003)(4326008)(8676002)(508600001)(5660300002)(316002)(6666004)(69590400007)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Q4MvKjJ6ImLlWxnWu3ZR8BjKw3VexPo0hOOAvlNymvpiVCuJu7AC89FRYQ+kFmgJFtfliOKI9SgJt+U46P23lJUzUpKGxZZinXVPmkblYxNI/x9Z4RC6S55lCkRdTAqJVNodOFcfYEDAWO0w9ni60DGDUXyAKRk/GWE01CH5NQCNZHKwcmec6e+2Nz6rP0IJ4Ky3QxLpSQCwvA3opZuHroYK+1GwRao9LweUHpZTicLrkhr2apXlk7wElzOyXdQFum9qvf9MMsKM0XcIaGH/rBwjYDJkrgS3cE2y1yp910tdPVVRCAoN+u51t+k298264gaTaTUodeCouQHNgDvBj48tXXpa6EH7aQ82GsmHxSuf/b33+5zDquXzrx4S7gUYd7BZTURsECOFD2qGhXjgyIKBLKyeLln0hwFtz05fvAoH4foOjl9NmNoDoSkwqEUOtdgkwLKkEoeCDNaTB54w7po71mLY8a26/LJ43KuahrY= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 947df85a-4bd5-4844-523d-08d8242010a8 X-MS-Exchange-CrossTenant-AuthSource: AM6PR03MB5233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 15:52:21.2413 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: klwWcg6BeuvrCy3GXseCYFyTStdOPcTqL5IMbPRWhbI0fIjowTzZoD6QW+q3KCbTyHTWCf1bjxBwzWBBIUn+wQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0302MB3223 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.4.114; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/09 11:52:55 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=no 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: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Type: text/plain; charset="utf-8" This patch implements functionality of following ioctls: BTRFS_IOC_SUBVOL_CREATE - Creating a btrfs subvolume Create a btrfs subvolume. The subvolume is created using the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_vol_args { __s64 fd; char name[BTRFS_PATH_NAME_MAX + 1]; }; Before calling this ioctl, the fields of this structure should be filled with aproppriate values. The fd field represents the file descriptor value of the subvolume and the name field represents the subvolume path. BTRFS_IOC_SUBVOL_GETFLAGS - Getting subvolume flags Read the flags of the btrfs subvolume. The flags are read using the ioctl's third argument that is a pointer of __u64 (unsigned long). The third argument represents a bit mask that can be composed of follow= ing values: BTRFS_SUBVOL_RDONLY (1ULL << 1) BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2) BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3) BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4) BTRFS_IOC_SUBVOL_SETFLAGS - Setting subvolume flags Set the flags of the btrfs subvolume. The flags are set using the ioctl's third argument that is a pointer of __u64 (unsigned long). The third argument represents a bit mask that can be composed of same values as in the case of previous ioctl (BTRFS_IOC_SUBVOL_GETFLAGS). BTRFS_IOC_SUBVOL_GETINFO - Getting subvolume information Read information about the subvolume. The subvolume information is returned in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_get_subvol_info_args { /* Id of this subvolume */ __u64 treeid; /* 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 a deleted subvolume. */ __u64 parent_id; /* * Inode number of the directory which contains this subvolume. * Zero for top-level subvolume or a 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 a non-snapshot subvolume. */ __u8 parent_uuid[BTRFS_UUID_SIZE]; /* * UUID of the subvolume from which this subvolume was received. * All zero for non-received subvolume. */ __u8 received_uuid[BTRFS_UUID_SIZE]; /* Transaction id indicating when change/create/send/receive happened */ __u64 ctransid; __u64 otransid; __u64 stransid; __u64 rtransid; /* Time corresponding 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; /* Must be zero */ __u64 reserved[8]; }; All of the fields of this structure are filled after the ioctl call. Implementation notes: Ioctls BTRFS_IOC_SUBVOL_CREATE and BTRFS_IOC_SUBVOL_GETINFO have struct= ure types as third arguments. That is the reason why a corresponding defini= tion are added in file 'linux-user/syscall_types.h'. The line '#include ' is added in file 'linux-user/syscal= l.c' to recognise preprocessor definitions for these ioctls. Since the file "li= nux/btrfs.h" was added in the kernel version 3.9, it is enwrapped in an #ifdef state= ment with parameter CONFIG_BTRFS which is defined in 'configure' if the header file is present. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- configure | 9 +++++++++ linux-user/ioctls.h | 15 +++++++++++++++ linux-user/syscall.c | 3 +++ linux-user/syscall_defs.h | 10 ++++++++++ linux-user/syscall_types.h | 28 ++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+) diff --git a/configure b/configure index b969dee675..8b3b214031 100755 --- a/configure +++ b/configure @@ -4945,6 +4945,12 @@ if check_include sys/kcov.h ; then kcov=3Dyes fi =20 +# check for btrfs filesystem support (kernel must be 3.9+) +btrfs=3Dno +if check_include linux/btrfs.h ; then + btrfs=3Dyes +fi + # If we're making warnings fatal, apply this to Sphinx runs as well sphinx_werror=3D"" if test "$werror" =3D "yes"; then @@ -7057,6 +7063,9 @@ fi if test "$kcov" =3D "yes" ; then echo "CONFIG_KCOV=3Dy" >> $config_host_mak fi +if test "$btrfs" =3D "yes" ; then + echo "CONFIG_BTRFS=3Dy" >> $config_host_mak +fi if test "$inotify" =3D "yes" ; then echo "CONFIG_INOTIFY=3Dy" >> $config_host_mak fi diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 0defa1d8c1..544184ff95 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -174,6 +174,21 @@ IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) =20 +#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_SUBVOL_GETFLAGS + IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) +#endif +#ifdef BTRFS_IOC_SUBVOL_SETFLAGS + IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG)) +#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 CONFIG_USBFS /* USB ioctls */ IOCTL(USBDEVFS_CONTROL, IOC_RW, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 05f03919ff..4a65b28999 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -112,6 +112,9 @@ #include #include #include +#ifdef CONFIG_BTRFS +#include +#endif #include "linux_loop.h" #include "uname.h" =20 diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 152ec637cb..c11bcc6ba9 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -967,6 +967,16 @@ struct target_rtc_pll_info { #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int) #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) =20 +/* btrfs ioctls */ +#define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 14, struct btrfs_ioctl_vol_= args) +#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, \ + 25, abi_ullong) +#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 26, abi_ullong) +#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IOR(BTRFS_IOCTL_MAG= IC, \ + 60, struct btrfs_ioctl_get_subvol_info_= args) + /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 4e12c1661e..75ce6482ea 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -321,6 +321,34 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */ MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ =20 +STRUCT(btrfs_ioctl_vol_args, + TYPE_LONGLONG, /* fd */ + MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */ + +STRUCT(btrfs_ioctl_timespec, + TYPE_ULONGLONG, /* sec */ + TYPE_INT) /* nsec */ + +STRUCT(btrfs_ioctl_get_subvol_info_args, + TYPE_ULONGLONG, /* treeid */ + MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), + TYPE_ULONGLONG, /* parentid */ + TYPE_ULONGLONG, /* dirid */ + TYPE_ULONGLONG, /* generation */ + TYPE_ULONGLONG, /* flags */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* parent_uuid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* received_uuid */ + TYPE_ULONGLONG, /* ctransid */ + TYPE_ULONGLONG, /* otransid */ + TYPE_ULONGLONG, /* stransid */ + TYPE_ULONGLONG, /* rtransid */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* ctime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* otime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* stime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* rtime */ + MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ --=20 2.25.1 From nobody Sat May 4 01:12:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1594310034; cv=pass; d=zohomail.com; s=zohoarc; b=EunQcmHwAyFvpG9EcSbDNcJebFrm9yojq7Wwgtv87lvX1Ylz2Gjallxk0g3WldLIRKghR1gvO8hhTkXhPLkE0XV5jqOnBRg3UK2NOGOdEombjHI0hKOfrJX3FM5yfJBXq3B0KEm01Vn0vLTy79QDQP6PUfplLbU+84iNnpu/hoo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594310034; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Sb94QBlIVCBKjgw/zGthkYgnaVjsH6UnNivcR6gcdCo=; b=Wgk954owiqmaSfyq4J1RuSNRYfnKl6BVllW14oGGjJCqLkZdFgmx6ouZrkKeybn/pD/uhHhEQiO643YJU+44r43zUD3AYdnROOVT7YahDQtyY+ZnsGZ11t57XwGVB3hZ+iDsHv0Vw0wXqgog4yyJFMjipDBjISom4Nj3fI072gE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594310033882232.99237051814202; Thu, 9 Jul 2020 08:53:53 -0700 (PDT) Received: from localhost ([::1]:59580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtYrw-0003hq-Nj for importer@patchew.org; Thu, 09 Jul 2020 11:53:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtYqa-0001e2-1e for qemu-devel@nongnu.org; Thu, 09 Jul 2020 11:52:28 -0400 Received: from mail-eopbgr70095.outbound.protection.outlook.com ([40.107.7.95]:49322 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtYqY-0006aw-5h for qemu-devel@nongnu.org; Thu, 09 Jul 2020 11:52:27 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM7PR03MB6675.eurprd03.prod.outlook.com (2603:10a6:20b:1b9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Thu, 9 Jul 2020 15:52:22 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 15:52:22 +0000 Received: from localhost.localdomain (109.245.225.24) by AM3PR07CA0147.eurprd07.prod.outlook.com (2603:10a6:207:8::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.8 via Frontend Transport; Thu, 9 Jul 2020 15:52:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i48qROxDvrl6MBf842Gc0viLqky3jODukBOYiOfnZzGMEJQfLVu8z0V6yQ3Dyz5GCvi7bkWvcqBqi9vO2JYY9ZppJxUR1KgnxChg5/49vsnqrAODK2kUmVXHmgkg1JNHqJ0lPRMR9p0nhNJ18GPkOWx8vNbqk2SCn8ryGZuegwaPxsl2bWSbS0K4atlHWu29tZULlB3Fguht52NA5My9/u1+wIOrKd5pC/fwERxdTlcO84zKVI87oULSMQxNcIuAzNHrEJJUr+jECmJNLsZbReDLhawHiQUpKU/cm84ZYed8RFfst/+c+CtEMw+QwqU3UmN10PCJ9uf5Kkzkm10uRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Sb94QBlIVCBKjgw/zGthkYgnaVjsH6UnNivcR6gcdCo=; b=InmiJA92saqzsM7TRysWYfXmVCFAXyyz0LGkADXADY8ahzMnLsjAIkjGLDHBWcpYMVNZhcO/usRtsF1Kv/TUn/vVq2e5tmnP0V553TaIcdssV1lYbi4YdfZX72/o6CBlHtdC3kJ+FZOJU/FDMmGrtiHBhKbQzDQUgx+nj+W8FDK5y1YtfY8E69IMtl4omDfHkoXniQ/9dmrrQIPAteL2xvhm9dKrXK7jmCAp2H1DHvNgwp7WTduBk8AbFDM2qOyVoi8Ab3rT6KT0UuvN4kr6u1rVi5CaLlSvgOhVYfAaOQpt/yrT37JCgDY/UC7D6Ox1lpocRrTUbNblowembW0CXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Sb94QBlIVCBKjgw/zGthkYgnaVjsH6UnNivcR6gcdCo=; b=sWiDEFe4wTYvxAkMFG990q8jXRq5kxaW9yn9jrws943AHBrserltRqtYcJHl0b++cvmTHjN7LovmGoCatq3c1MQ/2Q6AwQoHoizFav24qH7Y3zgY4XnKz3Z6VY3J6DklNbWz3eQ5pHrmrm+kpGCCVUIl/VIRtrAJ3ZVIf9pyRe8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 2/4] linux-user: Add support for a group of btrfs ioctls used for snapshots Date: Thu, 9 Jul 2020 17:52:01 +0200 Message-Id: <20200709155203.21106-3-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709155203.21106-1-Filip.Bozuta@syrmia.com> References: <20200709155203.21106-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM3PR07CA0147.eurprd07.prod.outlook.com (2603:10a6:207:8::33) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [109.245.225.24] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c2f654af-679c-4d96-7839-08d82420113d X-MS-TrafficTypeDiagnostic: AM7PR03MB6675: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XXXtM5zLOvDk9AGckLehke5+kpZ/NKC0EW6gD7erllc2Z5eSNE6ZTlT5bNa/GsLOre3utj9iTTjD95qGJh7y3+x6O3ltW3MaTr2HhfmF2KP8wS2GNznMXcrM7WekubVYqoYaVvFT9XRYRVPmtUint280JZifGXfrS2H94ySXhHHx8quIg9rU6bF7dYe2+2dAp7Wdk7Xi3On5sUcqBSNK10iegS4+E3v/WrTLahfw5mo7/RyppqdKcb1BJVmF7wDJ5GQgG+XhstBbHbeEzlWF47tejwJFVLdfeQHOzA1pEAdIPhlloAeVZy35juVTxHudEBFC+FmfZCZ15Pd0aZJLwnmbdiS0IxdKSNhgEOEV6/bEhJtuCPvbrl2qg+uWDHuW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(346002)(39830400003)(376002)(396003)(136003)(366004)(66476007)(2906002)(107886003)(956004)(2616005)(52116002)(6666004)(6512007)(4326008)(6486002)(5660300002)(26005)(66556008)(16526019)(66946007)(186003)(1076003)(6506007)(36756003)(6916009)(54906003)(83380400001)(86362001)(69590400007)(316002)(8936002)(8676002)(508600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: H+q9poCZRKiDV2dXWN6vcS1mP9G2f/jf7oKiVpll4VgtlS+G5r80LV1jB+iDRl+5zQEJM72bpV8vYZUQ4YI1ggXLgi3r3UvAuZ7mjSKzxuzaVObgzKOkfYCS6cBtdeaqcJuVOND+7jfpV+/4wbPZ3WZSnLl+j3hHHnErzl3VzyDyGGhRSEqxg0t/GflgrZsENzNXist84eM4BYBLERFc86OPQ0R08UttnT+/9yvFCLFVo02zGnbGzMDI4TBMtPK9NL4Bryb69++ll6ZattlMpLj9k+SoduJD0H4/V00qV0jWreU6Sd6imrNOf2Sot/V2XMA0Nseo8di79aynAr0BrCwjQOTsbnXPVWkjdSGjIEJxScRB/D1mCG1IbNwEM1fln4W6vR7/lcbPMzs22rxvH8I7NoGCNPRThyW8Jk0Oty/Bn9xwq45BbYyIIrWEJjrs+SkxY2wGaFLVf7kP27OzW4JaW3cFz76832sSEK9Wiz4= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2f654af-679c-4d96-7839-08d82420113d X-MS-Exchange-CrossTenant-AuthSource: AM6PR03MB5233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 15:52:22.1728 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LQwVSWIAP7R6RRqLRfFxH4rLxJoAUo08DwWpoZFrOUllSJmFDZCheMGihRwH6nbe8AUSLvGQACOZGzawHI9VYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR03MB6675 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.7.95; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/09 11:52:23 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=no 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: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Type: text/plain; charset="utf-8" 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 t= he ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_a= rgs' (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 t= he ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_a= rgs' (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 Reviewed-by: Laurent Vivier --- linux-user/ioctls.h | 8 ++++++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 544184ff95..2422675dd0 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)) =20 +#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 c11bcc6ba9..21d8909fd6 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -968,8 +968,12 @@ struct target_rtc_pll_info { #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) =20 /* btrfs ioctls */ +#define TARGET_BTRFS_IOC_SNAP_CREATE TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 1, struct btrfs_ioctl_vol_= args) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ 14, struct btrfs_ioctl_vol_= args) +#define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 15, struct btrfs_ioctl_vol_= args) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, \ 25, abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ --=20 2.25.1 From nobody Sat May 4 01:12:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1594310194; cv=pass; d=zohomail.com; s=zohoarc; b=DWr3J4cEDNaSL8Va10mi9HtBDhF1Vrlc+aCLYO6dqiEhuCtw+fj7drCOBroFNxeU7LxJau45nkAsaaZtmlr+RUklhn9LYvYTN4Gd3FOaQpjqcMA8W87hRhIsTHPYkZ4q3BdwgYZQYycqybYAcd4ws0n+OSZJea4ZxntGc2N0bpM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594310194; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RDKvmzteHQyUIXqkz82nv0D6pYmUcMzBdwDTo+H1uOI=; b=T3Z50DflU/GTHOIoBMdSuhhmUEm/XEXOQFvLLMV1ZPwWJVezJYwuQGhXnqlZ8Gg05TERYcO7WvMABQsCoBmfiGFT6qExKUWW/Fz5omib38VxM4zQffMZfKnSzkTf3+3kWEzngw6HKcqUJh8y2kWEPSkaYx95RL5inIfsaFwpTv0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594310194345279.8746354877874; Thu, 9 Jul 2020 08:56:34 -0700 (PDT) Received: from localhost ([::1]:39274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtYuX-0007Ey-1U for importer@patchew.org; Thu, 09 Jul 2020 11:56:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtYr6-0002o9-QY for qemu-devel@nongnu.org; Thu, 09 Jul 2020 11:53:00 -0400 Received: from mail-eopbgr40114.outbound.protection.outlook.com ([40.107.4.114]:3260 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtYr5-0006dz-2L for qemu-devel@nongnu.org; Thu, 09 Jul 2020 11:53:00 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR0302MB3223.eurprd03.prod.outlook.com (2603:10a6:209:1d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Thu, 9 Jul 2020 15:52:23 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 15:52:23 +0000 Received: from localhost.localdomain (109.245.225.24) by AM3PR07CA0147.eurprd07.prod.outlook.com (2603:10a6:207:8::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.8 via Frontend Transport; Thu, 9 Jul 2020 15:52:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AA/wxuB2c/nOgDccEBU+vXPMNTSdrh9a5xbC0L5J/hcl2OX/k7FpXKYMIJyylNiw6upnFKVWRVS7gwkKcuuTAowFBl56dEmSRNmU1TujGXMKfeTMNIa6aF11nw3sUFkmtqsJ8wq3ogp/ZPIJ+eactr3HgkxWcZk2dYN1VtreZv+O+5/zVXcKWqTbi51lMMSdZI1Aj0JuwmPMQ5dNfgmYbLqhTUCprpjl/DKqpgYxQOhE3pmWz381usl0rHuIKumUGPhaMjvnNQhLXVgX7jXgTin0KRvltTmyzTVQaVkpaEj7PXa81+PjOzlC2UeWFBja7OjrIH+iy4p+suQTOliTvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RDKvmzteHQyUIXqkz82nv0D6pYmUcMzBdwDTo+H1uOI=; b=ni/4LhiilSLtTusqQQkIPh2fKFr2IfnyazLt0+gywLbawJOlG74fuHCUCMsy+llQIdl2LTKadD1TjJLImXvqKpwZC/xLLfulBFd3Q2sqbHyeSC+Dy0OwXpfzHW4C2XYW1aBB3k8ftrRsHwyRRSm5bFVbTkNfD37kZc9gNyMDFGKiJWpCBSNqfh9EsLjeb93GbhckL/LQrxW3wqgVVKiAOrjVUwyN0wS7Jf1I0izVxegxcbU76/Tga3FhWMwM4IHOzeuXl3QsXko9rkBt1243HZHcnA+FMSeJjMJdoTW5NApSThLWptlyAdwlNJndv0hFh1SnIBZteEt5pMX5E36DpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RDKvmzteHQyUIXqkz82nv0D6pYmUcMzBdwDTo+H1uOI=; b=T0+g6dP9kddUi4Hdz34XCP/q/qUjXmMpz7FOWbr3oYlPBvGwACPkVMoE0jIXHC4SZxSKLoed9Ax2DAMC2eY01yei46k6ka88njHrWccWLeEyjKA0wrKXqOYshp4XQHGfCZJxODOdYzai7eOB+9t+mtPvDOyyCbXPGqa1w01w6do= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 3/4] linux-user: Add support for a group of btrfs ioctls used to manipulate with devices Date: Thu, 9 Jul 2020 17:52:02 +0200 Message-Id: <20200709155203.21106-4-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709155203.21106-1-Filip.Bozuta@syrmia.com> References: <20200709155203.21106-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM3PR07CA0147.eurprd07.prod.outlook.com (2603:10a6:207:8::33) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [109.245.225.24] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa2e9029-acc8-4dc2-953d-08d8242011d6 X-MS-TrafficTypeDiagnostic: AM6PR0302MB3223: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 04599F3534 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G/bNX9HlKMa72twjRlxkfx+gU4gya77ftb/iRGUiIafzxCZUMWVfDK+zevkydyau1eGC6GybkOZKhPIqJjEqmGF2sEzWIaaQ144MutTN8VZy2peE1qPM6H7UWGQU+MUFPYLAgPmq1wi3Mzzb3Ddm5/xENJ9M6fqdslwtCTWskQTTbe2/XaHVDSrHBxSAWh179G1TkQntGzdPxZ26EJJdJk9fye8CZ5ZL6foT64/ez1cGXf2gTWoYrPvx53UAN23TizK8lef/JyIQ4VSo7r46scG+MjXVbOfD0h8QwzHyF2OVVUxDwGvHpo6y3Esj3BPj69DOR+ilwrr2h2YqenwrBpmBWy4xyqq1kypfGANbxS52/5c9QH9D2WcTMpHKbjoa X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(376002)(396003)(39830400003)(366004)(136003)(346002)(66946007)(66476007)(16526019)(186003)(66556008)(26005)(36756003)(52116002)(2616005)(956004)(6506007)(6916009)(107886003)(2906002)(6486002)(54906003)(6512007)(86362001)(1076003)(4326008)(8676002)(508600001)(5660300002)(316002)(6666004)(69590400007)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: rcztZtNIDB/7odL/15gY1KoOs0a+fmBHHQE0aXlYx4+BV8tp9es/yQp3/a4vE4kDZHsjzaqDnj/fF7l2cKWFDS5slXHkAWslQuqVHwB3jlUj1yOYJnvkJcsYj5wVlTwfnH+ZDhIxk3qbME7iNKOUEANyKf8neJW23hCMA7XaNj/U0AD7/dXcOgRLEgS/r13t51rxuIf/sYifzTe2hOn9Ou+OAi3QNOQW18Q2zeBCl8wSp46NOyaI5+BWn/QjzvSUseu9IT4wiI35xTEnOzKzRdEh9Ztdo2yLYP5/tMKnUsQKHTbB1F43Fl0NPlk9fsReY3H/EIviLEKcjlv8S9pCVYlgQU5JziRRVLqN4aK/h9PhdHvnpPwX7p85xQOWqD1TFG1q45WANRywn6GpZgNZC429L4cdmx6Cfayas/kanHRn04a9nfO5tEqJvK1HYP6tsJju/SqRgMI/m7zQFBJCF4E3WQJWxgQ5Wz2WZS7WnzI= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa2e9029-acc8-4dc2-953d-08d8242011d6 X-MS-Exchange-CrossTenant-AuthSource: AM6PR03MB5233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 15:52:23.1962 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M9VhSN7oNkoOTlMJY5w6IO+eqHa6M89m1cXs08EvlfB7u6z5zJafIg7nb6EM34KUQjg1ZCq8WcST9sV4FnKzqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0302MB3223 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.4.114; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/09 11:52:55 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=no 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: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Type: text/plain; charset="utf-8" This patch implements functionality for following ioctls: BTRFS_IOC_SCAN_DEV - Scanning device for a btrfs filesystem Scan a device for a btrfs filesystem. The device that is to be scanned is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. If the device contains a btrfs filesystem, the ioctl returns 0, otherwise a negative value is returned. BTRFS_IOC_ADD_DEV - Adding a device to a btrfs filesystem Add a device to a btrfs filesystem. The device that is to be added is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. BTRFS_IOC_RM_DEV - Removing a device from a btrfs filesystem Remove a device from a btrfs filesystem. The device that is to be removed is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. BTRFS_IOC_DEV_INFO - Getting information about a device Obtain information for device in a btrfs filesystem. The information is gathered in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_dev_info_args { __u64 devid; /* in/out */ __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */ __u64 bytes_used; /* out */ __u64 total_bytes; /* out */ __u64 unused[379]; /* pad to 4k */ __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ }; Before calling this ioctl, field "devid" should be set with the id value for the device for which the information is to be obtained. If this fie= ld is not aproppriately set, the errno ENODEV ("No such device") is return= ed. BTRFS_IOC_GET_DEV_STATS - Getting device statistics Obtain stats informatin for device in a btrfs filesystem. The informati= on is gathered in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_get_dev_stats { __u64 devid; /* in */ __u64 nr_items; /* in/out */ __u64 flags; /* in/out */ /* out values: */ __u64 values[BTRFS_DEV_STAT_VALUES_MAX]; /* * This pads the struct to 1032 bytes. It was originally meant to pad to * 1024 bytes, but when adding the flags field, the padding calculation * was not adjusted. */ __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; }; Before calling this ioctl, field "devid" should be set with the id value for the device for which the information is to be obtained. If this fie= ld is not aproppriately set, the errno ENODEV ("No such device") is return= ed. BTRFS_IOC_FORGET_DEV - Remove unmounted devices Search and remove all stale devices (devices which are not mounted). The third ioctl argument is a pointer to a 'struct btrfs_ioctl_vol_args= '. The ioctl call will release all unmounted devices which match the path which is specified in the "name" field of the structure. If an empty path ("") is specified, all unmounted devices will be released. Implementation notes: Ioctls BTRFS_IOC_DEV_INFO and BTRFS_IOC_GET_DEV_STATS use types 'struct btrfs_ioctl_dev_info_args' and ' struct btrfs_ioctl_get_dev_sta= ts' as third argument types. That is the reason why corresponding structure definitions were added in file 'linux-user/syscall_types.h'. Since the thunk type for 'struct ioc_vol_args' was already added in a previous patch, the rest of the implementation was straightforward. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/ioctls.h | 24 ++++++++++++++++++++++++ linux-user/syscall_defs.h | 12 ++++++++++++ linux-user/syscall_types.h | 16 ++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 2422675dd0..c20bd97736 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -178,6 +178,22 @@ IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_SCAN_DEV + IOCTL(BTRFS_IOC_SCAN_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_FORGET_DEV + IOCTL(BTRFS_IOC_FORGET_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_ADD_DEV + IOCTL(BTRFS_IOC_ADD_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_RM_DEV + IOCTL(BTRFS_IOC_RM_DEV, 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))) @@ -192,6 +208,14 @@ #ifdef BTRFS_IOC_SUBVOL_SETFLAGS IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG)) #endif +#ifdef BTRFS_IOC_DEV_INFO + IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_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))) +#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 21d8909fd6..20c03cd145 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -970,6 +970,14 @@ struct target_rtc_pll_info { /* btrfs ioctls */ #define TARGET_BTRFS_IOC_SNAP_CREATE TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ 1, struct btrfs_ioctl_vol_= args) +#define TARGET_BTRFS_IOC_SCAN_DEV TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 4, struct btrfs_ioctl_vol_= args) +#define TARGET_BTRFS_IOC_FORGET_DEV TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 5, struct btrfs_ioctl_vol_= args) +#define TARGET_BTRFS_IOC_ADD_DEV TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 10, struct btrfs_ioctl_vol_= args) +#define TARGET_BTRFS_IOC_RM_DEV TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 11, struct btrfs_ioctl_vol_= args) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ 14, struct btrfs_ioctl_vol_= args) #define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ @@ -978,6 +986,10 @@ struct target_rtc_pll_info { 25, abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ 26, abi_ullong) +#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWR(BTRFS_IOCTL_MA= GIC,\ + 30, struct btrfs_ioctl_dev_info_= args) +#define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWR(BTRFS_IOCTL_MA= GIC,\ + 52, struct btrfs_ioctl_get_dev_s= tats) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IOR(BTRFS_IOCTL_MAG= IC, \ 60, struct btrfs_ioctl_get_subvol_info_= args) =20 diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 75ce6482ea..b5718231e5 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -349,6 +349,22 @@ STRUCT(btrfs_ioctl_get_subvol_info_args, MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* rtime */ MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ =20 +STRUCT(btrfs_ioctl_dev_info_args, + TYPE_ULONGLONG, /* devid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */ + TYPE_ULONGLONG, /* bytes_used */ + TYPE_ULONGLONG, /* total_bytes */ + MK_ARRAY(TYPE_ULONGLONG, 379), /* unused */ + MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */ + +STRUCT(btrfs_ioctl_get_dev_stats, + TYPE_ULONGLONG, /* devid */ + TYPE_ULONGLONG, /* nr_items */ + TYPE_ULONGLONG, /* flags */ + MK_ARRAY(TYPE_ULONGLONG, BTRFS_DEV_STAT_VALUES_MAX), /* values */ + MK_ARRAY(TYPE_ULONGLONG, + 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ --=20 2.25.1 From nobody Sat May 4 01:12:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1594310121; cv=pass; d=zohomail.com; s=zohoarc; b=TUeGxEdFH+d6JvmuDHzF0UF9UqF07b2fGyd3y39oZLLQsVZPUrRJQxMHlJHvnM7qIHMmPKmk5OWdOCTF4w5fi8S8yYt9j+oDvNvGHxBIZBwgK+HA8W4AbGMy+93fX5OiM4o9NbLyXLHZuC8gZ2ItMPaDC9ZJqahu99JNc2Q1LOk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594310121; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jfoaKSfdP+I+cOvQUxQemrNNZOo1EGm2i7J7QyBhX+8=; b=TSJ4Lx9SqiyLL+c6WNvYGKRyDJ+K8ZG5iOCe6Cq9F6u8jAC65BUVzxOAc1eIWX/fB2Qswkm8q9zaB+SANvP0BZxZ6t5/6UNvyUTnGr1HvITxz13M7a5vvGHXgZQdwkMMGj1g5xy7PG7JyBzsTlq7d3zlkw2HDFxczGOtX6n3DKk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594310121219854.1154432855292; Thu, 9 Jul 2020 08:55:21 -0700 (PDT) Received: from localhost ([::1]:35146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtYtL-0005NL-Tk for importer@patchew.org; Thu, 09 Jul 2020 11:55:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtYr9-0002tZ-29 for qemu-devel@nongnu.org; Thu, 09 Jul 2020 11:53:03 -0400 Received: from mail-eopbgr40114.outbound.protection.outlook.com ([40.107.4.114]:3260 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtYr7-0006dz-1A for qemu-devel@nongnu.org; Thu, 09 Jul 2020 11:53:02 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR0302MB3223.eurprd03.prod.outlook.com (2603:10a6:209:1d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Thu, 9 Jul 2020 15:52:24 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 15:52:24 +0000 Received: from localhost.localdomain (109.245.225.24) by AM3PR07CA0147.eurprd07.prod.outlook.com (2603:10a6:207:8::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.8 via Frontend Transport; Thu, 9 Jul 2020 15:52:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a+LDxif9TsHQJ7ygeMRteY4vJtAZ9rFNIwPVAFYSUP5zwGk8bnDlmvjpdl+pGnjbc+pgWtxYOmcgD6/Add8ntYQ+wrrxxLdHOk88YEtQzOVKkYiCWwQQ9DSuFZ9cvVVro+/E/e45g6oLpwJretq04MU1uHFkszLypRgwWjlgTafrFibbQcXHikFEgwSiTZUs1T9JB+LX1xeNChrVaeOvgBwE5KWFwuXdAbhcZnQHzdhrp6QqDkl9/bT1Q0zpgcWFBA0Z7Xg+RV9+85KmkKJ0gibe7dGa+ui1Jyg7/FlJDiQr7NH9NLUjxWFE/NgVlBG3Yu4dF02iRA0X6AH9+rO3mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jfoaKSfdP+I+cOvQUxQemrNNZOo1EGm2i7J7QyBhX+8=; b=LeXhZ8vm4zJDCEPPM55U20xgCVjwqCWBaPP/5ADkkJblGqxTKGUTkGAYoPVuqoI05y4+XvNIL9f06nuH7021HfHaZLTfzqEHYk7P94UU/njrbJjsDsVRxnq1yLEfiTO3QWzjXPm4GXgzHM14DawHPkkHUn9eu4l7jqoPTJCUqgFqpDYL6hMKRJIumW+Nby6iqeVUjp0KKuv2FcHhtJcnhcreBRC+lzWGE8Ng23NIw+u2FG0arHkVkFq6akUOfXSUIuCyztRMuYNJ0m8/FkAEQ4YEoWWx02g0q0mP9e1CPwEaTDbyKUB+AATZMvFI6hxq6hEJ04LPYSFFS5UV1zxhOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jfoaKSfdP+I+cOvQUxQemrNNZOo1EGm2i7J7QyBhX+8=; b=GVjTUsTeTp+INGWVrnNu7VwyZLppt8CJnYXPKZ9dToKe6VJ20n5zLtX/ytnXZqeWas6BlWpjW9A/jV6Y3vxWIxXuABFBetU6jtg09N2slhWgfgYHjR4IxfDaxvfcw3+bkyXEpkf3zVbetGgiIRxO7MKoz1DmftjdQIrmvyr8uXw= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 4/4] linux-user: Add support for a group of btrfs ioctls used to get/set features Date: Thu, 9 Jul 2020 17:52:03 +0200 Message-Id: <20200709155203.21106-5-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709155203.21106-1-Filip.Bozuta@syrmia.com> References: <20200709155203.21106-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM3PR07CA0147.eurprd07.prod.outlook.com (2603:10a6:207:8::33) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [109.245.225.24] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3ddf253-1b00-4645-24ad-08d824201257 X-MS-TrafficTypeDiagnostic: AM6PR0302MB3223: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 04599F3534 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jpSXjQcM3vUBuAI8VnrP2jYePfpsXikC1zKff52tPOhFuhmTSs4sHLtkvUlY3g5zL7t1nudizyV9JKTWwHC+01OhOBpxOOnxRIQEvbC6As9IiYJ0sWbWuz9CNaOB5PHf1I4U7RxllktJkU3Pdm56hqgz3+laYBIGArx+q2R83tFu4ZalO0A8GNavJgvs+2CZt+pQVyEniP3zWWp0Tp2NvybFWmyL1l0SwhyfoMkSC3kWcVbIw5m+sHjkAk/fETbWZ0RgzanC1tApP4BEKSGcf2DBxUBH4BBYPWel1yeUrc5u9HDnljyLUEICNLGiTLEJDbhZVqCLL4NZjpgkzEe0icIX2S0zBd60SBrjOjyVmAptYTC18P5oFoqqYn8Ld4CNQCAzMLeyGY6fsRwyOgqG7IV/w96KiI/lhiipXZNnr3ylt1i28P7ZxgezAfHpumz2OUSyS5z5FVVD+9hmIB7U6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(376002)(396003)(39830400003)(366004)(136003)(346002)(66946007)(66476007)(16526019)(186003)(66556008)(26005)(36756003)(52116002)(2616005)(966005)(956004)(6506007)(6916009)(107886003)(2906002)(6486002)(54906003)(6512007)(86362001)(1076003)(4326008)(8676002)(508600001)(5660300002)(316002)(6666004)(69590400007)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mqmMjRXDFmMs/KPhZg1oPgcEHHghr63qXIfmoKBM+Iqwnf0Pi2c6vu6cKcp0HQfg3Fkq2vZUjlwXtMON0AGQFFZZlOIwt/34E6VP0qMlOjzvM+9YTGQJk/78uxh3PlVYE4kEPgkim3mrvPX27xqeGmy4d5RJvi92Z8B8HKwkQMKzd9TJm6gLLuIU3We3xBCwZ4ajDE1xvl145NC9Cxsg3YN+o6R5RZ9Lk+4D65OcFk2B0epgyiXU5g7Ai/jHERYTllpUZXdjm+wZbEPKXbF9C8Qq3Hi0zIrdTFtJOGxtNq1L02u6VOEprqIs+9/3VbYAFSYhok9tRthsJPV3QdghSTglnesRJGx0aGDQOmdkpxY7HPd5oOQp5OQAgP4deKXSvInHCEj0iC5XNQxYfz7cXRmwPOAq93v+8fPY0o4QtQvLqNoblyin/RYta8lIY7BGdcHB4o6zMOWAG7jQeMDiEWrs4TA03YMJ//uIRdt0uOs= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3ddf253-1b00-4645-24ad-08d824201257 X-MS-Exchange-CrossTenant-AuthSource: AM6PR03MB5233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 15:52:23.9908 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b4aiMQiFo1ZJf9h28YYEt1jPRI7qT5DqgK34j8DAOL2zKBfH0qzKXf1n5M0LxHkVIV50kEsvTAwXazSrSZpF3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0302MB3223 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.4.114; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/09 11:52:55 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=no 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: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Type: text/plain; charset="utf-8" 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 t= he 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 availa= ble predefined flag values, errno ENOPERM ("Operation not permitted") is re= turned. 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 el= ement 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 ad= ded in file 'linux-user/syscall_types.h'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/ioctls.h | 12 ++++++++++++ linux-user/syscall_defs.h | 6 ++++++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index c20bd97736..c6303a0406 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 20c03cd145..9db6f46cba 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -990,6 +990,12 @@ struct target_rtc_pll_info { 30, struct btrfs_ioctl_dev_info_= args) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWR(BTRFS_IOCTL_MA= GIC,\ 52, struct btrfs_ioctl_get_dev_s= tats) +#define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IOR(BTRFS_IOCTL_MAG= IC, \ + 57, struct btrfs_ioctl_feature_fl= ags) +#define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOW(BTRFS_IOCTL_MAG= IC, \ + 57, struct btrfs_ioctl_feature_flag= s[2]) +#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IOR(BTRFS_IOCTL_MAG= IC, \ + 57, struct btrfs_ioctl_feature_flag= s[3]) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IOR(BTRFS_IOCTL_MAG= IC, \ 60, struct btrfs_ioctl_get_subvol_info_= args) =20 diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index b5718231e5..e26ab01e8f 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -365,6 +365,11 @@ STRUCT(btrfs_ioctl_get_dev_stats, MK_ARRAY(TYPE_ULONGLONG, 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ =20 +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 */ --=20 2.25.1