@@ -5079,6 +5079,12 @@ if check_include sys/kcov.h ; then
kcov=yes
fi
+# check for btrfs filesystem support (kernel must be 3.9+)
+btrfs=no
+if check_include linux/btrfs.h ; then
+ btrfs=yes
+fi
+
# If we're making warnings fatal, apply this to Sphinx runs as well
sphinx_werror=""
if test "$werror" = "yes"; then
@@ -7330,6 +7336,9 @@ fi
if test "$kcov" = "yes" ; then
echo "CONFIG_KCOV=y" >> $config_host_mak
fi
+if test "$btrfs" = "yes" ; then
+ echo "CONFIG_BTRFS=y" >> $config_host_mak
+fi
if test "$inotify" = "yes" ; then
echo "CONFIG_INOTIFY=y" >> $config_host_mak
fi
@@ -174,6 +174,21 @@
IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT))
IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
+#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,
@@ -115,6 +115,9 @@
#ifdef HAVE_DRM_H
#include <libdrm/drm.h>
#endif
+#ifdef CONFIG_BTRFS
+#include <linux/btrfs.h>
+#endif
#include "linux_loop.h"
#include "uname.h"
@@ -972,6 +972,14 @@ 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)
+/* btrfs ioctls */
+#define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MAGIC, 14)
+#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,\
+ abi_ullong)
+#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MAGIC, 60)
+
/* usb ioctls */
#define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
#define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
@@ -354,6 +354,34 @@ STRUCT(blkpg_partition,
MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */
MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */
+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 */