This is useful when tracking object changes.
Signed-off-by: Angus Salkeld <[email protected]>
---
include/corosync/confdb.h | 6 ++++
include/corosync/ipc_confdb.h | 11 ++++++++
lib/confdb.c | 55 +++++++++++++++++++++++++++++++++++++++++
lib/sa-confdb.c | 8 ++++++
lib/sa-confdb.h | 3 ++
services/confdb.c | 28 +++++++++++++++++++++
6 files changed, 111 insertions(+), 0 deletions(-)
diff --git a/include/corosync/confdb.h b/include/corosync/confdb.h
index ca8e21b..ca0d7ba 100644
--- a/include/corosync/confdb.h
+++ b/include/corosync/confdb.h
@@ -194,6 +194,12 @@ cs_error_t confdb_object_parent_get (
hdb_handle_t object_handle,
hdb_handle_t *parent_object_handle);
+cs_error_t confdb_object_name_get (
+ confdb_handle_t handle,
+ hdb_handle_t object_handle,
+ char *object_name,
+ size_t *object_name_len);
+
/*
* Manipulate keys
*/
diff --git a/include/corosync/ipc_confdb.h b/include/corosync/ipc_confdb.h
index c92bcc6..856c8a6 100644
--- a/include/corosync/ipc_confdb.h
+++ b/include/corosync/ipc_confdb.h
@@ -59,6 +59,7 @@ enum req_confdb_types {
MESSAGE_REQ_CONFDB_KEY_CREATE_TYPED = 17,
MESSAGE_REQ_CONFDB_KEY_GET_TYPED = 18,
MESSAGE_REQ_CONFDB_KEY_ITER_TYPED = 19,
+ MESSAGE_REQ_CONFDB_OBJECT_NAME_GET = 20,
};
enum res_confdb_types {
@@ -85,6 +86,7 @@ enum res_confdb_types {
MESSAGE_RES_CONFDB_KEY_GET_TYPED = 20,
MESSAGE_RES_CONFDB_KEY_ITER_TYPED = 21,
MESSAGE_RES_CONFDB_RELOAD_CALLBACK = 22,
+ MESSAGE_RES_CONFDB_OBJECT_NAME_GET = 23,
};
@@ -114,6 +116,15 @@ struct res_lib_confdb_object_parent_get {
mar_uint64_t parent_object_handle __attribute__((aligned(8)));
};
+struct req_lib_confdb_object_name_get {
+ coroipc_request_header_t header __attribute__((aligned(8)));
+ mar_uint64_t object_handle __attribute__((aligned(8)));
+};
+
+struct res_lib_confdb_object_name_get {
+ coroipc_response_header_t header __attribute__((aligned(8)));
+ mar_name_t object_name __attribute__((aligned(8)));
+};
struct req_lib_confdb_key_create {
coroipc_request_header_t header __attribute__((aligned(8)));
diff --git a/lib/confdb.c b/lib/confdb.c
index fe87073..156a7ca 100644
--- a/lib/confdb.c
+++ b/lib/confdb.c
@@ -575,6 +575,61 @@ error_exit:
return (error);
}
+cs_error_t confdb_object_name_get (
+ confdb_handle_t handle,
+ hdb_handle_t object_handle,
+ char *object_name,
+ size_t *object_name_len)
+{
+ cs_error_t error;
+ struct confdb_inst *confdb_inst;
+ struct iovec iov;
+ struct req_lib_confdb_object_name_get request;
+ struct res_lib_confdb_object_name_get response;
+
+ error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle,
(void *)&confdb_inst));
+ if (error != CS_OK) {
+ return (error);
+ }
+
+ if (confdb_inst->standalone) {
+ error = CS_OK;
+
+ if (confdb_sa_object_name_get(object_handle, object_name,
object_name_len))
+ error = CS_ERR_ACCESS;
+ goto error_exit;
+ }
+
+ request.header.size = sizeof (struct req_lib_confdb_object_name_get);
+ request.header.id = MESSAGE_REQ_CONFDB_OBJECT_NAME_GET;
+ request.object_handle = object_handle;
+
+ iov.iov_base = (char *)&request;
+ iov.iov_len = sizeof (struct req_lib_confdb_object_name_get);
+
+ error = coroipcc_msg_send_reply_receive (
+ confdb_inst->handle,
+ &iov,
+ 1,
+ &response,
+ sizeof (struct res_lib_confdb_object_name_get));
+
+ if (error != CS_OK) {
+ goto error_exit;
+ }
+
+ error = response.header.error;
+ if (error == CS_OK) {
+ *object_name_len = response.object_name.length;
+ memcpy(object_name, response.object_name.value,
*object_name_len);
+ }
+
+error_exit:
+ (void)hdb_handle_put (&confdb_handle_t_db, handle);
+
+ return (error);
+}
+
static cs_error_t do_find_destroy(
struct confdb_inst *confdb_inst,
hdb_handle_t find_handle)
diff --git a/lib/sa-confdb.c b/lib/sa-confdb.c
index 0a71115..03995e3 100644
--- a/lib/sa-confdb.c
+++ b/lib/sa-confdb.c
@@ -186,6 +186,14 @@ int confdb_sa_object_parent_get (
return objdb->object_parent_get(object_handle, parent_object_handle);
}
+int confdb_sa_object_name_get(
+ hdb_handle_t object_handle,
+ char *object_name,
+ size_t *object_name_len)
+{
+ return objdb->object_name_get(object_handle, object_name,
object_name_len);
+}
+
int confdb_sa_key_create (
hdb_handle_t parent_object_handle,
const void *key_name,
diff --git a/lib/sa-confdb.h b/lib/sa-confdb.h
index d9ea906..61a0fa7 100644
--- a/lib/sa-confdb.h
+++ b/lib/sa-confdb.h
@@ -40,6 +40,9 @@ extern int confdb_sa_object_create(hdb_handle_t
parent_object_handle,
extern int confdb_sa_object_destroy(hdb_handle_t object_handle);
extern int confdb_sa_object_parent_get(hdb_handle_t object_handle,
hdb_handle_t *parent_object_handle);
+extern int confdb_sa_object_name_get(hdb_handle_t object_handle,
+ char *object_name,
+ size_t *object_name_len);
extern int confdb_sa_key_create(hdb_handle_t parent_object_handle,
const void *key_name,
size_t key_name_len,
diff --git a/services/confdb.c b/services/confdb.c
index 78770ed..56e3ae1 100644
--- a/services/confdb.c
+++ b/services/confdb.c
@@ -107,6 +107,8 @@ static void message_handler_req_lib_confdb_object_find
(void *conn,
static void message_handler_req_lib_confdb_object_parent_get (void *conn,
const void
*message);
+static void message_handler_req_lib_confdb_object_name_get (void *conn,
+ const void
*message);
static void message_handler_req_lib_confdb_write (void *conn,
const void *message);
static void message_handler_req_lib_confdb_reload (void *conn,
@@ -227,6 +229,10 @@ static struct corosync_lib_handler confdb_lib_engine[] =
.lib_handler_fn =
message_handler_req_lib_confdb_key_iter_typed,
.flow_control =
CS_LIB_FLOW_CONTROL_NOT_REQUIRED
},
+ { /* 20 */
+ .lib_handler_fn =
message_handler_req_lib_confdb_object_name_get,
+ .flow_control =
CS_LIB_FLOW_CONTROL_NOT_REQUIRED
+ },
};
@@ -570,6 +576,28 @@ static void
message_handler_req_lib_confdb_object_parent_get (void *conn,
api->ipc_response_send(conn, &res_lib_confdb_object_parent_get,
sizeof(res_lib_confdb_object_parent_get));
}
+static void message_handler_req_lib_confdb_object_name_get (void *conn,
+ const void
*message)
+{
+ const struct req_lib_confdb_object_name_get *request = message;
+ struct res_lib_confdb_object_name_get response;
+ int ret = CS_OK;
+ char object_name[CS_MAX_NAME_LENGTH];
+ size_t object_name_len;
+
+ if (api->object_name_get(request->object_handle,
+ object_name, &object_name_len)) {
+ ret = CS_ERR_ACCESS;
+ }
+
+ response.object_name.length = object_name_len;
+ strncpy((char*)response.object_name.value, object_name,
CS_MAX_NAME_LENGTH);
+ response.object_name.value[CS_MAX_NAME_LENGTH-1] = '\0';
+ response.header.size = sizeof(response);
+ response.header.id = MESSAGE_RES_CONFDB_OBJECT_NAME_GET;
+ response.header.error = ret;
+ api->ipc_response_send(conn, &response, sizeof(response));
+}
static void message_handler_req_lib_confdb_key_iter (void *conn,
const void *message)
--
1.7.3.4
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais