render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0005-linux-user-Add-support-for-btrfs-ioctls-used-to-get-.patch

Daniel P. Berrangé dc03f3
From 5793eb73d4d6d37293c6ca95ed85414fcccb9662 Mon Sep 17 00:00:00 2001
Daniel P. Berrangé dc03f3
From: Filip Bozuta <Filip.Bozuta@syrmia.com>
Daniel P. Berrangé dc03f3
Date: Thu, 3 Sep 2020 01:26:57 +0200
Daniel P. Berrangé dc03f3
Subject: [PATCH 5/9] linux-user: Add support for btrfs ioctls used to get/set
Daniel P. Berrangé dc03f3
 features
Daniel P. Berrangé dc03f3
MIME-Version: 1.0
Daniel P. Berrangé dc03f3
Content-Type: text/plain; charset=UTF-8
Daniel P. Berrangé dc03f3
Content-Transfer-Encoding: 8bit
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
This patch implements functionality for following ioctls:
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
BTRFS_IOC_GET_FEATURES - Getting feature flags
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Read feature flags for a btrfs filesystem. The feature flags
Daniel P. Berrangé dc03f3
    are returned inside the ioctl's third argument which represents
Daniel P. Berrangé dc03f3
    a pointer to a following structure type:
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    struct btrfs_ioctl_feature_flags {
Daniel P. Berrangé dc03f3
	__u64 compat_flags;
Daniel P. Berrangé dc03f3
	__u64 compat_ro_flags;
Daniel P. Berrangé dc03f3
	__u64 incompat_flags;
Daniel P. Berrangé dc03f3
    };
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    All of the structure field represent bit masks that can be composed
Daniel P. Berrangé dc03f3
    of values which can be found on:
Daniel P. Berrangé dc03f3
    https://elixir.bootlin.com/linux/latest/source/fs/btrfs/ctree.h#L282
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
BTRFS_IOC_SET_FEATURES - Setting feature flags
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Set and clear feature flags for a btrfs filesystem. The feature flags
Daniel P. Berrangé dc03f3
    are set using the ioctl's third argument which represents a
Daniel P. Berrangé dc03f3
    'struct btrfs_ioctl_feature_flags[2]' array. The first element of the
Daniel P. Berrangé dc03f3
    array represent flags which are to be cleared and the second element of
Daniel P. Berrangé dc03f3
    the array represent flags which are to be set. The second element has the
Daniel P. Berrangé dc03f3
    priority over the first, which means that if there are matching flags
Daniel P. Berrangé dc03f3
    in the elements, they will be set in the filesystem. If the flag values
Daniel P. Berrangé dc03f3
    in the third argument aren't correctly set to be composed of the available
Daniel P. Berrangé dc03f3
    predefined flag values, errno ENOPERM ("Operation not permitted") is returned.
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
BTRFS_IOC_GET_SUPPORTED_FEATURES - Getting supported feature flags
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Read supported feature flags for a btrfs filesystem. The supported
Daniel P. Berrangé dc03f3
    feature flags are read using the ioctl's third argument which represents
Daniel P. Berrangé dc03f3
    a 'struct btrfs_ioctl_feature_flags[3]' array. The first element of this
Daniel P. Berrangé dc03f3
    array represents all of the supported flags in the btrfs filesystem.
Daniel P. Berrangé dc03f3
    The second element represents flags that can be safely set and third element
Daniel P. Berrangé dc03f3
    represent flags that can be safely clearead.
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
Implementation notes:
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    All of the implemented ioctls use 'struct btrfs_ioctl_feature_flags' as
Daniel P. Berrangé dc03f3
    third argument. That is the reason why a corresponding defintion was added
Daniel P. Berrangé dc03f3
    in file 'linux-user/syscall_types.h'.
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Daniel P. Berrangé dc03f3
Tested-by: Daniel P. Berrangé <berrange@redhat.com>
Daniel P. Berrangé dc03f3
Message-Id: <20200823195014.116226-5-Filip.Bozuta@syrmia.com>
Daniel P. Berrangé dc03f3
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Daniel P. Berrangé dc03f3
---
Daniel P. Berrangé dc03f3
 linux-user/ioctls.h        | 12 ++++++++++++
Daniel P. Berrangé dc03f3
 linux-user/syscall_defs.h  |  3 +++
Daniel P. Berrangé dc03f3
 linux-user/syscall_types.h |  5 +++++
