2 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
3 * Copyright 2017 Philippe Proulx <jeremie.galarneau@efficios.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #define BT_LOG_TAG "PLUGIN-TEXT-DMESG-SRC"
31 #include <babeltrace/assert-internal.h>
32 #include <babeltrace/babeltrace.h>
33 #include <babeltrace/values-internal.h>
34 #include <babeltrace/compat/utc-internal.h>
35 #include <babeltrace/compat/stdio-internal.h>
38 #define NSEC_PER_USEC 1000UL
39 #define NSEC_PER_MSEC 1000000UL
40 #define NSEC_PER_SEC 1000000000ULL
41 #define USEC_PER_SEC 1000000UL
43 struct dmesg_component
;
45 struct dmesg_notif_iter
{
46 struct dmesg_component
*dmesg_comp
;
50 struct bt_notification
*tmp_event_notif
;
53 STATE_EMIT_STREAM_BEGINNING
,
54 STATE_EMIT_PACKET_BEGINNING
,
56 STATE_EMIT_PACKET_END
,
57 STATE_EMIT_STREAM_END
,
62 struct dmesg_component
{
65 bt_bool read_from_stdin
;
69 struct bt_graph
*graph
; /* Weak */
70 struct bt_trace
*trace
;
71 struct bt_stream_class
*stream_class
;
72 struct bt_event_class
*event_class
;
73 struct bt_stream
*stream
;
74 struct bt_packet
*packet
;
75 struct bt_clock_class
*clock_class
;
76 struct bt_clock_class_priority_map
*cc_prio_map
;
80 struct bt_field_type
*create_packet_header_ft(void)
82 struct bt_field_type
*root_ft
= NULL
;
83 struct bt_field_type
*ft
= NULL
;
86 root_ft
= bt_field_type_structure_create();
88 BT_LOGE_STR("Cannot create an empty structure field type object.");
92 ft
= bt_field_type_integer_create(32);
94 BT_LOGE_STR("Cannot create an integer field type object.");
98 ret
= bt_field_type_structure_add_field(root_ft
, ft
, "magic");
100 BT_LOGE("Cannot add `magic` field type to structure field type: "
106 ft
= bt_field_type_integer_create(8);
108 BT_LOGE_STR("Cannot create an integer field type object.");
123 struct bt_field_type
*create_event_header_ft(
124 struct bt_clock_class
*clock_class
)
126 struct bt_field_type
*root_ft
= NULL
;
127 struct bt_field_type
*ft
= NULL
;
130 root_ft
= bt_field_type_structure_create();
132 BT_LOGE_STR("Cannot create an empty structure field type object.");
136 ft
= bt_field_type_integer_create(64);
138 BT_LOGE_STR("Cannot create an integer field type object.");
142 ret
= bt_field_type_integer_set_mapped_clock_class(ft
, clock_class
);
144 BT_LOGE("Cannot map integer field type to clock class: "
149 ret
= bt_field_type_structure_add_field(root_ft
,
152 BT_LOGE("Cannot add `timestamp` field type to structure field type: "
168 struct bt_field_type
*create_event_payload_ft(void)
170 struct bt_field_type
*root_ft
= NULL
;
171 struct bt_field_type
*ft
= NULL
;
174 root_ft
= bt_field_type_structure_create();
176 BT_LOGE_STR("Cannot create an empty structure field type object.");
180 ft
= bt_field_type_string_create();
182 BT_LOGE_STR("Cannot create a string field type object.");
186 ret
= bt_field_type_structure_add_field(root_ft
,
189 BT_LOGE("Cannot add `str` field type to structure field type: "
205 struct bt_clock_class
*create_clock_class(void)
207 return bt_clock_class_create("the_clock", 1000000000);
211 int create_meta(struct dmesg_component
*dmesg_comp
, bool has_ts
)
213 struct bt_field_type
*ft
= NULL
;
214 const char *trace_name
= NULL
;
215 gchar
*basename
= NULL
;
218 dmesg_comp
->trace
= bt_trace_create();
219 if (!dmesg_comp
->trace
) {
220 BT_LOGE_STR("Cannot create an empty trace object.");
224 ft
= create_packet_header_ft();
226 BT_LOGE_STR("Cannot create packet header field type.");
230 ret
= bt_trace_set_packet_header_field_type(dmesg_comp
->trace
, ft
);
232 BT_LOGE_STR("Cannot set trace's packet header field type.");
236 if (dmesg_comp
->params
.read_from_stdin
) {
237 trace_name
= "STDIN";
239 basename
= g_path_get_basename(dmesg_comp
->params
.path
->str
);
242 if (strcmp(basename
, G_DIR_SEPARATOR_S
) != 0 &&
243 strcmp(basename
, ".") != 0) {
244 trace_name
= basename
;
249 ret
= bt_trace_set_name(dmesg_comp
->trace
, trace_name
);
251 BT_LOGE("Cannot set trace's name: name=\"%s\"", trace_name
);
256 dmesg_comp
->stream_class
= bt_stream_class_create(NULL
);
257 if (!dmesg_comp
->stream_class
) {
258 BT_LOGE_STR("Cannot create an empty stream class object.");
262 dmesg_comp
->cc_prio_map
= bt_clock_class_priority_map_create();
263 if (!dmesg_comp
->cc_prio_map
) {
264 BT_LOGE_STR("Cannot create empty clock class priority map.");
269 dmesg_comp
->clock_class
= create_clock_class();
270 if (!dmesg_comp
->clock_class
) {
271 BT_LOGE_STR("Cannot create clock class.");
275 ret
= bt_trace_add_clock_class(dmesg_comp
->trace
,
276 dmesg_comp
->clock_class
);
278 BT_LOGE_STR("Cannot add clock class to trace.");
282 ret
= bt_clock_class_priority_map_add_clock_class(
283 dmesg_comp
->cc_prio_map
, dmesg_comp
->clock_class
, 0);
285 BT_LOGE_STR("Cannot add clock class to clock class priority map.");
290 ft
= create_event_header_ft(dmesg_comp
->clock_class
);
292 BT_LOGE_STR("Cannot create event header field type.");
296 ret
= bt_stream_class_set_event_header_field_type(
297 dmesg_comp
->stream_class
, ft
);
299 BT_LOGE_STR("Cannot set stream class's event header field type.");
304 dmesg_comp
->event_class
= bt_event_class_create("string");
305 if (!dmesg_comp
->event_class
) {
306 BT_LOGE_STR("Cannot create an empty event class object.");
311 ft
= create_event_payload_ft();
313 BT_LOGE_STR("Cannot create event payload field type.");
317 ret
= bt_event_class_set_payload_field_type(dmesg_comp
->event_class
, ft
);
319 BT_LOGE_STR("Cannot set event class's event payload field type.");
323 ret
= bt_stream_class_add_event_class(dmesg_comp
->stream_class
,
324 dmesg_comp
->event_class
);
326 BT_LOGE("Cannot add event class to stream class: ret=%d", ret
);
330 ret
= bt_trace_add_stream_class(dmesg_comp
->trace
,
331 dmesg_comp
->stream_class
);
333 BT_LOGE("Cannot add event class to stream class: ret=%d", ret
);
353 int handle_params(struct dmesg_component
*dmesg_comp
, struct bt_value
*params
)
355 struct bt_value
*read_from_stdin
= NULL
;
356 struct bt_value
*no_timestamp
= NULL
;
357 struct bt_value
*path
= NULL
;
358 const char *path_str
;
361 no_timestamp
= bt_value_map_get(params
, "no-extract-timestamp");
363 if (!bt_value_is_bool(no_timestamp
)) {
364 BT_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: "
366 bt_value_type_string(
367 bt_value_get_type(no_timestamp
)));
371 ret
= bt_value_bool_get(no_timestamp
,
372 &dmesg_comp
->params
.no_timestamp
);
376 path
= bt_value_map_get(params
, "path");
378 if (dmesg_comp
->params
.read_from_stdin
) {
379 BT_LOGE_STR("Cannot specify both `read-from-stdin` and `path` parameters.");
383 if (!bt_value_is_string(path
)) {
384 BT_LOGE("Expecting a string value for the `path` parameter: "
386 bt_value_type_string(
387 bt_value_get_type(path
)));
391 ret
= bt_value_string_get(path
, &path_str
);
393 g_string_assign(dmesg_comp
->params
.path
, path_str
);
395 dmesg_comp
->params
.read_from_stdin
= true;
404 bt_put(read_from_stdin
);
406 bt_put(no_timestamp
);
411 int fill_packet_header_field(struct bt_packet
*packet
)
413 struct bt_field
*ph
= NULL
;
414 struct bt_field
*magic
= NULL
;
417 ph
= bt_packet_borrow_header(packet
);
419 magic
= bt_field_structure_borrow_field_by_name(ph
, "magic");
421 BT_LOGE_STR("Cannot borrow `magic` field from structure field.");
425 ret
= bt_field_integer_unsigned_set_value(magic
, 0xc1fc1fc1);
437 int create_packet_and_stream(struct dmesg_component
*dmesg_comp
)
441 dmesg_comp
->stream
= bt_stream_create(dmesg_comp
->stream_class
,
443 if (!dmesg_comp
->stream
) {
444 BT_LOGE_STR("Cannot create stream object.");
448 dmesg_comp
->packet
= bt_packet_create(dmesg_comp
->stream
);
449 if (!dmesg_comp
->packet
) {
450 BT_LOGE_STR("Cannot create packet object.");
454 ret
= fill_packet_header_field(dmesg_comp
->packet
);
456 BT_LOGE_STR("Cannot fill packet header field.");
460 ret
= bt_trace_set_is_static(dmesg_comp
->trace
);
462 BT_LOGE_STR("Cannot make trace static.");
476 int try_create_meta_stream_packet(struct dmesg_component
*dmesg_comp
,
481 if (dmesg_comp
->trace
) {
482 /* Already created */
486 ret
= create_meta(dmesg_comp
, has_ts
);
488 BT_LOGE("Cannot create metadata objects: dmesg-comp-addr=%p",
493 ret
= create_packet_and_stream(dmesg_comp
);
495 BT_LOGE("Cannot create packet and stream objects: "
496 "dmesg-comp-addr=%p", dmesg_comp
);
510 void destroy_dmesg_component(struct dmesg_component
*dmesg_comp
)
516 if (dmesg_comp
->params
.path
) {
517 g_string_free(dmesg_comp
->params
.path
, TRUE
);
520 bt_put(dmesg_comp
->packet
);
521 bt_put(dmesg_comp
->trace
);
522 bt_put(dmesg_comp
->stream_class
);
523 bt_put(dmesg_comp
->event_class
);
524 bt_put(dmesg_comp
->stream
);
525 bt_put(dmesg_comp
->clock_class
);
526 bt_put(dmesg_comp
->cc_prio_map
);
531 enum bt_component_status
create_port(struct bt_private_component
*priv_comp
)
533 return bt_private_component_source_add_output_private_port(priv_comp
,
538 enum bt_component_status
dmesg_init(struct bt_private_component
*priv_comp
,
539 struct bt_value
*params
, void *init_method_data
)
542 struct dmesg_component
*dmesg_comp
= g_new0(struct dmesg_component
, 1);
543 enum bt_component_status status
= BT_COMPONENT_STATUS_OK
;
546 BT_LOGE_STR("Failed to allocate one dmesg component structure.");
550 dmesg_comp
->graph
= bt_component_borrow_graph(
551 bt_component_borrow_from_private(priv_comp
));
552 BT_ASSERT(dmesg_comp
->graph
);
553 dmesg_comp
->params
.path
= g_string_new(NULL
);
554 if (!dmesg_comp
->params
.path
) {
555 BT_LOGE_STR("Failed to allocate a GString.");
559 ret
= handle_params(dmesg_comp
, params
);
561 BT_LOGE("Invalid parameters: comp-addr=%p", priv_comp
);
565 if (!dmesg_comp
->params
.read_from_stdin
&&
566 !g_file_test(dmesg_comp
->params
.path
->str
,
567 G_FILE_TEST_IS_REGULAR
)) {
568 BT_LOGE("Input path is not a regular file: "
569 "comp-addr=%p, path=\"%s\"", priv_comp
,
570 dmesg_comp
->params
.path
->str
);
574 status
= create_port(priv_comp
);
575 if (status
!= BT_COMPONENT_STATUS_OK
) {
579 (void) bt_private_component_set_user_data(priv_comp
, dmesg_comp
);
583 destroy_dmesg_component(dmesg_comp
);
584 (void) bt_private_component_set_user_data(priv_comp
, NULL
);
587 status
= BT_COMPONENT_STATUS_ERROR
;
595 void dmesg_finalize(struct bt_private_component
*priv_comp
)
597 void *data
= bt_private_component_get_user_data(priv_comp
);
599 destroy_dmesg_component(data
);
603 struct bt_notification
*create_init_event_notif_from_line(
604 struct dmesg_component
*dmesg_comp
,
605 const char *line
, const char **new_start
)
607 struct bt_event
*event
;
608 struct bt_notification
*notif
= NULL
;
609 bool has_timestamp
= false;
610 unsigned long sec
, usec
, msec
;
611 unsigned int year
, mon
, mday
, hour
, min
;
613 struct bt_field
*eh_field
= NULL
;
614 struct bt_field
*ts_field
= NULL
;
619 if (dmesg_comp
->params
.no_timestamp
) {
623 /* Extract time from input line */
624 if (sscanf(line
, "[%lu.%lu] ", &sec
, &usec
) == 2) {
625 ts
= (uint64_t) sec
* USEC_PER_SEC
+ (uint64_t) usec
;
628 * The clock class we use has a 1 GHz frequency: convert
632 has_timestamp
= true;
633 } else if (sscanf(line
, "[%u-%u-%u %u:%u:%lu.%lu] ",
634 &year
, &mon
, &mday
, &hour
, &min
,
639 memset(&ti
, 0, sizeof(ti
));
640 ti
.tm_year
= year
- 1900; /* From 1900 */
641 ti
.tm_mon
= mon
- 1; /* 0 to 11 */
647 ep_sec
= bt_timegm(&ti
);
648 if (ep_sec
!= (time_t) -1) {
649 ts
= (uint64_t) ep_sec
* NSEC_PER_SEC
650 + (uint64_t) msec
* NSEC_PER_MSEC
;
653 has_timestamp
= true;
657 /* Set new start for the message portion of the line */
658 *new_start
= strchr(line
, ']');
659 BT_ASSERT(*new_start
);
662 if ((*new_start
)[0] == ' ') {
669 * At this point, we know if the stream class's event header
670 * field type should have a timestamp or not, so we can lazily
671 * create the metadata, stream, and packet objects.
673 ret
= try_create_meta_stream_packet(dmesg_comp
, has_timestamp
);
675 /* try_create_meta_stream_packet() logs errors */
679 notif
= bt_notification_event_create(dmesg_comp
->graph
,
680 dmesg_comp
->event_class
, dmesg_comp
->packet
,
681 dmesg_comp
->cc_prio_map
);
683 BT_LOGE_STR("Cannot create event notification.");
687 event
= bt_notification_event_borrow_event(notif
);
690 if (dmesg_comp
->clock_class
) {
691 struct bt_clock_value
*cv
= bt_event_borrow_clock_value(event
,
692 dmesg_comp
->clock_class
);
694 ret
= bt_clock_value_set_value(cv
, ts
);
696 eh_field
= bt_event_borrow_header(event
);
698 ts_field
= bt_field_structure_borrow_field_by_name(eh_field
,
701 BT_LOGE_STR("Cannot borrow `timestamp` field from event header structure field.");
705 ret
= bt_field_integer_unsigned_set_value(ts_field
, ts
);
719 int fill_event_payload_from_line(struct dmesg_component
*dmesg_comp
,
720 const char *line
, struct bt_event
*event
)
722 struct bt_field
*ep_field
= NULL
;
723 struct bt_field
*str_field
= NULL
;
727 ep_field
= bt_event_borrow_payload(event
);
729 str_field
= bt_field_structure_borrow_field_by_name(ep_field
, "str");
731 BT_LOGE_STR("Cannot borrow `timestamp` field from event payload structure field.");
736 if (line
[len
- 1] == '\n') {
737 /* Do not include the newline character in the payload */
741 ret
= bt_field_string_clear(str_field
);
743 BT_LOGE_STR("Cannot clear string field object.");
747 ret
= bt_field_string_append_len(str_field
, line
, len
);
749 BT_LOGE("Cannot append value to string field object: "
764 struct bt_notification
*create_notif_from_line(
765 struct dmesg_component
*dmesg_comp
, const char *line
)
767 struct bt_event
*event
= NULL
;
768 struct bt_notification
*notif
= NULL
;
769 const char *new_start
;
772 notif
= create_init_event_notif_from_line(dmesg_comp
, line
, &new_start
);
774 BT_LOGE_STR("Cannot create and initialize event notification from line.");
778 event
= bt_notification_event_borrow_event(notif
);
780 ret
= fill_event_payload_from_line(dmesg_comp
, new_start
,
783 BT_LOGE("Cannot fill event payload field from line: "
798 void destroy_dmesg_notif_iter(struct dmesg_notif_iter
*dmesg_notif_iter
)
800 if (!dmesg_notif_iter
) {
804 if (dmesg_notif_iter
->fp
&& dmesg_notif_iter
->fp
!= stdin
) {
805 if (fclose(dmesg_notif_iter
->fp
)) {
806 BT_LOGE_ERRNO("Cannot close input file", ".");
810 bt_put(dmesg_notif_iter
->tmp_event_notif
);
811 free(dmesg_notif_iter
->linebuf
);
812 g_free(dmesg_notif_iter
);
816 enum bt_notification_iterator_status
dmesg_notif_iter_init(
817 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
,
818 struct bt_private_port
*priv_port
)
820 struct bt_private_component
*priv_comp
= NULL
;
821 struct dmesg_component
*dmesg_comp
;
822 struct dmesg_notif_iter
*dmesg_notif_iter
=
823 g_new0(struct dmesg_notif_iter
, 1);
824 enum bt_notification_iterator_status status
=
825 BT_NOTIFICATION_ITERATOR_STATUS_OK
;
827 if (!dmesg_notif_iter
) {
828 BT_LOGE_STR("Failed to allocate on dmesg notification iterator structure.");
832 priv_comp
= bt_private_connection_private_notification_iterator_get_private_component(
834 BT_ASSERT(priv_comp
);
835 dmesg_comp
= bt_private_component_get_user_data(priv_comp
);
836 BT_ASSERT(dmesg_comp
);
837 dmesg_notif_iter
->dmesg_comp
= dmesg_comp
;
839 if (dmesg_comp
->params
.read_from_stdin
) {
840 dmesg_notif_iter
->fp
= stdin
;
842 dmesg_notif_iter
->fp
= fopen(dmesg_comp
->params
.path
->str
, "r");
843 if (!dmesg_notif_iter
->fp
) {
844 BT_LOGE_ERRNO("Cannot open input file in read mode", ": path=\"%s\"",
845 dmesg_comp
->params
.path
->str
);
850 (void) bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter
,
855 destroy_dmesg_notif_iter(dmesg_notif_iter
);
856 (void) bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter
,
859 status
= BT_NOTIFICATION_ITERATOR_STATUS_ERROR
;
868 void dmesg_notif_iter_finalize(
869 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
)
871 destroy_dmesg_notif_iter(bt_private_connection_private_notification_iterator_get_user_data(
876 enum bt_notification_iterator_status
dmesg_notif_iter_next_one(
877 struct dmesg_notif_iter
*dmesg_notif_iter
,
878 struct bt_notification
**notif
)
881 struct dmesg_component
*dmesg_comp
;
882 enum bt_notification_iterator_status status
=
883 BT_NOTIFICATION_ITERATOR_STATUS_OK
;
885 BT_ASSERT(dmesg_notif_iter
);
886 dmesg_comp
= dmesg_notif_iter
->dmesg_comp
;
887 BT_ASSERT(dmesg_comp
);
889 if (dmesg_notif_iter
->state
== STATE_DONE
) {
890 status
= BT_NOTIFICATION_ITERATOR_STATUS_END
;
894 if (dmesg_notif_iter
->tmp_event_notif
||
895 dmesg_notif_iter
->state
== STATE_EMIT_PACKET_END
||
896 dmesg_notif_iter
->state
== STATE_EMIT_STREAM_END
) {
902 bool only_spaces
= true;
904 len
= bt_getline(&dmesg_notif_iter
->linebuf
,
905 &dmesg_notif_iter
->linebuf_len
, dmesg_notif_iter
->fp
);
907 if (errno
== EINVAL
) {
908 status
= BT_NOTIFICATION_ITERATOR_STATUS_ERROR
;
909 } else if (errno
== ENOMEM
) {
911 BT_NOTIFICATION_ITERATOR_STATUS_NOMEM
;
913 if (dmesg_notif_iter
->state
== STATE_EMIT_STREAM_BEGINNING
) {
914 /* Stream did not even begin */
915 status
= BT_NOTIFICATION_ITERATOR_STATUS_END
;
918 /* End current packet now */
919 dmesg_notif_iter
->state
=
920 STATE_EMIT_PACKET_END
;
928 BT_ASSERT(dmesg_notif_iter
->linebuf
);
930 /* Ignore empty lines, once trimmed */
931 for (ch
= dmesg_notif_iter
->linebuf
; *ch
!= '\0'; ch
++) {
943 dmesg_notif_iter
->tmp_event_notif
= create_notif_from_line(dmesg_comp
,
944 dmesg_notif_iter
->linebuf
);
945 if (!dmesg_notif_iter
->tmp_event_notif
) {
946 BT_LOGE("Cannot create event notification from line: "
947 "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp
,
948 dmesg_notif_iter
->linebuf
);
953 BT_ASSERT(dmesg_comp
->trace
);
955 switch (dmesg_notif_iter
->state
) {
956 case STATE_EMIT_STREAM_BEGINNING
:
957 BT_ASSERT(dmesg_notif_iter
->tmp_event_notif
);
958 *notif
= bt_notification_stream_begin_create(
959 dmesg_comp
->graph
, dmesg_comp
->stream
);
960 dmesg_notif_iter
->state
= STATE_EMIT_PACKET_BEGINNING
;
962 case STATE_EMIT_PACKET_BEGINNING
:
963 BT_ASSERT(dmesg_notif_iter
->tmp_event_notif
);
964 *notif
= bt_notification_packet_begin_create(
965 dmesg_comp
->graph
, dmesg_comp
->packet
);
966 dmesg_notif_iter
->state
= STATE_EMIT_EVENT
;
968 case STATE_EMIT_EVENT
:
969 BT_ASSERT(dmesg_notif_iter
->tmp_event_notif
);
970 *notif
= dmesg_notif_iter
->tmp_event_notif
;
971 dmesg_notif_iter
->tmp_event_notif
= NULL
;
973 case STATE_EMIT_PACKET_END
:
974 *notif
= bt_notification_packet_end_create(
975 dmesg_comp
->graph
, dmesg_comp
->packet
);
976 dmesg_notif_iter
->state
= STATE_EMIT_STREAM_END
;
978 case STATE_EMIT_STREAM_END
:
979 *notif
= bt_notification_stream_end_create(
980 dmesg_comp
->graph
, dmesg_comp
->stream
);
981 dmesg_notif_iter
->state
= STATE_DONE
;
988 BT_LOGE("Cannot create notification: dmesg-comp-addr=%p",
990 status
= BT_NOTIFICATION_ITERATOR_STATUS_ERROR
;
998 enum bt_notification_iterator_status
dmesg_notif_iter_next(
999 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
,
1000 bt_notification_array notifs
, uint64_t capacity
,
1003 struct dmesg_notif_iter
*dmesg_notif_iter
=
1004 bt_private_connection_private_notification_iterator_get_user_data(
1006 enum bt_notification_iterator_status status
=
1007 BT_NOTIFICATION_ITERATOR_STATUS_OK
;
1010 while (i
< capacity
&& status
== BT_NOTIFICATION_ITERATOR_STATUS_OK
) {
1011 status
= dmesg_notif_iter_next_one(dmesg_notif_iter
, ¬ifs
[i
]);
1012 if (status
== BT_NOTIFICATION_ITERATOR_STATUS_OK
) {
1019 * Even if dmesg_notif_iter_next_one() returned
1020 * something else than
1021 * BT_NOTIFICATION_ITERATOR_STATUS_OK, we accumulated
1022 * notification objects in the output notification
1023 * array, so we need to return
1024 * BT_NOTIFICATION_ITERATOR_STATUS_OK so that they are
1025 * transfered to downstream. This other status occurs
1026 * again the next time muxer_notif_iter_do_next() is
1027 * called, possibly without any accumulated
1028 * notification, in which case we'll return it.
1031 status
= BT_NOTIFICATION_ITERATOR_STATUS_OK
;