X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Flttng-context-hostname.c;h=c34ed5cd1a6814a3da7c1d1ae886cea6a5085557;hb=8a57ec025ffbe56153748fd69b60118862707182;hp=86c5d021dd9c42f4cfedbfc250d889a691e5a7f9;hpb=cfa6cc1d0f01c2cfcc1a679abf3a6572d411c309;p=lttng-modules.git diff --git a/src/lttng-context-hostname.c b/src/lttng-context-hostname.c index 86c5d021..c34ed5cd 100644 --- a/src/lttng-context-hostname.c +++ b/src/lttng-context-hostname.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,7 @@ #define LTTNG_HOSTNAME_CTX_LEN (__NEW_UTS_LEN + 1) static -size_t hostname_get_size(size_t offset) +size_t hostname_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset) { size_t size = 0; @@ -28,8 +29,8 @@ size_t hostname_get_size(size_t offset) } static -void hostname_record(struct lttng_ctx_field *field, - struct lib_ring_buffer_ctx *ctx, +void hostname_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, + struct lttng_kernel_ring_buffer_ctx *ctx, struct lttng_channel *chan) { struct nsproxy *nsproxy; @@ -53,9 +54,9 @@ void hostname_record(struct lttng_ctx_field *field, } static -void hostname_get_value(struct lttng_ctx_field *field, - struct lttng_probe_ctx *lttng_probe_ctx, - union lttng_ctx_value *value) +void hostname_get_value(void *priv, + struct lttng_kernel_probe_ctx *lttng_probe_ctx, + struct lttng_ctx_value *value) { struct nsproxy *nsproxy; struct uts_namespace *ns; @@ -72,35 +73,26 @@ void hostname_get_value(struct lttng_ctx_field *field, } else { hostname = ""; } - value->str = hostname; + value->u.str = hostname; } -static const struct lttng_type hostname_array_elem_type = - __type_integer(char, 0, 0, -1, __BYTE_ORDER, 10, UTF8); +static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field( + lttng_kernel_static_event_field("hostname", + lttng_kernel_static_type_array_text(LTTNG_HOSTNAME_CTX_LEN), + false, false, false), + hostname_get_size, + hostname_record, + hostname_get_value, + NULL, NULL); -int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx) +int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx) { - struct lttng_ctx_field *field; + int ret; - field = lttng_append_context(ctx); - if (!field) - return -ENOMEM; - if (lttng_find_context(*ctx, "hostname")) { - lttng_remove_context_field(ctx, field); + if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name)) return -EEXIST; - } - field->event_field.name = "hostname"; - field->event_field.type.atype = atype_array_nestable; - field->event_field.type.u.array_nestable.elem_type = - &hostname_array_elem_type; - field->event_field.type.u.array_nestable.length = LTTNG_HOSTNAME_CTX_LEN; - field->event_field.type.u.array_nestable.alignment = 0; - - field->get_size = hostname_get_size; - field->record = hostname_record; - field->get_value = hostname_get_value; - lttng_context_update(*ctx); + ret = lttng_kernel_context_append(ctx, ctx_field); wrapper_vmalloc_sync_mappings(); - return 0; + return ret; } EXPORT_SYMBOL_GPL(lttng_add_hostname_to_ctx);