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"
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
;
52 struct dmesg_component
{
55 bt_bool read_from_stdin
;
59 struct bt_trace
*trace
;
60 struct bt_stream_class
*stream_class
;
61 struct bt_event_class
*event_class
;
62 struct bt_stream
*stream
;
63 struct bt_packet
*packet
;
64 struct bt_clock_class
*clock_class
;
65 struct bt_clock_class_priority_map
*cc_prio_map
;
69 struct bt_field_type
*create_packet_header_ft(void)
71 struct bt_field_type
*root_ft
= NULL
;
72 struct bt_field_type
*ft
= NULL
;
75 root_ft
= bt_field_type_structure_create();
77 BT_LOGE_STR("Cannot create an empty structure field type object.");
81 ft
= bt_field_type_integer_create(32);
83 BT_LOGE_STR("Cannot create an integer field type object.");
87 ret
= bt_field_type_structure_add_field(root_ft
, ft
, "magic");
89 BT_LOGE("Cannot add `magic` field type to structure field type: "
95 ft
= bt_field_type_integer_create(8);
97 BT_LOGE_STR("Cannot create an integer field type object.");
112 struct bt_field_type
*create_packet_context_ft(void)
114 struct bt_field_type
*root_ft
= NULL
;
115 struct bt_field_type
*ft
= NULL
;
118 root_ft
= bt_field_type_structure_create();
120 BT_LOGE_STR("Cannot create an empty structure field type object.");
124 ft
= bt_field_type_integer_create(64);
126 BT_LOGE_STR("Cannot create an integer field type object.");
130 ret
= bt_field_type_structure_add_field(root_ft
,
133 BT_LOGE("Cannot add `content_size` field type to structure field type: "
139 ft
= bt_field_type_integer_create(64);
141 BT_LOGE_STR("Cannot create an integer field type object.");
145 ret
= bt_field_type_structure_add_field(root_ft
,
148 BT_LOGE("Cannot add `packet_size` field type to structure field type: "
164 struct bt_field_type
*create_event_header_ft(
165 struct bt_clock_class
*clock_class
)
167 struct bt_field_type
*root_ft
= NULL
;
168 struct bt_field_type
*ft
= NULL
;
171 root_ft
= bt_field_type_structure_create();
173 BT_LOGE_STR("Cannot create an empty structure field type object.");
177 ft
= bt_field_type_integer_create(64);
179 BT_LOGE_STR("Cannot create an integer field type object.");
183 ret
= bt_field_type_integer_set_mapped_clock_class(ft
, clock_class
);
185 BT_LOGE("Cannot map integer field type to clock class: "
190 ret
= bt_field_type_structure_add_field(root_ft
,
193 BT_LOGE("Cannot add `timestamp` field type to structure field type: "
209 struct bt_field_type
*create_event_payload_ft(void)
211 struct bt_field_type
*root_ft
= NULL
;
212 struct bt_field_type
*ft
= NULL
;
215 root_ft
= bt_field_type_structure_create();
217 BT_LOGE_STR("Cannot create an empty structure field type object.");
221 ft
= bt_field_type_string_create();
223 BT_LOGE_STR("Cannot create a string field type object.");
227 ret
= bt_field_type_structure_add_field(root_ft
,
230 BT_LOGE("Cannot add `str` field type to structure field type: "
246 struct bt_clock_class
*create_clock_class(void)
248 return bt_clock_class_create("the_clock", 1000000000);
252 int create_meta(struct dmesg_component
*dmesg_comp
, bool has_ts
)
254 struct bt_field_type
*ft
= NULL
;
255 const char *trace_name
= NULL
;
256 gchar
*basename
= NULL
;
259 dmesg_comp
->trace
= bt_trace_create();
260 if (!dmesg_comp
->trace
) {
261 BT_LOGE_STR("Cannot create an empty trace object.");
265 ft
= create_packet_header_ft();
267 BT_LOGE_STR("Cannot create packet header field type.");
271 ret
= bt_trace_set_packet_header_type(dmesg_comp
->trace
, ft
);
273 BT_LOGE_STR("Cannot set trace's packet header field type.");
277 if (dmesg_comp
->params
.read_from_stdin
) {
278 trace_name
= "STDIN";
280 basename
= g_path_get_basename(dmesg_comp
->params
.path
->str
);
283 if (strcmp(basename
, G_DIR_SEPARATOR_S
) != 0 &&
284 strcmp(basename
, ".") != 0) {
285 trace_name
= basename
;
290 ret
= bt_trace_set_name(dmesg_comp
->trace
, trace_name
);
292 BT_LOGE("Cannot set trace's name: name=\"%s\"", trace_name
);
297 dmesg_comp
->stream_class
= bt_stream_class_create_empty(NULL
);
298 if (!dmesg_comp
->stream_class
) {
299 BT_LOGE_STR("Cannot create an empty stream class object.");
304 ft
= create_packet_context_ft();
306 BT_LOGE_STR("Cannot create packet context field type.");
310 ret
= bt_stream_class_set_packet_context_type(
311 dmesg_comp
->stream_class
, ft
);
313 BT_LOGE_STR("Cannot set stream class's packet context field type.");
317 dmesg_comp
->cc_prio_map
= bt_clock_class_priority_map_create();
318 if (!dmesg_comp
->cc_prio_map
) {
319 BT_LOGE_STR("Cannot create empty clock class priority map.");
324 dmesg_comp
->clock_class
= create_clock_class();
325 if (!dmesg_comp
->clock_class
) {
326 BT_LOGE_STR("Cannot create clock class.");
330 ret
= bt_trace_add_clock_class(dmesg_comp
->trace
,
331 dmesg_comp
->clock_class
);
333 BT_LOGE_STR("Cannot add clock class to trace.");
337 ret
= bt_clock_class_priority_map_add_clock_class(
338 dmesg_comp
->cc_prio_map
, dmesg_comp
->clock_class
, 0);
340 BT_LOGE_STR("Cannot add clock class to clock class priority map.");
345 ft
= create_event_header_ft(dmesg_comp
->clock_class
);
347 BT_LOGE_STR("Cannot create event header field type.");
351 ret
= bt_stream_class_set_event_header_type(
352 dmesg_comp
->stream_class
, ft
);
354 BT_LOGE_STR("Cannot set stream class's event header field type.");
359 dmesg_comp
->event_class
= bt_event_class_create("string");
360 if (!dmesg_comp
->event_class
) {
361 BT_LOGE_STR("Cannot create an empty event class object.");
366 ft
= create_event_payload_ft();
368 BT_LOGE_STR("Cannot create event payload field type.");
372 ret
= bt_event_class_set_payload_type(dmesg_comp
->event_class
, ft
);
374 BT_LOGE_STR("Cannot set event class's event payload field type.");
378 ret
= bt_stream_class_add_event_class(dmesg_comp
->stream_class
,
379 dmesg_comp
->event_class
);
381 BT_LOGE("Cannot add event class to stream class: ret=%d", ret
);
385 ret
= bt_trace_add_stream_class(dmesg_comp
->trace
,
386 dmesg_comp
->stream_class
);
388 BT_LOGE("Cannot add event class to stream class: ret=%d", ret
);
408 int handle_params(struct dmesg_component
*dmesg_comp
, struct bt_value
*params
)
410 struct bt_value
*read_from_stdin
= NULL
;
411 struct bt_value
*no_timestamp
= NULL
;
412 struct bt_value
*path
= NULL
;
413 const char *path_str
;
416 no_timestamp
= bt_value_map_get(params
, "no-extract-timestamp");
418 if (!bt_value_is_bool(no_timestamp
)) {
419 BT_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: "
421 bt_value_type_string(
422 bt_value_get_type(no_timestamp
)));
426 ret
= bt_value_bool_get(no_timestamp
,
427 &dmesg_comp
->params
.no_timestamp
);
431 path
= bt_value_map_get(params
, "path");
433 if (dmesg_comp
->params
.read_from_stdin
) {
434 BT_LOGE_STR("Cannot specify both `read-from-stdin` and `path` parameters.");
438 if (!bt_value_is_string(path
)) {
439 BT_LOGE("Expecting a string value for the `path` parameter: "
441 bt_value_type_string(
442 bt_value_get_type(path
)));
446 ret
= bt_value_string_get(path
, &path_str
);
448 g_string_assign(dmesg_comp
->params
.path
, path_str
);
450 dmesg_comp
->params
.read_from_stdin
= true;
459 bt_put(read_from_stdin
);
461 bt_put(no_timestamp
);
466 struct bt_field
*create_packet_header_field(struct bt_field_type
*ft
)
468 struct bt_field
*ph
= NULL
;
469 struct bt_field
*magic
= NULL
;
472 ph
= bt_field_create(ft
);
474 BT_LOGE_STR("Cannot create field object.");
478 magic
= bt_field_structure_get_field_by_name(ph
, "magic");
480 BT_LOGE_STR("Cannot get `magic` field from structure field.");
484 ret
= bt_field_unsigned_integer_set_value(magic
, 0xc1fc1fc1);
486 BT_LOGE_STR("Cannot set integer field's value.");
501 struct bt_field
*create_packet_context_field(struct bt_field_type
*ft
)
503 struct bt_field
*pc
= NULL
;
504 struct bt_field
*field
= NULL
;
507 pc
= bt_field_create(ft
);
509 BT_LOGE_STR("Cannot create field object.");
513 field
= bt_field_structure_get_field_by_name(pc
, "content_size");
515 BT_LOGE_STR("Cannot get `content_size` field from structure field.");
519 ret
= bt_field_unsigned_integer_set_value(field
, 0);
521 BT_LOGE_STR("Cannot set integer field's value.");
526 field
= bt_field_structure_get_field_by_name(pc
, "packet_size");
528 BT_LOGE_STR("Cannot get `packet_size` field from structure field.");
532 ret
= bt_field_unsigned_integer_set_value(field
, 0);
534 BT_LOGE_STR("Cannot set integer field's value.");
549 int create_packet_and_stream(struct dmesg_component
*dmesg_comp
)
552 struct bt_field_type
*ft
= NULL
;
553 struct bt_field
*field
= NULL
;
555 dmesg_comp
->stream
= bt_stream_create(dmesg_comp
->stream_class
,
557 if (!dmesg_comp
->stream
) {
558 BT_LOGE_STR("Cannot create stream object.");
562 dmesg_comp
->packet
= bt_packet_create(dmesg_comp
->stream
);
563 if (!dmesg_comp
->packet
) {
564 BT_LOGE_STR("Cannot create packet object.");
568 ft
= bt_trace_get_packet_header_type(dmesg_comp
->trace
);
570 field
= create_packet_header_field(ft
);
572 BT_LOGE_STR("Cannot create packet header field.");
576 ret
= bt_packet_set_header(dmesg_comp
->packet
, field
);
578 BT_LOGE_STR("Cannot set packet's header field.");
584 ft
= bt_stream_class_get_packet_context_type(
585 dmesg_comp
->stream_class
);
587 field
= create_packet_context_field(ft
);
589 BT_LOGE_STR("Cannot create packet context field.");
593 ret
= bt_packet_set_context(dmesg_comp
->packet
, field
);
595 BT_LOGE_STR("Cannot set packet's context field.");
599 ret
= bt_trace_set_is_static(dmesg_comp
->trace
);
601 BT_LOGE_STR("Cannot make trace static.");
617 int try_create_meta_stream_packet(struct dmesg_component
*dmesg_comp
,
622 if (dmesg_comp
->trace
) {
623 /* Already created */
627 ret
= create_meta(dmesg_comp
, has_ts
);
629 BT_LOGE("Cannot create metadata objects: dmesg-comp-addr=%p",
634 ret
= create_packet_and_stream(dmesg_comp
);
636 BT_LOGE("Cannot create packet and stream objects: "
637 "dmesg-comp-addr=%p", dmesg_comp
);
651 void destroy_dmesg_component(struct dmesg_component
*dmesg_comp
)
657 if (dmesg_comp
->params
.path
) {
658 g_string_free(dmesg_comp
->params
.path
, TRUE
);
661 bt_put(dmesg_comp
->packet
);
662 bt_put(dmesg_comp
->trace
);
663 bt_put(dmesg_comp
->stream_class
);
664 bt_put(dmesg_comp
->event_class
);
665 bt_put(dmesg_comp
->stream
);
666 bt_put(dmesg_comp
->clock_class
);
667 bt_put(dmesg_comp
->cc_prio_map
);
672 enum bt_component_status
create_port(struct bt_private_component
*priv_comp
)
674 return bt_private_component_source_add_output_private_port(priv_comp
,
679 enum bt_component_status
dmesg_init(struct bt_private_component
*priv_comp
,
680 struct bt_value
*params
, void *init_method_data
)
683 struct dmesg_component
*dmesg_comp
= g_new0(struct dmesg_component
, 1);
684 enum bt_component_status status
= BT_COMPONENT_STATUS_OK
;
687 BT_LOGE_STR("Failed to allocate one dmesg component structure.");
691 dmesg_comp
->params
.path
= g_string_new(NULL
);
692 if (!dmesg_comp
->params
.path
) {
693 BT_LOGE_STR("Failed to allocate a GString.");
697 ret
= handle_params(dmesg_comp
, params
);
699 BT_LOGE("Invalid parameters: comp-addr=%p", priv_comp
);
703 if (!dmesg_comp
->params
.read_from_stdin
&&
704 !g_file_test(dmesg_comp
->params
.path
->str
,
705 G_FILE_TEST_IS_REGULAR
)) {
706 BT_LOGE("Input path is not a regular file: "
707 "comp-addr=%p, path=\"%s\"", priv_comp
,
708 dmesg_comp
->params
.path
->str
);
712 status
= create_port(priv_comp
);
713 if (status
!= BT_COMPONENT_STATUS_OK
) {
717 (void) bt_private_component_set_user_data(priv_comp
, dmesg_comp
);
721 destroy_dmesg_component(dmesg_comp
);
722 (void) bt_private_component_set_user_data(priv_comp
, NULL
);
725 status
= BT_COMPONENT_STATUS_ERROR
;
733 void dmesg_finalize(struct bt_private_component
*priv_comp
)
735 void *data
= bt_private_component_get_user_data(priv_comp
);
737 destroy_dmesg_component(data
);
741 int create_event_header_from_line(
742 struct dmesg_component
*dmesg_comp
,
743 const char *line
, const char **new_start
,
744 struct bt_field
**user_field
,
745 struct bt_clock_value
**user_clock_value
)
747 bool has_timestamp
= false;
748 unsigned long sec
, usec
, msec
;
749 unsigned int year
, mon
, mday
, hour
, min
;
751 struct bt_clock_value
*clock_value
= NULL
;
752 struct bt_field_type
*ft
= NULL
;
753 struct bt_field
*eh_field
= NULL
;
754 struct bt_field
*ts_field
= NULL
;
757 assert(user_clock_value
);
761 if (dmesg_comp
->params
.no_timestamp
) {
765 /* Extract time from input line */
766 if (sscanf(line
, "[%lu.%lu] ", &sec
, &usec
) == 2) {
767 ts
= (uint64_t) sec
* USEC_PER_SEC
+ (uint64_t) usec
;
770 * The clock class we use has a 1 GHz frequency: convert
774 has_timestamp
= true;
775 } else if (sscanf(line
, "[%u-%u-%u %u:%u:%lu.%lu] ",
776 &year
, &mon
, &mday
, &hour
, &min
,
781 memset(&ti
, 0, sizeof(ti
));
782 ti
.tm_year
= year
- 1900; /* From 1900 */
783 ti
.tm_mon
= mon
- 1; /* 0 to 11 */
789 ep_sec
= bt_timegm(&ti
);
790 if (ep_sec
!= (time_t) -1) {
791 ts
= (uint64_t) ep_sec
* NSEC_PER_SEC
792 + (uint64_t) msec
* NSEC_PER_MSEC
;
795 has_timestamp
= true;
799 /* Set new start for the message portion of the line */
800 *new_start
= strchr(line
, ']');
804 if ((*new_start
)[0] == ' ') {
811 * At this point, we know if the stream class's event header
812 * field type should have a timestamp or not, so we can lazily
813 * create the metadata, stream, and packet objects.
815 ret
= try_create_meta_stream_packet(dmesg_comp
, has_timestamp
);
817 /* try_create_meta_stream_packet() logs errors */
821 if (dmesg_comp
->clock_class
) {
822 clock_value
= bt_clock_value_create(dmesg_comp
->clock_class
,
825 BT_LOGE_STR("Cannot create clock value object.");
829 ft
= bt_stream_class_get_event_header_type(
830 dmesg_comp
->stream_class
);
832 eh_field
= bt_field_create(ft
);
834 BT_LOGE_STR("Cannot create event header field object.");
838 ts_field
= bt_field_structure_get_field_by_name(eh_field
,
841 BT_LOGE_STR("Cannot get `timestamp` field from structure field.");
845 ret
= bt_field_unsigned_integer_set_value(ts_field
, ts
);
847 BT_LOGE_STR("Cannot set integer field's value.");
851 *user_clock_value
= clock_value
;
853 *user_field
= eh_field
;
871 int create_event_payload_from_line(
872 struct dmesg_component
*dmesg_comp
,
873 const char *line
, struct bt_field
**user_field
)
875 struct bt_field_type
*ft
= NULL
;
876 struct bt_field
*ep_field
= NULL
;
877 struct bt_field
*str_field
= NULL
;
882 ft
= bt_event_class_get_payload_type(dmesg_comp
->event_class
);
884 ep_field
= bt_field_create(ft
);
886 BT_LOGE_STR("Cannot create event payload field object.");
890 str_field
= bt_field_structure_get_field_by_name(ep_field
, "str");
892 BT_LOGE_STR("Cannot get `timestamp` field from structure field.");
897 if (line
[len
- 1] == '\n') {
898 /* Do not include the newline character in the payload */
902 ret
= bt_field_string_append_len(str_field
, line
, len
);
904 BT_LOGE("Cannot append value to string field object: "
909 *user_field
= ep_field
;
924 struct bt_notification
*create_notif_from_line(
925 struct dmesg_component
*dmesg_comp
, const char *line
)
927 struct bt_field
*eh_field
= NULL
;
928 struct bt_field
*ep_field
= NULL
;
929 struct bt_clock_value
*clock_value
= NULL
;
930 struct bt_event
*event
= NULL
;
931 struct bt_notification
*notif
= NULL
;
932 const char *new_start
;
935 ret
= create_event_header_from_line(dmesg_comp
, line
, &new_start
,
936 &eh_field
, &clock_value
);
938 BT_LOGE("Cannot create event header field from line: "
943 ret
= create_event_payload_from_line(dmesg_comp
, new_start
,
946 BT_LOGE("Cannot create event payload field from line: "
952 event
= bt_event_create(dmesg_comp
->event_class
);
954 BT_LOGE_STR("Cannot create event object.");
958 ret
= bt_event_set_packet(event
, dmesg_comp
->packet
);
960 BT_LOGE_STR("Cannot set event's packet.");
965 ret
= bt_event_set_header(event
, eh_field
);
967 BT_LOGE_STR("Cannot set event's header field.");
972 ret
= bt_event_set_event_payload(event
, ep_field
);
974 BT_LOGE_STR("Cannot set event's payload field.");
979 ret
= bt_event_set_clock_value(event
, clock_value
);
981 BT_LOGE_STR("Cannot set event's clock value.");
986 notif
= bt_notification_event_create(event
, dmesg_comp
->cc_prio_map
);
988 BT_LOGE_STR("Cannot create event notification.");
1000 bt_put(clock_value
);
1006 void destroy_dmesg_notif_iter(struct dmesg_notif_iter
*dmesg_notif_iter
)
1008 if (!dmesg_notif_iter
) {
1012 if (dmesg_notif_iter
->fp
&& dmesg_notif_iter
->fp
!= stdin
) {
1013 if (fclose(dmesg_notif_iter
->fp
)) {
1014 BT_LOGE_ERRNO("Cannot close input file", ".");
1018 free(dmesg_notif_iter
->linebuf
);
1019 g_free(dmesg_notif_iter
);
1023 enum bt_notification_iterator_status
dmesg_notif_iter_init(
1024 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
,
1025 struct bt_private_port
*priv_port
)
1027 struct bt_private_component
*priv_comp
= NULL
;
1028 struct dmesg_component
*dmesg_comp
;
1029 struct dmesg_notif_iter
*dmesg_notif_iter
=
1030 g_new0(struct dmesg_notif_iter
, 1);
1031 enum bt_notification_iterator_status status
=
1032 BT_NOTIFICATION_ITERATOR_STATUS_OK
;
1034 if (!dmesg_notif_iter
) {
1035 BT_LOGE_STR("Failed to allocate on dmesg notification iterator structure.");
1039 priv_comp
= bt_private_connection_private_notification_iterator_get_private_component(
1042 dmesg_comp
= bt_private_component_get_user_data(priv_comp
);
1044 dmesg_notif_iter
->dmesg_comp
= dmesg_comp
;
1046 if (dmesg_comp
->params
.read_from_stdin
) {
1047 dmesg_notif_iter
->fp
= stdin
;
1049 dmesg_notif_iter
->fp
= fopen(dmesg_comp
->params
.path
->str
, "r");
1050 if (!dmesg_notif_iter
->fp
) {
1051 BT_LOGE_ERRNO("Cannot open input file in read mode", ": path=\"%s\"",
1052 dmesg_comp
->params
.path
->str
);
1057 (void) bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter
,
1062 destroy_dmesg_notif_iter(dmesg_notif_iter
);
1063 (void) bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter
,
1066 status
= BT_NOTIFICATION_ITERATOR_STATUS_ERROR
;
1075 void dmesg_notif_iter_finalize(
1076 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
)
1078 destroy_dmesg_notif_iter(bt_private_connection_private_notification_iterator_get_user_data(
1083 struct bt_notification_iterator_next_method_return
dmesg_notif_iter_next(
1084 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
)
1087 struct dmesg_notif_iter
*dmesg_notif_iter
=
1088 bt_private_connection_private_notification_iterator_get_user_data(
1090 struct dmesg_component
*dmesg_comp
;
1091 struct bt_notification_iterator_next_method_return next_ret
= {
1092 .status
= BT_NOTIFICATION_ITERATOR_STATUS_OK
,
1093 .notification
= NULL
1096 assert(dmesg_notif_iter
);
1097 dmesg_comp
= dmesg_notif_iter
->dmesg_comp
;
1102 bool only_spaces
= true;
1104 len
= bt_getline(&dmesg_notif_iter
->linebuf
,
1105 &dmesg_notif_iter
->linebuf_len
, dmesg_notif_iter
->fp
);
1107 if (errno
== EINVAL
) {
1109 BT_NOTIFICATION_ITERATOR_STATUS_ERROR
;
1110 } else if (errno
== ENOMEM
) {
1112 BT_NOTIFICATION_ITERATOR_STATUS_NOMEM
;
1115 BT_NOTIFICATION_ITERATOR_STATUS_END
;
1121 assert(dmesg_notif_iter
->linebuf
);
1123 /* Ignore empty lines, once trimmed */
1124 for (ch
= dmesg_notif_iter
->linebuf
; *ch
!= '\0'; ch
++) {
1125 if (!isspace(*ch
)) {
1126 only_spaces
= false;
1136 next_ret
.notification
= create_notif_from_line(dmesg_comp
,
1137 dmesg_notif_iter
->linebuf
);
1138 if (!next_ret
.notification
) {
1139 BT_LOGE("Cannot create event notification from line: "
1140 "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp
,
1141 dmesg_notif_iter
->linebuf
);