Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

*: fix compilation with btrfs-progs >= 4.5 #1

Merged
merged 1 commit into from
Dec 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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