2 * SPDX-License-Identifier: MIT
4 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
5 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
8 #define BT_COMP_LOG_SELF_COMP (dmesg_comp->self_comp)
9 #define BT_LOG_OUTPUT_LEVEL (dmesg_comp->log_level)
10 #define BT_LOG_TAG "PLUGIN/SRC.TEXT.DMESG"
11 #include "logging/comp-logging.h"
19 #include "common/common.h"
20 #include "common/assert.h"
21 #include <babeltrace2/babeltrace.h>
22 #include "compat/utc.h"
23 #include "compat/stdio.h"
25 #include "plugins/common/param-validation/param-validation.h"
27 #define NSEC_PER_USEC 1000UL
28 #define NSEC_PER_MSEC 1000000UL
29 #define NSEC_PER_SEC 1000000000ULL
30 #define USEC_PER_SEC 1000000UL
32 struct dmesg_component
;
34 struct dmesg_msg_iter
{
35 struct dmesg_component
*dmesg_comp
;
38 bt_self_message_iterator
*self_msg_iter
;
43 bt_message
*tmp_event_msg
;
44 uint64_t last_clock_value
;
47 STATE_EMIT_STREAM_BEGINNING
,
49 STATE_EMIT_STREAM_END
,
54 struct dmesg_component
{
55 bt_logging_level log_level
;
59 bt_bool read_from_stdin
;
63 bt_self_component_source
*self_comp_src
;
64 bt_self_component
*self_comp
;
65 bt_trace_class
*trace_class
;
66 bt_stream_class
*stream_class
;
67 bt_event_class
*event_class
;
70 bt_clock_class
*clock_class
;
74 bt_field_class
*create_event_payload_fc(struct dmesg_component
*dmesg_comp
,
75 bt_trace_class
*trace_class
)
77 bt_field_class
*root_fc
= NULL
;
78 bt_field_class
*fc
= NULL
;
81 root_fc
= bt_field_class_structure_create(trace_class
);
83 BT_COMP_LOGE_STR("Cannot create an empty structure field class object.");
87 fc
= bt_field_class_string_create(trace_class
);
89 BT_COMP_LOGE_STR("Cannot create a string field class object.");
93 ret
= bt_field_class_structure_append_member(root_fc
,
96 BT_COMP_LOGE("Cannot add `str` member to structure field class: "
104 BT_FIELD_CLASS_PUT_REF_AND_RESET(root_fc
);
107 bt_field_class_put_ref(fc
);
112 int create_meta(struct dmesg_component
*dmesg_comp
, bool has_ts
)
114 bt_field_class
*fc
= NULL
;
117 dmesg_comp
->trace_class
= bt_trace_class_create(dmesg_comp
->self_comp
);
118 if (!dmesg_comp
->trace_class
) {
119 BT_COMP_LOGE_STR("Cannot create an empty trace class object.");
123 dmesg_comp
->stream_class
= bt_stream_class_create(
124 dmesg_comp
->trace_class
);
125 if (!dmesg_comp
->stream_class
) {
126 BT_COMP_LOGE_STR("Cannot create a stream class object.");
131 dmesg_comp
->clock_class
= bt_clock_class_create(
132 dmesg_comp
->self_comp
);
133 if (!dmesg_comp
->clock_class
) {
134 BT_COMP_LOGE_STR("Cannot create clock class.");
139 * The `dmesg` timestamp's origin is not the Unix epoch,
140 * it's the boot time.
142 bt_clock_class_set_origin_is_unix_epoch(dmesg_comp
->clock_class
,
145 ret
= bt_stream_class_set_default_clock_class(
146 dmesg_comp
->stream_class
, dmesg_comp
->clock_class
);
148 BT_COMP_LOGE_STR("Cannot set stream class's default clock class.");
153 dmesg_comp
->event_class
= bt_event_class_create(
154 dmesg_comp
->stream_class
);
155 if (!dmesg_comp
->event_class
) {
156 BT_COMP_LOGE_STR("Cannot create an event class object.");
160 ret
= bt_event_class_set_name(dmesg_comp
->event_class
, "string");
162 BT_COMP_LOGE_STR("Cannot set event class's name.");
166 fc
= create_event_payload_fc(dmesg_comp
, dmesg_comp
->trace_class
);
168 BT_COMP_LOGE_STR("Cannot create event payload field class.");
172 ret
= bt_event_class_set_payload_field_class(dmesg_comp
->event_class
, fc
);
174 BT_COMP_LOGE_STR("Cannot set event class's event payload field class.");
184 bt_field_class_put_ref(fc
);
189 struct bt_param_validation_map_value_entry_descr dmesg_params
[] = {
190 { "no-extract-timestamp", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL
, { .type
= BT_VALUE_TYPE_BOOL
} },
191 { "path", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL
, { .type
= BT_VALUE_TYPE_STRING
} },
192 BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END
196 bt_component_class_initialize_method_status
handle_params(
197 struct dmesg_component
*dmesg_comp
,
198 const bt_value
*params
)
200 const bt_value
*no_timestamp
= NULL
;
201 const bt_value
*path
= NULL
;
202 bt_component_class_initialize_method_status status
;
203 enum bt_param_validation_status validation_status
;
204 gchar
*validate_error
= NULL
;
206 validation_status
= bt_param_validation_validate(params
,
207 dmesg_params
, &validate_error
);
208 if (validation_status
== BT_PARAM_VALIDATION_STATUS_MEMORY_ERROR
) {
209 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR
;
211 } else if (validation_status
== BT_PARAM_VALIDATION_STATUS_VALIDATION_ERROR
) {
212 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR
;
213 BT_COMP_LOGE_APPEND_CAUSE(dmesg_comp
->self_comp
,
214 "%s", validate_error
);
218 no_timestamp
= bt_value_map_borrow_entry_value_const(params
,
219 "no-extract-timestamp");
221 dmesg_comp
->params
.no_timestamp
=
222 bt_value_bool_get(no_timestamp
);
225 path
= bt_value_map_borrow_entry_value_const(params
, "path");
227 const char *path_str
= bt_value_string_get(path
);
229 g_string_assign(dmesg_comp
->params
.path
, path_str
);
231 dmesg_comp
->params
.read_from_stdin
= true;
234 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK
;
236 g_free(validate_error
);
242 int create_stream_and_trace(struct dmesg_component
*dmesg_comp
)
245 const char *trace_name
= NULL
;
246 gchar
*basename
= NULL
;
248 dmesg_comp
->trace
= bt_trace_create(dmesg_comp
->trace_class
);
249 if (!dmesg_comp
->trace
) {
250 BT_COMP_LOGE_STR("Cannot create trace object.");
254 if (dmesg_comp
->params
.read_from_stdin
) {
255 trace_name
= "STDIN";
257 basename
= g_path_get_basename(dmesg_comp
->params
.path
->str
);
260 if (strcmp(basename
, G_DIR_SEPARATOR_S
) != 0 &&
261 strcmp(basename
, ".") != 0) {
262 trace_name
= basename
;
267 ret
= bt_trace_set_name(dmesg_comp
->trace
, trace_name
);
269 BT_COMP_LOGE("Cannot set trace's name: name=\"%s\"",
275 dmesg_comp
->stream
= bt_stream_create(dmesg_comp
->stream_class
,
277 if (!dmesg_comp
->stream
) {
278 BT_COMP_LOGE_STR("Cannot create stream object.");
294 int try_create_meta_stream(struct dmesg_component
*dmesg_comp
, bool has_ts
)
298 if (dmesg_comp
->trace
) {
299 /* Already created */
303 ret
= create_meta(dmesg_comp
, has_ts
);
305 BT_COMP_LOGE("Cannot create metadata objects: dmesg-comp-addr=%p",
310 ret
= create_stream_and_trace(dmesg_comp
);
312 BT_COMP_LOGE("Cannot create stream object: "
313 "dmesg-comp-addr=%p", dmesg_comp
);
327 void destroy_dmesg_component(struct dmesg_component
*dmesg_comp
)
333 if (dmesg_comp
->params
.path
) {
334 g_string_free(dmesg_comp
->params
.path
, TRUE
);
337 bt_trace_put_ref(dmesg_comp
->trace
);
338 bt_stream_class_put_ref(dmesg_comp
->stream_class
);
339 bt_event_class_put_ref(dmesg_comp
->event_class
);
340 bt_stream_put_ref(dmesg_comp
->stream
);
341 bt_clock_class_put_ref(dmesg_comp
->clock_class
);
342 bt_trace_class_put_ref(dmesg_comp
->trace_class
);
347 bt_component_class_initialize_method_status
create_port(
348 bt_self_component_source
*self_comp
)
350 bt_component_class_initialize_method_status status
;
351 bt_self_component_add_port_status add_port_status
;
353 add_port_status
= bt_self_component_source_add_output_port(self_comp
,
355 switch (add_port_status
) {
356 case BT_SELF_COMPONENT_ADD_PORT_STATUS_OK
:
357 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK
;
359 case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR
:
360 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR
;
362 case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR
:
363 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR
;
373 bt_component_class_initialize_method_status
dmesg_init(
374 bt_self_component_source
*self_comp_src
,
375 bt_self_component_source_configuration
*config
,
376 const bt_value
*params
, void *init_method_data
)
378 struct dmesg_component
*dmesg_comp
= g_new0(struct dmesg_component
, 1);
379 bt_component_class_initialize_method_status status
;
380 bt_self_component
*self_comp
=
381 bt_self_component_source_as_self_component(self_comp_src
);
382 const bt_component
*comp
= bt_self_component_as_component(self_comp
);
383 bt_logging_level log_level
= bt_component_get_logging_level(comp
);
386 /* Implicit log level is not available here */
387 BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR
, log_level
, self_comp
,
388 "Failed to allocate one dmesg component structure.");
389 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR
;
393 dmesg_comp
->log_level
= log_level
;
394 dmesg_comp
->self_comp
= self_comp
;
395 dmesg_comp
->self_comp_src
= self_comp_src
;
396 dmesg_comp
->params
.path
= g_string_new(NULL
);
397 if (!dmesg_comp
->params
.path
) {
398 BT_COMP_LOGE_STR("Failed to allocate a GString.");
399 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR
;
403 status
= handle_params(dmesg_comp
, params
);
404 if (status
!= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK
) {
405 BT_COMP_LOGE("Invalid parameters: comp-addr=%p", self_comp
);
406 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR
;
410 if (!dmesg_comp
->params
.read_from_stdin
&&
411 !g_file_test(dmesg_comp
->params
.path
->str
,
412 G_FILE_TEST_IS_REGULAR
)) {
413 BT_COMP_LOGE("Input path is not a regular file: "
414 "comp-addr=%p, path=\"%s\"", self_comp
,
415 dmesg_comp
->params
.path
->str
);
416 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR
;
420 status
= create_port(self_comp_src
);
421 if (status
!= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK
) {
425 bt_self_component_set_data(self_comp
, dmesg_comp
);
426 BT_COMP_LOGI_STR("Component initialized.");
428 status
= BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK
;
432 destroy_dmesg_component(dmesg_comp
);
433 bt_self_component_set_data(self_comp
, NULL
);
440 void dmesg_finalize(bt_self_component_source
*self_comp
)
442 destroy_dmesg_component(bt_self_component_get_data(
443 bt_self_component_source_as_self_component(self_comp
)));
447 bt_message
*create_init_event_msg_from_line(
448 struct dmesg_msg_iter
*msg_iter
,
449 const char *line
, const char **new_start
)
452 bt_message
*msg
= NULL
;
453 bool has_timestamp
= false;
454 unsigned long sec
, usec
, msec
;
455 unsigned int year
, mon
, mday
, hour
, min
;
458 struct dmesg_component
*dmesg_comp
= msg_iter
->dmesg_comp
;
462 if (dmesg_comp
->params
.no_timestamp
) {
466 /* Extract time from input line */
467 if (sscanf(line
, "[%lu.%lu] ", &sec
, &usec
) == 2) {
468 ts
= (uint64_t) sec
* USEC_PER_SEC
+ (uint64_t) usec
;
471 * The clock class we use has a 1 GHz frequency: convert
475 has_timestamp
= true;
476 } else if (sscanf(line
, "[%u-%u-%u %u:%u:%lu.%lu] ",
477 &year
, &mon
, &mday
, &hour
, &min
,
482 memset(&ti
, 0, sizeof(ti
));
483 ti
.tm_year
= year
- 1900; /* From 1900 */
484 ti
.tm_mon
= mon
- 1; /* 0 to 11 */
490 ep_sec
= bt_timegm(&ti
);
491 if (ep_sec
!= (time_t) -1) {
492 ts
= (uint64_t) ep_sec
* NSEC_PER_SEC
493 + (uint64_t) msec
* NSEC_PER_MSEC
;
496 has_timestamp
= true;
500 /* Set new start for the message portion of the line */
501 *new_start
= strchr(line
, ']');
502 BT_ASSERT_DBG(*new_start
);
505 if ((*new_start
)[0] == ' ') {
512 * At this point, we know if the stream class's event header
513 * field class should have a timestamp or not, so we can lazily
514 * create the metadata and stream objects.
516 ret
= try_create_meta_stream(dmesg_comp
, has_timestamp
);
518 /* try_create_meta_stream() logs errors */
522 if (dmesg_comp
->clock_class
) {
523 msg
= bt_message_event_create_with_default_clock_snapshot(
524 msg_iter
->self_msg_iter
,
525 dmesg_comp
->event_class
, dmesg_comp
->stream
, ts
);
526 msg_iter
->last_clock_value
= ts
;
528 msg
= bt_message_event_create(msg_iter
->self_msg_iter
,
529 dmesg_comp
->event_class
, dmesg_comp
->stream
);
533 BT_COMP_LOGE_STR("Cannot create event message.");
537 event
= bt_message_event_borrow_event(msg
);
538 BT_ASSERT_DBG(event
);
542 BT_MESSAGE_PUT_REF_AND_RESET(msg
);
549 int fill_event_payload_from_line(struct dmesg_component
*dmesg_comp
,
550 const char *line
, bt_event
*event
)
552 bt_field
*ep_field
= NULL
;
553 bt_field
*str_field
= NULL
;
557 ep_field
= bt_event_borrow_payload_field(event
);
558 BT_ASSERT_DBG(ep_field
);
559 str_field
= bt_field_structure_borrow_member_field_by_index(
562 BT_COMP_LOGE_STR("Cannot borrow `timestamp` field from event payload structure field.");
567 if (line
[len
- 1] == '\n') {
568 /* Do not include the newline character in the payload */
572 bt_field_string_clear(str_field
);
573 ret
= bt_field_string_append_with_length(str_field
, line
, len
);
575 BT_COMP_LOGE("Cannot append value to string field object: "
590 bt_message
*create_msg_from_line(
591 struct dmesg_msg_iter
*dmesg_msg_iter
, const char *line
)
593 struct dmesg_component
*dmesg_comp
= dmesg_msg_iter
->dmesg_comp
;
594 bt_event
*event
= NULL
;
595 bt_message
*msg
= NULL
;
596 const char *new_start
;
599 msg
= create_init_event_msg_from_line(dmesg_msg_iter
,
602 BT_COMP_LOGE_STR("Cannot create and initialize event message from line.");
606 event
= bt_message_event_borrow_event(msg
);
607 BT_ASSERT_DBG(event
);
608 ret
= fill_event_payload_from_line(dmesg_comp
, new_start
, event
);
610 BT_COMP_LOGE("Cannot fill event payload field from line: "
618 BT_MESSAGE_PUT_REF_AND_RESET(msg
);
625 void destroy_dmesg_msg_iter(struct dmesg_msg_iter
*dmesg_msg_iter
)
627 struct dmesg_component
*dmesg_comp
;
629 if (!dmesg_msg_iter
) {
633 dmesg_comp
= dmesg_msg_iter
->dmesg_comp
;
635 if (dmesg_msg_iter
->fp
&& dmesg_msg_iter
->fp
!= stdin
) {
636 if (fclose(dmesg_msg_iter
->fp
)) {
637 BT_COMP_LOGE_ERRNO("Cannot close input file", ".");
641 bt_message_put_ref(dmesg_msg_iter
->tmp_event_msg
);
642 free(dmesg_msg_iter
->linebuf
);
643 g_free(dmesg_msg_iter
);
649 bt_message_iterator_class_initialize_method_status
dmesg_msg_iter_init(
650 bt_self_message_iterator
*self_msg_iter
,
651 bt_self_message_iterator_configuration
*config
,
652 bt_self_component_port_output
*self_port
)
654 bt_self_component
*self_comp
=
655 bt_self_message_iterator_borrow_component(self_msg_iter
);
656 struct dmesg_component
*dmesg_comp
= bt_self_component_get_data(self_comp
);
657 struct dmesg_msg_iter
*dmesg_msg_iter
=
658 g_new0(struct dmesg_msg_iter
, 1);
659 bt_message_iterator_class_initialize_method_status status
=
660 BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK
;
662 if (!dmesg_msg_iter
) {
663 BT_COMP_LOGE_STR("Failed to allocate on dmesg message iterator structure.");
667 BT_ASSERT(dmesg_comp
);
668 dmesg_msg_iter
->dmesg_comp
= dmesg_comp
;
669 dmesg_msg_iter
->self_msg_iter
= self_msg_iter
;
671 if (dmesg_comp
->params
.read_from_stdin
) {
672 dmesg_msg_iter
->fp
= stdin
;
674 dmesg_msg_iter
->fp
= fopen(dmesg_comp
->params
.path
->str
, "r");
675 if (!dmesg_msg_iter
->fp
) {
676 BT_COMP_LOGE_ERRNO("Cannot open input file in read mode", ": path=\"%s\"",
677 dmesg_comp
->params
.path
->str
);
682 bt_self_message_iterator_set_data(self_msg_iter
,
687 destroy_dmesg_msg_iter(dmesg_msg_iter
);
688 bt_self_message_iterator_set_data(self_msg_iter
, NULL
);
690 status
= BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR
;
698 void dmesg_msg_iter_finalize(
699 bt_self_message_iterator
*priv_msg_iter
)
701 destroy_dmesg_msg_iter(bt_self_message_iterator_get_data(
706 bt_message_iterator_class_next_method_status
dmesg_msg_iter_next_one(
707 struct dmesg_msg_iter
*dmesg_msg_iter
,
711 struct dmesg_component
*dmesg_comp
;
712 bt_message_iterator_class_next_method_status status
=
713 BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK
;
715 BT_ASSERT_DBG(dmesg_msg_iter
);
716 dmesg_comp
= dmesg_msg_iter
->dmesg_comp
;
717 BT_ASSERT_DBG(dmesg_comp
);
719 if (dmesg_msg_iter
->state
== STATE_DONE
) {
720 status
= BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END
;
724 if (dmesg_msg_iter
->tmp_event_msg
||
725 dmesg_msg_iter
->state
== STATE_EMIT_STREAM_END
) {
731 bool only_spaces
= true;
733 len
= bt_getline(&dmesg_msg_iter
->linebuf
,
734 &dmesg_msg_iter
->linebuf_len
, dmesg_msg_iter
->fp
);
736 if (errno
== EINVAL
) {
737 status
= BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR
;
738 } else if (errno
== ENOMEM
) {
739 status
= BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR
;
741 if (dmesg_msg_iter
->state
== STATE_EMIT_STREAM_BEGINNING
) {
742 /* Stream did not even begin */
743 status
= BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END
;
747 dmesg_msg_iter
->state
=
748 STATE_EMIT_STREAM_END
;
756 BT_ASSERT_DBG(dmesg_msg_iter
->linebuf
);
758 /* Ignore empty lines, once trimmed */
759 for (ch
= dmesg_msg_iter
->linebuf
; *ch
!= '\0'; ch
++) {
760 if (!isspace((unsigned char) *ch
)) {
771 dmesg_msg_iter
->tmp_event_msg
= create_msg_from_line(
772 dmesg_msg_iter
, dmesg_msg_iter
->linebuf
);
773 if (!dmesg_msg_iter
->tmp_event_msg
) {
774 BT_COMP_LOGE("Cannot create event message from line: "
775 "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp
,
776 dmesg_msg_iter
->linebuf
);
781 BT_ASSERT_DBG(dmesg_comp
->trace
);
783 switch (dmesg_msg_iter
->state
) {
784 case STATE_EMIT_STREAM_BEGINNING
:
785 BT_ASSERT_DBG(dmesg_msg_iter
->tmp_event_msg
);
786 *msg
= bt_message_stream_beginning_create(
787 dmesg_msg_iter
->self_msg_iter
, dmesg_comp
->stream
);
788 dmesg_msg_iter
->state
= STATE_EMIT_EVENT
;
790 case STATE_EMIT_EVENT
:
791 BT_ASSERT_DBG(dmesg_msg_iter
->tmp_event_msg
);
792 *msg
= dmesg_msg_iter
->tmp_event_msg
;
793 dmesg_msg_iter
->tmp_event_msg
= NULL
;
795 case STATE_EMIT_STREAM_END
:
796 *msg
= bt_message_stream_end_create(
797 dmesg_msg_iter
->self_msg_iter
, dmesg_comp
->stream
);
798 dmesg_msg_iter
->state
= STATE_DONE
;
805 BT_COMP_LOGE("Cannot create message: dmesg-comp-addr=%p",
807 status
= BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR
;
815 bt_message_iterator_class_next_method_status
dmesg_msg_iter_next(
816 bt_self_message_iterator
*self_msg_iter
,
817 bt_message_array_const msgs
, uint64_t capacity
,
820 struct dmesg_msg_iter
*dmesg_msg_iter
=
821 bt_self_message_iterator_get_data(
823 bt_message_iterator_class_next_method_status status
=
824 BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK
;
827 while (i
< capacity
&&
828 status
== BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK
) {
829 bt_message
*priv_msg
= NULL
;
831 status
= dmesg_msg_iter_next_one(dmesg_msg_iter
,
834 if (status
== BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK
) {
841 * Even if dmesg_msg_iter_next_one() returned
842 * something else than
843 * BT_SELF_MESSAGE_ITERATOR_STATUS_OK, we
844 * accumulated message objects in the output
845 * message array, so we need to return
846 * BT_SELF_MESSAGE_ITERATOR_STATUS_OK so that they
847 * are transfered to downstream. This other status
848 * occurs again the next time muxer_msg_iter_do_next()
849 * is called, possibly without any accumulated
850 * message, in which case we'll return it.
853 status
= BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK
;
860 bt_message_iterator_class_can_seek_beginning_method_status
861 dmesg_msg_iter_can_seek_beginning(
862 bt_self_message_iterator
*self_msg_iter
, bt_bool
*can_seek
)
864 struct dmesg_msg_iter
*dmesg_msg_iter
=
865 bt_self_message_iterator_get_data(self_msg_iter
);
867 /* Can't seek the beginning of the standard input stream */
868 *can_seek
= !dmesg_msg_iter
->dmesg_comp
->params
.read_from_stdin
;
870 return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK
;
874 bt_message_iterator_class_seek_beginning_method_status
875 dmesg_msg_iter_seek_beginning(
876 bt_self_message_iterator
*self_msg_iter
)
878 struct dmesg_msg_iter
*dmesg_msg_iter
=
879 bt_self_message_iterator_get_data(self_msg_iter
);
881 BT_ASSERT(!dmesg_msg_iter
->dmesg_comp
->params
.read_from_stdin
);
883 BT_MESSAGE_PUT_REF_AND_RESET(dmesg_msg_iter
->tmp_event_msg
);
884 dmesg_msg_iter
->last_clock_value
= 0;
885 dmesg_msg_iter
->state
= STATE_EMIT_STREAM_BEGINNING
;
886 return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK
;