// ssize_t rbd_write(rbd_image_t image, uint64_t ofs, size_t len, const char *buf); func (image *Image) Write(data []byte) (n int, err error) { ret := int(C.rbd_write(image.image, C.uint64_t(image.offset), C.size_t(len(data)), (*C.char)(unsafe.Pointer(&data[0])))) if ret >= 0 { image.offset += int64(ret) } if ret != len(data) { err = RBDError(-1) } return ret, err }
func (image *Image) WriteAt(data []byte, off int64) (n int, err error) { if image.image == nil { return 0, RbdErrorImageNotOpen } if len(data) == 0 { return 0, nil } ret := int(C.rbd_write(image.image, C.uint64_t(off), C.size_t(len(data)), (*C.char)(unsafe.Pointer(&data[0])))) if ret != len(data) { err = RBDError(-1) } return ret, err }