Skip to content

Commit

Permalink
Merge pull request #1 from runcom/fix-btrfs-progs-include
Browse files Browse the repository at this point in the history
*: fix compilation with btrfs-progs >= 4.5
  • Loading branch information
stevvooe authored Dec 16, 2016
2 parents 2ce0160 + e94254d commit a548767
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a548767

Please # to comment.