The LIBRADOS_OP_FLAG_* constants can be passed to rbd_writesame() and
other operations that will be added in the future.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
For more consisistency use getError where possible.
Changes produced using `gofmt -r 'RadosError(int(x)) -> getError(x)`,
followed by a few manual fixups.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Moving the errutil pkg to "internal/errutil" makes errutil private-like
and accessible to only other go-ceph packages. The functions it provided
were always meant to be used only by go-ceph, this just makes it more
official. This is a breaking change but it was only available to
outside users for 1 release and it is somewhat doubtful users outside
of go-ceph would have reached for these functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
RadosError-prefixes are not recommended, instead just Err as prefix is
used.
Also, errors are constants, not variables.
For existing users, backwards compatible constants are available. These
will need to be removed in a future go-ceph release.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
There is no good reason why the internal error handling support should
be exposed outside the rados package. Make the function lower-cased and
thus private.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Release resources that are allocated while configuring the connection to
the cluster. rados_shutdown() should only be needed after a successful
call to rados_connect(), however if the connection has been configured
with non-default parameters, some of the parameters may be allocated
before connecting. rados_shutdown() will free the allocated resources,
even if there has not been a connection yet.
Note that the finalizers get executed during garbage collection, which
can be forced by calling runtime.GC() for testing.
Fixes: #109
Signed-off-by: Niels de Vos <ndevos@redhat.com>
I got a "rados: ret=-22" message as part of call I made. I'm a bit rusty with my
C stderror codes, which made the error a bit unhelpful.
This commit makes this particular error come out as "rados: invalid argument",
even if we don't need to explicitly create a Rados error variable for invalid
argument case. It does so by using C.strerror().
A further change is that with this, we do not need to explicitly code
RadosErrorNotFound and RadosErrorPermissionsDenied using a different error type
thank RadosError.
In Go, the "C" package is a special type of package that creates local symbols
names (non exportable) to the importing package. The result, in the case of
rados.GetRadosError() is that trying to use results in:
cannot use cerr (type C.int) as type rados.C.int in argument to rados.GetRadosError
It seems that "C.int" within 'rados' namespace produces a symbol of the type
`_Ctype_int`, which given it's first character `_` is not exported. As such, we
have the type being defined as `rados._Ctype_int`, which is not accessible
outside of the rados package.
This commit changes the interface to use the native Go `int` type.