go-freebsd-libzfs
Go bindings for ZFS on FreeBSD through libzfs and libnvpair — pools, datasets, snapshots, clones, vdevs and properties, without zfs or zpool CLI calls.
Why
Idiomatic Go access to the OpenZFS stack on FreeBSD, with no zfs/zpool subprocesses and no output parsing.
How
- Links against
libzfsandlibnvpair; builds against the OpenZFS headers from the FreeBSD source tree. - A driver abstraction with two tracks: the working libzfs driver, and a pure
/dev/zfsioctl driver that’s planned. - C wrappers cover pool and dataset iteration (recursive, deduplicated), pool config, and the nvlist helpers needed to build property sets and vdev trees.
- A client API —
zfs.New(ctx),zpool.New(ctx)— where every call takes acontext.Context, properties are typed with source tracking, and errors carry operation, resource and errno.
Status
Send/receive, encryption key management, events and the cgo-free driver are future work.
client, err := zfs.New(ctx)
defer client.Close()
err = client.CreateSnapshot(ctx, "zroot/example@backup-1", false, nil)
props, err := client.GetProperties(ctx, "zroot/example", "used", "compression")
$ git clone https://github.com/zombocoder/go-freebsd-libzfs← all projects