go-fsctl

Pure-Go Linux kernel-ioctl control โ€” no cgo, no shelling out.

CGO_ENABLED=0 no CLI dependency direct kernel ioctls 100% test coverage 6-arch CI BSD-3-Clause
Documentation GitHub

go-fsctl is a family of independent, dependency-free Go modules that drive Linux storage subsystems straight through their kernel ioctl interfaces โ€” loop devices, device-mapper, btrfs and OpenZFS. No losetup, dmsetup, btrfs(8) or libzfs; no C toolchain, no subprocess parsing โ€” just the kernel and Go.

Straight to the kernel

Every module talks to the kernel the same way the reference CLIs do โ€” by opening a control device and issuing the subsystem's ioctls directly. No shelling out, no scraping human-readable output, no cgo wrapper around a C library.

// loop: attach a backing file via /dev/loop-control + LOOP_* ioctls
dev, err := loop.Attach(ctx, "disk.img", loop.Options{ReadOnly: false})
if err != nil {
	return err
}
defer dev.Detach()
fmt.Println(dev.Path()) // e.g. /dev/loop7

Repositories

One module per kernel subsystem. Each is pure Go with CGO_ENABLED=0, 100% test coverage and green CI across all six 64-bit architectures.

loop lib

Loop devices via /dev/loop-control and LOOP_* ioctls โ€” attach, detach, query status and resize backing files. No losetup, no cgo.

CI

dm lib

Device-mapper via /dev/mapper/control and DM_* ioctls โ€” linear, striped, crypt, thin and verity targets with scrub-style status. No dmsetup.

CI

btrfs lib

btrfs via BTRFS_IOC_* ioctls on directory fds โ€” subvolumes, snapshots, scrub, balance, qgroups and send. No btrfs(8).

CI

zfs lib

OpenZFS via /dev/zfs and ZFS_IOC_* ioctls โ€” pools, datasets, encryption, send/recv and clone. No libzfs, no cgo.

CI

cowclone lib

Copy-on-write file cloning via APFS clonefile(2) and Linux FICLONE reflink (btrfs, XFS, OpenZFS 2.2+), with a transparent byte-copy fallback everywhere else. No cgo.

CI

Every module is pure Go with CGO_ENABLED=0 and drives the kernel directly through ioctls โ€” no losetup, dmsetup, btrfs(8) or libzfs, and no subprocess output to parse. Each repo holds at 100% test coverage and builds green on amd64, arm64, riscv64, loong64, ppc64le and s390x. BSD-3-Clause throughout.