Skip to content

Commit

Permalink
Merge pull request #27 from fuweid/fix-checkptr-issue
Browse files Browse the repository at this point in the history
fix: checkptr issue
  • Loading branch information
dmcgowan authored Nov 11, 2020
2 parents 1539353 + d44cb8e commit 48eb88e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: go

go:
- "1.13.x"
- "1.15.x"

before_install:
- sudo apt-get update
Expand Down
6 changes: 3 additions & 3 deletions btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func SubvolCreate(path string) error {
if len(name) > C.BTRFS_PATH_NAME_MAX {
return errors.Errorf("%q too long for subvolume", name)
}
nameptr := (*[maxByteSliceSize]byte)(unsafe.Pointer(&args.name[0]))
nameptr := (*[maxByteSliceSize]byte)(unsafe.Pointer(&args.name[0]))[:C.BTRFS_PATH_NAME_MAX:C.BTRFS_PATH_NAME_MAX]
copy(nameptr[:C.BTRFS_PATH_NAME_MAX], []byte(name))

if err := ioctl(fp.Fd(), C.BTRFS_IOC_SUBVOL_CREATE, uintptr(unsafe.Pointer(&args))); err != nil {
Expand Down Expand Up @@ -311,7 +311,7 @@ func SubvolSnapshot(dst, src string, readonly bool) error {
return errors.Errorf("%q too long for subvolume", dstname)
}

nameptr := (*[maxByteSliceSize]byte)(unsafe.Pointer(name))
nameptr := (*[maxByteSliceSize]byte)(unsafe.Pointer(name))[:C.BTRFS_SUBVOL_NAME_MAX:C.BTRFS_SUBVOL_NAME_MAX]
copy(nameptr[:C.BTRFS_SUBVOL_NAME_MAX], []byte(dstname))

if readonly {
Expand Down Expand Up @@ -370,7 +370,7 @@ func SubvolDelete(path string) error {
return errors.Errorf("%q too long for subvolume", name)
}

nameptr := (*[maxByteSliceSize]byte)(unsafe.Pointer(&args.name[0]))
nameptr := (*[maxByteSliceSize]byte)(unsafe.Pointer(&args.name[0]))[:C.BTRFS_SUBVOL_NAME_MAX:C.BTRFS_SUBVOL_NAME_MAX]
copy(nameptr[:C.BTRFS_SUBVOL_NAME_MAX], []byte(name))

if err := ioctl(fp.Fd(), C.BTRFS_IOC_SNAP_DESTROY, uintptr(unsafe.Pointer(&args))); err != nil {
Expand Down

0 comments on commit 48eb88e

Please sign in to comment.