From: Roberto Campesato <render@metalabs.org>
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -154,6 +154,10 @@
IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
#endif
+#ifdef BTRFS_IOC_SNAP_CREATE_V2
+ IOCTL(BTRFS_IOC_SNAP_CREATE_V2, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args_v2)))
+#endif
#ifdef BTRFS_IOC_SCAN_DEV
IOCTL(BTRFS_IOC_SCAN_DEV, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
@@ -170,14 +174,26 @@
IOCTL(BTRFS_IOC_RM_DEV, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
#endif
+#ifdef BTRFS_IOC_RM_DEV_V2
+ IOCTL(BTRFS_IOC_RM_DEV_V2, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args_v2)))
+#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_SUBVOL_CREATE_V2
+ IOCTL(BTRFS_IOC_SUBVOL_CREATE_V2, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args_v2)))
+#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_SNAP_DESTROY_V2
+ IOCTL(BTRFS_IOC_SNAP_DESTROY_V2, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args_v2)))
+#endif
#ifdef BTRFS_IOC_INO_LOOKUP
IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args)))
@@ -273,6 +289,10 @@
IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args)))
#endif
+#ifdef BTRFS_IOC_TREE_SEARCH
+ IOCTL(BTRFS_IOC_TREE_SEARCH, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_search_args)))
+#endif
#ifdef CONFIG_USBFS
/* USB ioctls */
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -966,9 +966,12 @@
#define TARGET_BTRFS_IOC_RM_DEV TARGET_IOWU(BTRFS_IOCTL_MAGIC, 11)
#define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MAGIC, 14)
#define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MAGIC, 15)
+#define TARGET_BTRFS_IOC_TREE_SEARCH TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 17)
#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 18)
#define TARGET_BTRFS_IOC_DEFAULT_SUBVOL TARGET_IOW(BTRFS_IOCTL_MAGIC, 19, \
abi_ullong)
+#define TARGET_BTRFS_IOC_SNAP_CREATE_V2 TARGET_IOWU(BTRFS_IOCTL_MAGIC, 23)
+#define TARGET_BTRFS_IOC_SUBVOL_CREATE_V2 TARGET_IOWU(BTRFS_IOCTL_MAGIC, 24)
#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAGIC, 25, \
abi_ullong)
#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, 26, \
@@ -990,10 +993,12 @@
#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_RM_DEV_V2 TARGET_IOWU(BTRFS_IOCTL_MAGIC, 58)
#define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 59)
#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MAGIC, 60)
#define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 61)
#define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 62)
+#define TARGET_BTRFS_IOC_SNAP_DESTROY_V2 TARGET_IOWU(BTRFS_IOCTL_MAGIC, 63)
#endif
/* usb ioctls */
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -373,6 +373,37 @@
MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */
#endif
+#if defined(BTRFS_IOC_SNAP_CREATE_V2) || \
+ defined(BTRFS_IOC_SUBVOL_CREATE_V2) || \
+ defined(BTRFS_IOC_RM_DEV_V2) || defined(BTRFS_IOC_SNAP_DESTROY_V2)
+STRUCT(btrfs_ioctl_vol_args_v2,
+ TYPE_LONGLONG, /* fd */
+ TYPE_ULONGLONG, /* transid */
+ TYPE_ULONGLONG, /* flags */
+ MK_ARRAY(TYPE_ULONGLONG, 4), /* unused */
+ MK_ARRAY(TYPE_CHAR, BTRFS_SUBVOL_NAME_MAX + 1)) /* name */
+#endif
+
+#ifdef BTRFS_IOC_TREE_SEARCH
+STRUCT(btrfs_ioctl_search_args,
+ TYPE_ULONGLONG, /* tree_id */
+ TYPE_ULONGLONG, /* min_objectid */
+ TYPE_ULONGLONG, /* max_objectid */
+ TYPE_ULONGLONG, /* min_offset */
+ TYPE_ULONGLONG, /* max_offset */
+ TYPE_ULONGLONG, /* min_transid */
+ TYPE_ULONGLONG, /* max_transid */
+ TYPE_INT, /* min_type */
+ TYPE_INT, /* max_type */
+ TYPE_INT, /* nr_items */
+ TYPE_INT, /* unused */
+ TYPE_ULONGLONG, /* unused1 */
+ TYPE_ULONGLONG, /* unused2 */
+ TYPE_ULONGLONG, /* unused3 */
+ TYPE_ULONGLONG, /* unused4 */
+ MK_ARRAY(TYPE_CHAR, BTRFS_SEARCH_ARGS_BUFSIZE)) /* buf */
+#endif
+
#ifdef BTRFS_IOC_GET_SUBVOL_INFO
STRUCT(btrfs_ioctl_timespec,
TYPE_ULONGLONG, /* sec */