dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0003-linux-user-Add-support-for-a-group-of-btrfs-ioctls-u.patch

Daniel P. Berrangé dc03f3
From 40fdd783ec707e61c285e081816bd2df54dfede4 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:55 +0200
Daniel P. Berrangé dc03f3
Subject: [PATCH 3/9] linux-user: Add support for a group of btrfs ioctls used
Daniel P. Berrangé dc03f3
 for snapshots
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_SNAP_CREATE - Creating a subvolume snapshot
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Create a snapshot of a btrfs subvolume. The snapshot is created using the
Daniel P. Berrangé dc03f3
    ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_args'
Daniel P. Berrangé dc03f3
    (which was mentioned in the previous patch). Before calling this ioctl,
Daniel P. Berrangé dc03f3
    the fields of the structure should be filled with aproppriate values for
Daniel P. Berrangé dc03f3
    the file descriptor and path of the subvolume for which the snapshot is to
Daniel P. Berrangé dc03f3
    be created.
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
BTRFS_IOC_SNAP_DESTROY - Removing a subvolume snapshot
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Delete a snapshot of a btrfs subvolume. The snapshot is deleted using the
Daniel P. Berrangé dc03f3
    ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_args'
Daniel P. Berrangé dc03f3
    (which was mentioned in the previous patch). Before calling this ioctl,
Daniel P. Berrangé dc03f3
    the fields of the structure should be filled with aproppriate values for
Daniel P. Berrangé dc03f3
    the file descriptor and path of the subvolume for which the snapshot is to
Daniel P. Berrangé dc03f3
    be deleted.
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
Implementation notes:
Daniel P. Berrangé dc03f3
Daniel P. Berrangé dc03f3
    Since the thunk type 'struct btrfs_ioctl_vol_args' is defined in the
Daniel P. Berrangé dc03f3
    previous patch, the implementation for these ioctls was straightforward.
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-3-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        | 8 ++++++++
Daniel P. Berrangé dc03f3
 linux-user/syscall_defs.h  | 2 ++
Daniel P. Berrangé dc03f3
 linux-user/syscall_types.h | 3 ++-
Daniel P. Berrangé dc03f3
 3 files changed, 12 insertions(+), 1 deletion(-)
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 12d1444224..f33a99f8b6 100644
Daniel P. Berrangé dc03f3
--- a/linux-user/ioctls.h
Daniel P. Berrangé dc03f3
+++ b/linux-user/ioctls.h
Daniel P. Berrangé dc03f3
@@ -174,10 +174,18 @@
Daniel P. Berrangé dc03f3
      IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT))
Daniel P. Berrangé dc03f3
      IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
Daniel P. Berrangé dc03f3
 
Daniel P. Berrangé dc03f3
+#ifdef BTRFS_IOC_SNAP_CREATE
Daniel P. Berrangé dc03f3
+     IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W,
Daniel P. Berrangé dc03f3
+           MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
Daniel P. Berrangé dc03f3
+#endif
Daniel P. Berrangé dc03f3
 #ifdef BTRFS_IOC_SUBVOL_CREATE
Daniel P. Berrangé dc03f3
      IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W,
Daniel P. Berrangé dc03f3
            MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
Daniel P. Berrangé dc03f3
 #endif
Daniel P. Berrangé dc03f3
+#ifdef BTRFS_IOC_SNAP_DESTROY
Daniel P. Berrangé dc03f3
+     IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W,
Daniel P. Berrangé dc03f3
+           MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
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
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
Daniel P. Berrangé dc03f3
index 2757956dfa..a945e12547 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
@@ -968,7 +968,9 @@ struct target_rtc_pll_info {
Daniel P. Berrangé dc03f3
 #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
Daniel P. Berrangé dc03f3
 
Daniel P. Berrangé dc03f3
 /* btrfs ioctls */
Daniel P. Berrangé dc03f3
+#define TARGET_BTRFS_IOC_SNAP_CREATE            TARGET_IOWU(BTRFS_IOCTL_MAGIC, 1)
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_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
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
Daniel P. Berrangé dc03f3
index db61dbc1b3..038cd7869b 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
@@ -354,7 +354,8 @@ STRUCT(blkpg_partition,
Daniel P. Berrangé dc03f3
        MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */
Daniel P. Berrangé dc03f3
        MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */
Daniel P. Berrangé dc03f3
 
Daniel P. Berrangé dc03f3
-#ifdef BTRFS_IOC_SUBVOL_CREATE
Daniel P. Berrangé dc03f3
+#if defined(BTRFS_IOC_SUBVOL_CREATE) || defined(BTRFS_IOC_SNAP_CREATE) || \
Daniel P. Berrangé dc03f3
+    defined(BTRFS_IOC_SNAP_DESTROY)
Daniel P. Berrangé dc03f3
 STRUCT(btrfs_ioctl_vol_args,
Daniel P. Berrangé dc03f3
        TYPE_LONGLONG, /* fd */
Daniel P. Berrangé dc03f3
        MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */
Daniel P. Berrangé dc03f3
-- 
Daniel P. Berrangé dc03f3
2.26.2
Daniel P. Berrangé dc03f3