1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
3 * lttng-context-uts-ns.c
5 * LTTng uts namespace context.
7 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * 2019 Michael Jeanson <mjeanson@efficios.com>
12 #include <linux/module.h>
13 #include <linux/slab.h>
14 #include <linux/sched.h>
15 #include <linux/utsname.h>
16 #include <lttng-events.h>
17 #include <wrapper/ringbuffer/frontend_types.h>
18 #include <lttng-tracer.h>
20 #if defined(CONFIG_UTS_NS)
23 size_t uts_ns_get_size(size_t offset
)
27 size
+= lib_ring_buffer_align(offset
, lttng_alignof(unsigned int));
28 size
+= sizeof(unsigned int);
33 void uts_ns_record(struct lttng_ctx_field
*field
,
34 struct lib_ring_buffer_ctx
*ctx
,
35 struct lttng_channel
*chan
)
37 unsigned int uts_ns_inum
= 0;
40 * nsproxy can be NULL when scheduled out of exit.
42 * As documented in 'linux/nsproxy.h' namespaces access rules, no
43 * precautions should be taken when accessing the current task's
44 * namespaces, just dereference the pointers.
47 uts_ns_inum
= current
->nsproxy
->uts_ns
->ns
.inum
;
49 lib_ring_buffer_align_ctx(ctx
, lttng_alignof(uts_ns_inum
));
50 chan
->ops
->event_write(ctx
, &uts_ns_inum
, sizeof(uts_ns_inum
));
54 void uts_ns_get_value(struct lttng_ctx_field
*field
,
55 struct lttng_probe_ctx
*lttng_probe_ctx
,
56 union lttng_ctx_value
*value
)
58 unsigned int uts_ns_inum
= 0;
61 * nsproxy can be NULL when scheduled out of exit.
63 * As documented in 'linux/nsproxy.h' namespaces access rules, no
64 * precautions should be taken when accessing the current task's
65 * namespaces, just dereference the pointers.
68 uts_ns_inum
= current
->nsproxy
->uts_ns
->ns
.inum
;
70 value
->s64
= uts_ns_inum
;
73 int lttng_add_uts_ns_to_ctx(struct lttng_ctx
**ctx
)
75 struct lttng_ctx_field
*field
;
77 field
= lttng_append_context(ctx
);
80 if (lttng_find_context(*ctx
, "uts_ns")) {
81 lttng_remove_context_field(ctx
, field
);
84 field
->event_field
.name
= "uts_ns";
85 field
->event_field
.type
.atype
= atype_integer
;
86 field
->event_field
.type
.u
.integer
.size
= sizeof(unsigned int) * CHAR_BIT
;
87 field
->event_field
.type
.u
.integer
.alignment
= lttng_alignof(unsigned int) * CHAR_BIT
;
88 field
->event_field
.type
.u
.integer
.signedness
= lttng_is_signed_type(unsigned int);
89 field
->event_field
.type
.u
.integer
.reverse_byte_order
= 0;
90 field
->event_field
.type
.u
.integer
.base
= 10;
91 field
->event_field
.type
.u
.integer
.encoding
= lttng_encode_none
;
92 field
->get_size
= uts_ns_get_size
;
93 field
->record
= uts_ns_record
;
94 field
->get_value
= uts_ns_get_value
;
95 lttng_context_update(*ctx
);
98 EXPORT_SYMBOL_GPL(lttng_add_uts_ns_to_ctx
);
This page took 0.030492 seconds and 4 git commands to generate.