+ ret = lttng_strncpy(lsm.session.name, handle->session_name,
+ sizeof(lsm.session.name));
+ if (ret) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+end:
+ return ret;
+}
+
+enum lttng_error_code lttng_add_map(struct lttng_handle *handle,
+ struct lttng_map *map)
+{
+
+ int ret;
+ enum lttng_error_code ret_code;
+ struct lttcomm_session_msg lsm = {
+ .cmd_type = LTTNG_ADD_MAP,
+ };
+ struct lttcomm_session_msg *message_lsm;
+ struct lttng_payload message;
+ struct lttng_payload reply;
+
+ lttng_payload_init(&message);
+ lttng_payload_init(&reply);
+
+ if (!map) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ lsm.domain.type = lttng_map_get_domain(map);
+
+ lttng_strncpy(lsm.session.name, handle->session_name,
+ sizeof(lsm.session.name));
+
+ ret = lttng_dynamic_buffer_append(&message.buffer, &lsm, sizeof(lsm));
+ if (ret) {
+ ret_code = LTTNG_ERR_NOMEM;
+ goto end;
+ }
+
+ message_lsm = (struct lttcomm_session_msg *) message.buffer.data;
+
+ ret = lttng_map_serialize(map, &message);
+ if (ret < 0) {
+ ret_code = LTTNG_ERR_UNK;
+ goto end;
+ }
+
+ message_lsm->u.add_map.length = (uint32_t) message.buffer.size - sizeof(lsm);
+
+ {
+ struct lttng_payload_view message_view =
+ lttng_payload_view_from_payload(&message, 0, -1);
+
+ message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(
+ &message_view);
+
+ ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
+ if (ret < 0) {
+ ret_code = ret;
+ goto end;
+ }
+ }
+
+ ret_code = LTTNG_OK;
+
+end:
+ lttng_payload_reset(&message);
+ lttng_payload_reset(&reply);
+ return ret_code;
+}
+
+enum lttng_error_code lttng_enable_map(struct lttng_handle *handle,
+ const char *map_name)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ struct lttcomm_session_msg lsm;
+ struct lttng_payload message;
+ struct lttng_payload_view lsm_view =
+ lttng_payload_view_init_from_buffer(
+ (const char *) &lsm, 0, sizeof(lsm));
+ struct lttng_payload reply;
+
+ lttng_payload_init(&message);
+ lttng_payload_init(&reply);
+
+ memset(&lsm, 0, sizeof(lsm));
+ lsm.cmd_type = LTTNG_ENABLE_MAP;
+
+ COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
+
+ ret = lttng_strncpy(lsm.session.name, handle->session_name,