Daniel P. Berrangé dc03f3
 3 files changed, 20 insertions(+)
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
Daniel P. Berrangé dc03f3
index 55a6cbeca5..50fae1e33b 100644
Daniel P. Berrangé dc03f3
--- a/linux-user/ioctls.h
Daniel P. Berrangé dc03f3
+++ b/linux-user/ioctls.h
Daniel P. Berrangé dc03f3
@@ -216,6 +216,18 @@
Daniel P. Berrangé dc03f3
      IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW,
Daniel P. Berrangé dc03f3
            MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats)))
Daniel P. Berrangé dc03f3
 #endif
Daniel P. Berrangé dc03f3
+#ifdef BTRFS_IOC_GET_FEATURES
Daniel P. Berrangé dc03f3
+     IOCTL(BTRFS_IOC_GET_FEATURES, IOC_R,
Daniel P. Berrangé dc03f3
+           MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags)))
Daniel P. Berrangé dc03f3
+#endif
Daniel P. Berrangé dc03f3
+#ifdef BTRFS_IOC_SET_FEATURES
Daniel P. Berrangé dc03f3
+     IOCTL(BTRFS_IOC_SET_FEATURES, IOC_W,
Daniel P. Berrangé dc03f3
+           MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 2)))
Daniel P. Berrangé dc03f3
+#endif
Daniel P. Berrangé dc03f3
+#ifdef BTRFS_IOC_GET_SUPPORTED_FEATURES
Daniel P. Berrangé dc03f3
+     IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R,
Daniel P. Berrangé dc03f3
+           MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3)))
Daniel P. Berrangé dc03f3
+#endif
Daniel P. Berrangé dc03f3
 #ifdef BTRFS_IOC_GET_SUBVOL_INFO
Daniel P. Berrangé dc03f3
      IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R,
Daniel P. Berrangé dc03f3
            MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args)))
Daniel P. Berrangé dc03f3
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
Daniel P. Berrangé dc03f3
index 4c7bfa0391..44811fdcbb 100644
Daniel P. Berrangé dc03f3
--- a/linux-user/syscall_defs.h
Daniel P. Berrangé dc03f3
+++ b/linux-user/syscall_defs.h
Daniel P. Berrangé dc03f3
@@ -981,6 +981,9 @@ struct target_rtc_pll_info {
Daniel P. Berrangé dc03f3
                                                            abi_ullong)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_DEV_INFO               TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 30)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_GET_DEV_STATS          TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 52)
Daniel P. Berrangé dc03f3
+#define TARGET_BTRFS_IOC_GET_FEATURES           TARGET_IORU(BTRFS_IOCTL_MAGIC, 57)
Daniel P. Berrangé dc03f3
+#define TARGET_BTRFS_IOC_SET_FEATURES           TARGET_IOWU(BTRFS_IOCTL_MAGIC, 57)
Daniel P. Berrangé dc03f3
+#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 57)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO        TARGET_IORU(BTRFS_IOCTL_MAGIC, 60)
Daniel P. Berrangé dc03f3
 
Daniel P. Berrangé dc03f3
 /* usb ioctls */
Daniel P. Berrangé dc03f3
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
Daniel P. Berrangé dc03f3
index ea6898979b..925054cfd4 100644
Daniel P. Berrangé dc03f3
--- a/linux-user/syscall_types.h
Daniel P. Berrangé dc03f3
+++ b/linux-user/syscall_types.h
Daniel P. Berrangé dc03f3
@@ -409,6 +409,11 @@ STRUCT(btrfs_ioctl_get_dev_stats,
Daniel P. Berrangé dc03f3
                 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */
Daniel P. Berrangé dc03f3
 #endif
Daniel P. Berrangé dc03f3
 
Daniel P. Berrangé dc03f3
+STRUCT(btrfs_ioctl_feature_flags,
Daniel P. Berrangé dc03f3
+       TYPE_ULONGLONG, /* compat_flags */
Daniel P. Berrangé dc03f3
+       TYPE_ULONGLONG, /* compat_ro_flags */
Daniel P. Berrangé dc03f3
+       TYPE_ULONGLONG) /* incompat_flags */
Daniel P. Berrangé dc03f3
+
Daniel P. Berrangé dc03f3
 STRUCT(rtc_time,
Daniel P. Berrangé dc03f3
        TYPE_INT, /* tm_sec */
Daniel P. Berrangé dc03f3
        TYPE_INT, /* tm_min */
Daniel P. Berrangé dc03f3
-- 
Daniel P. Berrangé dc03f3
2.26.2
Daniel P. Berrangé dc03f3