I'm trying to convert, or at least understand this ioctl
call:
#define NVME_URING_CMD_IO _IOWR('N', 0x80, struct nvme_uring_cmd)
Is there an equivalent of _IOWR
in golang? maybe with the unix
package?
Ok, I managed to convert it, thanks to help in comments:
const (
IocNrBits = 8
IocTypeBits = 8
IocSizeBits = 14
IocNrShift = 0
IocRead uintptr = 2
IocWrite uintptr = 2
)
const (
IocTypeShift = IocNrShift + IocNrBits
IocSizeShift = IocTypeShift + IocTypeBits
IocDirshift = IocSizeShift + IocSizeBits
)
func IOC(dir, t, nr, size uintptr) uintptr {
return (dir << IocDirshift) |
(t << IocTypeShift) |
(nr << IocNrShift) |
(size << IocSizeShift)
}
func IOWR(t, nr, size uintptr) uintptr {
return IOC(IocRead|IocWrite, t, nr, size)
}
func NVME_URING_CMD_IO() uintptr {
return IOWR('N', 0x80, 32)
}