From e94254d96a0b9f62c745551ab9d92ea0460dea5d Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Fri, 16 Dec 2016 09:36:45 +0100 Subject: [PATCH] *: fix compilation with btrfs-progs >= 4.5 Signed-off-by: Antonio Murdaca --- btrfs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/btrfs.go b/btrfs.go index 4a20c0d..20f7c33 100644 --- a/btrfs.go +++ b/btrfs.go @@ -13,6 +13,10 @@ import "sort" // Required because Go has struct casting rules for negative numbers const __u64 u64_BTRFS_LAST_FREE_OBJECTID = (__u64)BTRFS_LAST_FREE_OBJECTID; const __u64 negative_one = (__u64)-1; + +static char* get_name_btrfs_ioctl_vol_args_v2(struct btrfs_ioctl_vol_args_v2* btrfs_struct) { + return btrfs_struct->name; +} */ import "C" @@ -300,12 +304,13 @@ func SubvolSnapshot(dst, src string, readonly bool) error { // dstdir is the ioctl arg, wile srcdir gets set on the args var args C.struct_btrfs_ioctl_vol_args_v2 args.fd = C.__s64(srcfp.Fd()) + name := C.get_name_btrfs_ioctl_vol_args_v2(&args) if len(dstname) > C.BTRFS_SUBVOL_NAME_MAX { return errors.Errorf("%q too long for subvolume", dstname) } - nameptr := (*[1<<31 - 1]byte)(unsafe.Pointer(&args.name[0])) + nameptr := (*[1<<31 - 1]byte)(unsafe.Pointer(name)) copy(nameptr[:C.BTRFS_SUBVOL_NAME_MAX], []byte(dstname)) if readonly {