dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0007-linux-user-Add-support-for-two-btrfs-ioctls-used-for.patch

Daniel P. Berrangé dc03f3
From 58252f756d7fb2a8516c0815034c0bded4697852 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:59 +0200
Daniel P. Berrangé dc03f3
Subject: [PATCH 7/9] linux-user: Add support for two btrfs ioctls used for
Daniel P. Berrangé dc03f3
 subvolume
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 ioctl:
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
BTRFS_IOC_DEFAULT_SUBVOL - Setting a default subvolume
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Set a default subvolume for a btrfs filesystem. The third
Daniel P. Berrangé dc03f3
    ioctl's argument is a '__u64' (unsigned long long) which
Daniel P. Berrangé dc03f3
    represents the id of a subvolume that is to be set as
Daniel P. Berrangé dc03f3
    the default.
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
BTRFS_IOC_GET_SUBVOL_ROOTREF - Getting tree and directory id of subvolumes
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Read tree and directory id of subvolumes from a btrfs
Daniel P. Berrangé dc03f3
    filesystem. The tree and directory id's are returned in the
Daniel P. Berrangé dc03f3
    ioctl's third argument which represents a pointer to a
Daniel P. Berrangé dc03f3
    following type:
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    struct btrfs_ioctl_get_subvol_rootref_args {
Daniel P. Berrangé dc03f3
		/* in/out, minimum id of rootref's treeid to be searched */
Daniel P. Berrangé dc03f3
		__u64 min_treeid;
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
		/* out */
Daniel P. Berrangé dc03f3
		struct {
Daniel P. Berrangé dc03f3
			__u64 treeid;
Daniel P. Berrangé dc03f3
			__u64 dirid;
Daniel P. Berrangé dc03f3
		} rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM];
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
		/* out, number of found items */
Daniel P. Berrangé dc03f3
		__u8 num_items;
Daniel P. Berrangé dc03f3
		__u8 align[7];
Daniel P. Berrangé dc03f3
     };
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
     Before calling this ioctl, 'min_treeid' field should be filled
Daniel P. Berrangé dc03f3
     with value that represent the minimum value for the tree id.
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
Implementation notes:
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Ioctl BTRFS_IOC_GET_SUBVOL_ROOTREF uses the above mentioned structure
Daniel P. Berrangé dc03f3
    type as third argument. That is the reason why a aproppriate thunk
Daniel P. Berrangé dc03f3
    structure definition is added in file '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-7-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        |  7 +++++++
Daniel P. Berrangé dc03f3
 linux-user/syscall_defs.h  |  3 +++
Daniel P. Berrangé dc03f3
 linux-user/syscall_types.h | 13 +++++++++++++
Daniel P. Berrangé dc03f3
 3 files changed, 23 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 169f98f7a3..728880b9f3 100644
Daniel P. Berrangé dc03f3
--- a/linux-user/ioctls.h
Daniel P. Berrangé dc03f3
+++ b/linux-user/ioctls.h
Daniel P. Berrangé dc03f3
@@ -206,6 +206,9 @@
Daniel P. Berrangé dc03f3
      IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW,
Daniel P. Berrangé dc03f3
            MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args)))
Daniel P. Berrangé dc03f3
 #endif
Daniel P. Berrangé dc03f3
+#ifdef BTRFS_IOC_DEFAULT_SUBVOL
Daniel P. Berrangé dc03f3
+     IOCTL(BTRFS_IOC_DEFAULT_SUBVOL, IOC_W, MK_PTR(TYPE_ULONGLONG))
Daniel P. Berrangé dc03f3
+#endif
Daniel P. Berrangé dc03f3
 #ifdef BTRFS_IOC_SUBVOL_GETFLAGS
Daniel P. Berrangé dc03f3
      IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG))
Daniel P. Berrangé dc03f3
 #endif
Daniel P. Berrangé dc03f3
@@ -248,6 +251,10 @@
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
 #endif
