cephfs: add a getErrorIfNegative helper func
Works like the ones already in the other packages.
@@ -35,6 +35,16 @@ func getError(e C.int) error {
return cephFSError(e)
}
+// getErrorIfNegative converts a ceph return code to error if negative.
+// This is useful for functions that return a usable positive value on
+// success but a negative error number on error.
+func getErrorIfNegative(ret C.int) error {
+ if ret >= 0 {
+ return nil
+ }
+ return getError(ret)
+}
+
// Public go errors:
var (
