Esempio n. 1
0
func (wo *WriteOperation) CompareAttribute(attributeName string, operator CompareAttribute, value io.Reader) *WriteOperation {
	name := C.CString(attributeName)
	defer freeString(name)
	bufAddr, bufLen := readerToBuf(value)
	C.rados_write_op_cmpxattr(wo.opContext, name, C.uint8_t(operator), bufAddr, C.size_t(bufLen))
	return wo
}
Esempio n. 2
0
func (ioctx *IOContext) WriteTaggedFull(oid string, tagName string, tag string, newTag string, data []byte) error {
	c_oid := C.CString(oid)
	c_tagName := C.CString(tagName)
	defer C.free(unsafe.Pointer(c_oid))
	defer C.free(unsafe.Pointer(c_tagName))

	b_tag := []byte(tag)
	b_newTag := []byte(newTag)

	op := C.rados_create_write_op()

	if tag == "" || tag == "0" {
		C.rados_write_op_create(
			op,
			LIBRADOS_CREATE_EXCLUSIVE,
			nil)
	} else {
		C.rados_write_op_cmpxattr(
			op,
			c_tagName,
			LIBRADOS_CMPXATTR_OP_EQ,
			(*C.char)(unsafe.Pointer(&b_tag[0])),
			(C.size_t)(len(b_tag)))
	}

	C.rados_write_op_write_full(
		op,
		(*C.char)(unsafe.Pointer(&data[0])),
		(C.size_t)(len(data)))

	C.rados_write_op_setxattr(
		op,
		c_tagName,
		(*C.char)(unsafe.Pointer(&b_newTag[0])),
		(C.size_t)(len(b_newTag)))

	ret := C.rados_write_op_operate(op, ioctx.ioctx, c_oid, nil, 0)

	C.rados_release_write_op(op)

	return GetRadosError(ret)
}