Daniel P. Berrangé dc03f3
+#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF
Daniel P. Berrangé dc03f3
+     IOCTL(BTRFS_IOC_GET_SUBVOL_ROOTREF, IOC_RW,
Daniel P. Berrangé dc03f3
+           MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_rootref_args)))
Daniel P. Berrangé dc03f3
+#endif
Daniel P. Berrangé dc03f3
 #ifdef BTRFS_IOC_INO_LOOKUP_USER
Daniel P. Berrangé dc03f3
      IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW,
Daniel P. Berrangé dc03f3
            MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args)))
Daniel P. Berrangé dc03f3
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
Daniel P. Berrangé dc03f3
index a6a9454b85..1d0bfb5479 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
@@ -976,6 +976,8 @@ struct target_rtc_pll_info {
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_SUBVOL_CREATE          TARGET_IOWU(BTRFS_IOCTL_MAGIC, 14)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_SNAP_DESTROY           TARGET_IOWU(BTRFS_IOCTL_MAGIC, 15)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_INO_LOOKUP             TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 18)
Daniel P. Berrangé dc03f3
+#define TARGET_BTRFS_IOC_DEFAULT_SUBVOL         TARGET_IOW(BTRFS_IOCTL_MAGIC, 19,\
Daniel P. Berrangé dc03f3
+                                                           abi_ullong)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS        TARGET_IOR(BTRFS_IOCTL_MAGIC, 25,\
Daniel P. Berrangé dc03f3
                                                            abi_ullong)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS        TARGET_IOW(BTRFS_IOCTL_MAGIC, 26,\
Daniel P. Berrangé dc03f3
@@ -989,6 +991,7 @@ struct target_rtc_pll_info {
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_LOGICAL_INO_V2         TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 59)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO        TARGET_IORU(BTRFS_IOCTL_MAGIC, 60)
Daniel P. Berrangé dc03f3
+#define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF     TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 61)
Daniel P. Berrangé dc03f3
 #define TARGET_BTRFS_IOC_INO_LOOKUP_USER        TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 62)
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 b84e14235f..5566d101c2 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
@@ -431,6 +431,19 @@ STRUCT(btrfs_ioctl_dev_info_args,
Daniel P. Berrangé dc03f3
        MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */
Daniel P. Berrangé dc03f3
 #endif
Daniel P. Berrangé dc03f3
 
Daniel P. Berrangé dc03f3
+#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF
Daniel P. Berrangé dc03f3
+STRUCT(rootref,
Daniel P. Berrangé dc03f3
+       TYPE_ULONGLONG, /* treeid */
Daniel P. Berrangé dc03f3
+       TYPE_ULONGLONG) /* dirid */
Daniel P. Berrangé dc03f3
+
Daniel P. Berrangé dc03f3
+STRUCT(btrfs_ioctl_get_subvol_rootref_args,
Daniel P. Berrangé dc03f3
+       TYPE_ULONGLONG, /* min_treeid */
Daniel P. Berrangé dc03f3
+       MK_ARRAY(MK_STRUCT(STRUCT_rootref),
Daniel P. Berrangé dc03f3
+                BTRFS_MAX_ROOTREF_BUFFER_NUM), /* rootref */
Daniel P. Berrangé dc03f3
+       TYPE_CHAR, /* num_items */
Daniel P. Berrangé dc03f3
+       MK_ARRAY(TYPE_CHAR, 7)) /* align */
Daniel P. Berrangé dc03f3
+#endif
Daniel P. Berrangé dc03f3
+
Daniel P. Berrangé dc03f3
 #ifdef BTRFS_IOC_GET_DEV_STATS
Daniel P. Berrangé dc03f3
 STRUCT(btrfs_ioctl_get_dev_stats,
Daniel P. Berrangé dc03f3
        TYPE_ULONGLONG, /* devid */
Daniel P. Berrangé dc03f3
-- 
Daniel P. Berrangé dc03f3
2.26.2
Daniel P. Berrangé dc03f3