Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
--- docker/daemon/graphdriver/btrfs/btrfs.go 2016-03-09 12:13:24.000000000 -0800
+++ docker/daemon/graphdriver/btrfs/btrfs.go 2016-04-17 04:34:27.188376720 -0700
@@ -7,6 +7,10 @@ package btrfs
#include <dirent.h>
#include <btrfs/ioctl.h>
#include <btrfs/ctree.h>
+
+static void set_name_btrfs_ioctl_vol_args_v2(struct btrfs_ioctl_vol_args_v2* btrfs_struct, const char* value) {
+ snprintf(btrfs_struct->name, BTRFS_SUBVOL_NAME_MAX, "%s", value);
+}
*/
import "C"
@@ -160,9 +164,10 @@ func subvolSnapshot(src, dest, name stri
var args C.struct_btrfs_ioctl_vol_args_v2
args.fd = C.__s64(getDirFd(srcDir))
- for i, c := range []byte(name) {
- args.name[i] = C.char(c)
- }
+
+ var cs = C.CString(name)
+ C.set_name_btrfs_ioctl_vol_args_v2(&args, cs)
+ C.free(unsafe.Pointer(cs))
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(destDir), C.BTRFS_IOC_SNAP_CREATE_V2,
uintptr(unsafe.Pointer(&args)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.