bae0bd14bdda1eca1a9849500c582412944c7b87
[babeltrace.git] / plugins / ctf / fs-src / data-stream-file.c
1 /*
2 * Copyright 2016-2017 - Philippe Proulx <pproulx@efficios.com>
3 * Copyright 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * Copyright 2010-2011 - EfficiOS Inc. and Linux Foundation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <stdint.h>
28 #include <stdlib.h>
29 #include <stdbool.h>
30 #include <glib.h>
31 #include <inttypes.h>
32 #include <babeltrace/compat/mman-internal.h>
33 #include <babeltrace/endian-internal.h>
34 #include <babeltrace/ctf-ir/stream.h>
35 #include <babeltrace/graph/notification-iterator.h>
36 #include <babeltrace/graph/notification-stream.h>
37 #include <babeltrace/graph/notification-event.h>
38 #include <babeltrace/graph/notification-packet.h>
39 #include <babeltrace/common-internal.h>
40 #include "file.h"
41 #include "metadata.h"
42 #include "../common/notif-iter/notif-iter.h"
43 #include <assert.h>
44 #include "data-stream-file.h"
45 #include <string.h>
46
47 #define BT_LOG_TAG "PLUGIN-CTF-FS-SRC-DS"
48 #include "logging.h"
49
50 static inline
51 size_t remaining_mmap_bytes(struct ctf_fs_ds_file *ds_file)
52 {
53 return ds_file->mmap_valid_len - ds_file->request_offset;
54 }
55
56 static
57 int ds_file_munmap(struct ctf_fs_ds_file *ds_file)
58 {
59 int ret = 0;
60
61 if (!ds_file || !ds_file->mmap_addr) {
62 goto end;
63 }
64
65 if (bt_munmap(ds_file->mmap_addr, ds_file->mmap_len)) {
66 BT_LOGE_ERRNO("Cannot memory-unmap file",
67 ": address=%p, size=%zu, file_path=\"%s\", file=%p",
68 ds_file->mmap_addr, ds_file->mmap_len,
69 ds_file->file->path->str,
70 ds_file->file ? ds_file->file->fp : NULL);
71 ret = -1;
72 goto end;
73 }
74
75 ds_file->mmap_addr = NULL;
76
77 end:
78 return ret;
79 }
80
81 static
82 enum bt_ctf_notif_iter_medium_status ds_file_mmap_next(
83 struct ctf_fs_ds_file *ds_file)
84 {
85 const size_t page_size = bt_common_get_page_size();
86 enum bt_ctf_notif_iter_medium_status ret =
87 BT_CTF_NOTIF_ITER_MEDIUM_STATUS_OK;
88
89 /* Unmap old region */
90 if (ds_file->mmap_addr) {
91 if (ds_file_munmap(ds_file)) {
92 goto error;
93 }
94
95 /*
96 * mmap_valid_len is guaranteed to be page-aligned except on the
97 * last mapping where it may not be possible (since the file's
98 * size itself may not be a page multiple).
99 */
100 ds_file->mmap_offset += ds_file->mmap_valid_len;
101 ds_file->request_offset = 0;
102 }
103
104 ds_file->mmap_valid_len = MIN(ds_file->file->size - ds_file->mmap_offset,
105 ds_file->mmap_max_len);
106 if (ds_file->mmap_valid_len == 0) {
107 ret = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF;
108 goto end;
109 }
110 /* Round up to next page, assuming page size being a power of 2. */
111 ds_file->mmap_len = (ds_file->mmap_valid_len + page_size - 1)
112 & ~(page_size - 1);
113 /* Map new region */
114 assert(ds_file->mmap_len);
115 ds_file->mmap_addr = bt_mmap((void *) 0, ds_file->mmap_len,
116 PROT_READ, MAP_PRIVATE, fileno(ds_file->file->fp),
117 ds_file->mmap_offset);
118 if (ds_file->mmap_addr == MAP_FAILED) {
119 BT_LOGE("Cannot memory-map address (size %zu) of file \"%s\" (%p) at offset %jd: %s",
120 ds_file->mmap_len, ds_file->file->path->str,
121 ds_file->file->fp, (intmax_t) ds_file->mmap_offset,
122 strerror(errno));
123 goto error;
124 }
125
126 goto end;
127 error:
128 ds_file_munmap(ds_file);
129 ret = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_ERROR;
130 end:
131 return ret;
132 }
133
134 static
135 enum bt_ctf_notif_iter_medium_status medop_request_bytes(
136 size_t request_sz, uint8_t **buffer_addr,
137 size_t *buffer_sz, void *data)
138 {
139 enum bt_ctf_notif_iter_medium_status status =
140 BT_CTF_NOTIF_ITER_MEDIUM_STATUS_OK;
141 struct ctf_fs_ds_file *ds_file = data;
142
143 if (request_sz == 0) {
144 goto end;
145 }
146
147 /* Check if we have at least one memory-mapped byte left */
148 if (remaining_mmap_bytes(ds_file) == 0) {
149 /* Are we at the end of the file? */
150 if (ds_file->mmap_offset >= ds_file->file->size) {
151 BT_LOGD("Reached end of file \"%s\" (%p)",
152 ds_file->file->path->str, ds_file->file->fp);
153 status = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF;
154 goto end;
155 }
156
157 status = ds_file_mmap_next(ds_file);
158 switch (status) {
159 case BT_CTF_NOTIF_ITER_MEDIUM_STATUS_OK:
160 break;
161 case BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF:
162 goto end;
163 default:
164 BT_LOGE("Cannot memory-map next region of file \"%s\" (%p)",
165 ds_file->file->path->str,
166 ds_file->file->fp);
167 goto error;
168 }
169 }
170
171 *buffer_sz = MIN(remaining_mmap_bytes(ds_file), request_sz);
172 *buffer_addr = ((uint8_t *) ds_file->mmap_addr) + ds_file->request_offset;
173 ds_file->request_offset += *buffer_sz;
174 goto end;
175
176 error:
177 status = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_ERROR;
178
179 end:
180 return status;
181 }
182
183 static
184 struct bt_ctf_stream *medop_get_stream(
185 struct bt_ctf_stream_class *stream_class, uint64_t stream_id,
186 void *data)
187 {
188 struct ctf_fs_ds_file *ds_file = data;
189 struct bt_ctf_stream_class *ds_file_stream_class;
190 struct bt_ctf_stream *stream = NULL;
191
192 ds_file_stream_class = bt_ctf_stream_get_class(ds_file->stream);
193 bt_put(ds_file_stream_class);
194
195 if (stream_class != ds_file_stream_class) {
196 /*
197 * Not supported: two packets described by two different
198 * stream classes within the same data stream file.
199 */
200 goto end;
201 }
202
203 stream = ds_file->stream;
204
205 end:
206 return stream;
207 }
208
209 BT_HIDDEN
210 struct bt_ctf_notif_iter_medium_ops ctf_fs_ds_file_medops = {
211 .request_bytes = medop_request_bytes,
212 .get_stream = medop_get_stream,
213 };
214
215 static
216 struct ctf_fs_ds_index *ctf_fs_ds_index_create(size_t length)
217 {
218 struct ctf_fs_ds_index *index = g_new0(struct ctf_fs_ds_index, 1);
219
220 if (!index) {
221 BT_LOGE_STR("Failed to allocate index");
222 goto error;
223 }
224
225 index->entries = g_array_sized_new(FALSE, TRUE,
226 sizeof(struct ctf_fs_ds_index_entry), length);
227 if (!index->entries) {
228 BT_LOGE("Failed to allocate %zu index entries.", length);
229 goto error;
230 }
231 g_array_set_size(index->entries, length);
232 end:
233 return index;
234 error:
235 ctf_fs_ds_index_destroy(index);
236 goto end;
237 }
238
239 static
240 struct bt_ctf_clock_class *get_field_mapped_clock_class(
241 struct bt_ctf_field *field)
242 {
243 struct bt_ctf_field_type *field_type;
244 struct bt_ctf_clock_class *clock_class = NULL;
245
246 field_type = bt_ctf_field_get_type(field);
247 if (!field_type) {
248 goto end;
249 }
250
251 clock_class = bt_ctf_field_type_integer_get_mapped_clock_class(
252 field_type);
253 if (!clock_class) {
254 goto end;
255 }
256 end:
257 bt_put(field_type);
258 return clock_class;
259 }
260
261 static
262 int get_ds_file_packet_bounds_clock_classes(struct ctf_fs_ds_file *ds_file,
263 struct bt_ctf_clock_class **_timestamp_begin_cc,
264 struct bt_ctf_clock_class **_timestamp_end_cc)
265 {
266 int ret;
267 struct bt_ctf_field *timestamp_field = NULL;
268 struct bt_ctf_field *packet_context_field = NULL;
269 struct bt_ctf_clock_class *timestamp_begin_cc = NULL;
270 struct bt_ctf_clock_class *timestamp_end_cc = NULL;
271
272 ret = ctf_fs_ds_file_get_packet_header_context_fields(ds_file,
273 NULL, &packet_context_field);
274 if (ret || !packet_context_field) {
275 BT_LOGD("Cannot retrieve packet context field of stream \'%s\'",
276 ds_file->file->path->str);
277 ret = -1;
278 goto end;
279 }
280
281 timestamp_field = bt_ctf_field_structure_get_field_by_name(
282 packet_context_field, "timestamp_begin");
283 if (!timestamp_field) {
284 BT_LOGD("Cannot retrieve timestamp_begin field in packet context of stream \'%s\'",
285 ds_file->file->path->str);
286 ret = -1;
287 goto end;
288 }
289
290 timestamp_begin_cc = get_field_mapped_clock_class(timestamp_field);
291 if (!timestamp_begin_cc) {
292 BT_LOGD("Cannot retrieve the clock mapped to timestamp_begin of stream \'%s\'",
293 ds_file->file->path->str);
294 }
295 BT_PUT(timestamp_field);
296
297 timestamp_field = bt_ctf_field_structure_get_field_by_name(
298 packet_context_field, "timestamp_end");
299 if (!timestamp_field) {
300 BT_LOGD("Cannot retrieve timestamp_end field in packet context of stream \'%s\'",
301 ds_file->file->path->str);
302 ret = -1;
303 goto end;
304 }
305
306 timestamp_end_cc = get_field_mapped_clock_class(timestamp_field);
307 if (!timestamp_end_cc) {
308 BT_LOGD("Cannot retrieve the clock mapped to timestamp_end in stream \'%s\'",
309 ds_file->file->path->str);
310 }
311
312 if (_timestamp_begin_cc) {
313 *_timestamp_begin_cc = bt_get(timestamp_begin_cc);
314 }
315 if (_timestamp_end_cc) {
316 *_timestamp_end_cc = bt_get(timestamp_end_cc);
317 }
318 end:
319 bt_put(packet_context_field);
320 bt_put(timestamp_field);
321 bt_put(timestamp_begin_cc);
322 bt_put(timestamp_end_cc);
323 return ret;
324 }
325
326 static
327 int convert_cycles_to_ns(struct bt_ctf_clock_class *clock_class,
328 uint64_t cycles, int64_t *ns)
329 {
330 int ret = 0;
331 struct bt_ctf_clock_value *clock_value;
332
333 assert(ns);
334 clock_value = bt_ctf_clock_value_create(clock_class, cycles);
335 if (!clock_value) {
336 ret = -1;
337 goto end;
338 }
339
340 ret = bt_ctf_clock_value_get_value_ns_from_epoch(clock_value, ns);
341 if (ret) {
342 goto end;
343 }
344 end:
345 bt_put(clock_value);
346 return ret;
347 }
348
349 static
350 struct ctf_fs_ds_index *build_index_from_idx_file(
351 struct ctf_fs_ds_file *ds_file)
352 {
353 int ret;
354 gchar *directory = NULL;
355 gchar *basename = NULL;
356 GString *index_basename = NULL;
357 gchar *index_file_path = NULL;
358 GMappedFile *mapped_file = NULL;
359 gsize filesize;
360 const char *mmap_begin = NULL, *file_pos = NULL;
361 const struct ctf_packet_index_file_hdr *header = NULL;
362 struct ctf_fs_ds_index *index = NULL;
363 struct ctf_fs_ds_index_entry *index_entry = NULL;
364 uint64_t total_packets_size = 0;
365 size_t file_index_entry_size;
366 size_t file_entry_count;
367 size_t i;
368 struct bt_ctf_clock_class *timestamp_begin_cc = NULL;
369 struct bt_ctf_clock_class *timestamp_end_cc = NULL;
370
371 BT_LOGD("Building index from .idx file of stream file %s",
372 ds_file->file->path->str);
373
374 ret = get_ds_file_packet_bounds_clock_classes(ds_file,
375 &timestamp_begin_cc, &timestamp_end_cc);
376 if (ret) {
377 BT_LOGD("Cannot get clock classes of \"timestamp_begin\" and \"timestamp_end\" fields");
378 goto error;
379 }
380
381 /* Look for index file in relative path index/name.idx. */
382 basename = g_path_get_basename(ds_file->file->path->str);
383 if (!basename) {
384 BT_LOGE("Cannot get the basename of datastream file %s",
385 ds_file->file->path->str);
386 goto error;
387 }
388
389 directory = g_path_get_dirname(ds_file->file->path->str);
390 if (!directory) {
391 BT_LOGE("Cannot get dirname of datastream file %s",
392 ds_file->file->path->str);
393 goto error;
394 }
395
396 index_basename = g_string_new(basename);
397 if (!index_basename) {
398 BT_LOGE("Cannot allocate index file basename string");
399 goto error;
400 }
401
402 g_string_append(index_basename, ".idx");
403 index_file_path = g_build_filename(directory, "index",
404 index_basename->str, NULL);
405 mapped_file = g_mapped_file_new(index_file_path, FALSE, NULL);
406 if (!mapped_file) {
407 BT_LOGD("Cannot create new mapped file %s",
408 index_file_path);
409 goto error;
410 }
411
412 /*
413 * The g_mapped_file API limits us to 4GB files on 32-bit.
414 * Traces with such large indexes have never been seen in the wild,
415 * but this would need to be adjusted to support them.
416 */
417 filesize = g_mapped_file_get_length(mapped_file);
418 if (filesize < sizeof(*header)) {
419 BT_LOGW("Invalid LTTng trace index file: "
420 "file size (%zu bytes) < header size (%zu bytes)",
421 filesize, sizeof(*header));
422 goto error;
423 }
424
425 mmap_begin = g_mapped_file_get_contents(mapped_file);
426 header = (struct ctf_packet_index_file_hdr *) mmap_begin;
427
428 file_pos = g_mapped_file_get_contents(mapped_file) + sizeof(*header);
429 if (be32toh(header->magic) != CTF_INDEX_MAGIC) {
430 BT_LOGW("Invalid LTTng trace index: \"magic\" field validation failed");
431 goto error;
432 }
433
434 file_index_entry_size = be32toh(header->packet_index_len);
435 file_entry_count = (filesize - sizeof(*header)) / file_index_entry_size;
436 if ((filesize - sizeof(*header)) % file_index_entry_size) {
437 BT_LOGW("Invalid LTTng trace index: the index's size after the header "
438 "(%zu bytes) is not a multiple of the index entry size "
439 "(%zu bytes)", (filesize - sizeof(*header)),
440 sizeof(*header));
441 goto error;
442 }
443
444 index = ctf_fs_ds_index_create(file_entry_count);
445 if (!index) {
446 goto error;
447 }
448
449 index_entry = (struct ctf_fs_ds_index_entry *) &g_array_index(
450 index->entries, struct ctf_fs_ds_index_entry, 0);
451 for (i = 0; i < file_entry_count; i++) {
452 struct ctf_packet_index *file_index =
453 (struct ctf_packet_index *) file_pos;
454 uint64_t packet_size = be64toh(file_index->packet_size);
455
456 if (packet_size % CHAR_BIT) {
457 BT_LOGW("Invalid packet size encountered in LTTng trace index file");
458 goto error;
459 }
460
461 /* Convert size in bits to bytes. */
462 packet_size /= CHAR_BIT;
463 index_entry->packet_size = packet_size;
464
465 index_entry->offset = be64toh(file_index->offset);
466 if (i != 0 && index_entry->offset < (index_entry - 1)->offset) {
467 BT_LOGW("Invalid, non-monotonic, packet offset encountered in LTTng trace index file: "
468 "previous offset=%" PRIu64 ", current offset=%" PRIu64,
469 (index_entry - 1)->offset, index_entry->offset);
470 goto error;
471 }
472
473 index_entry->timestamp_begin = be64toh(file_index->timestamp_begin);
474 index_entry->timestamp_end = be64toh(file_index->timestamp_end);
475 if (index_entry->timestamp_end < index_entry->timestamp_begin) {
476 BT_LOGW("Invalid packet time bounds encountered in LTTng trace index file (begin > end): "
477 "timestamp_begin=%" PRIu64 "timestamp_end=%" PRIu64,
478 index_entry->timestamp_begin,
479 index_entry->timestamp_end);
480 goto error;
481 }
482
483 /* Convert the packet's bound to nanoseconds since Epoch. */
484 ret = convert_cycles_to_ns(timestamp_begin_cc,
485 index_entry->timestamp_begin,
486 &index_entry->timestamp_begin_ns);
487 if (ret) {
488 BT_LOGD("Failed to convert raw timestamp to nanoseconds since Epoch during index parsing");
489 goto error;
490 }
491 ret = convert_cycles_to_ns(timestamp_end_cc,
492 index_entry->timestamp_end,
493 &index_entry->timestamp_end_ns);
494 if (ret) {
495 BT_LOGD("Failed to convert raw timestamp to nanoseconds since Epoch during LTTng trace index parsing");
496 goto error;
497 }
498
499 total_packets_size += packet_size;
500 file_pos += file_index_entry_size;
501 index_entry++;
502 }
503
504 /* Validate that the index addresses the complete stream. */
505 if (ds_file->file->size != total_packets_size) {
506 BT_LOGW("Invalid LTTng trace index file; indexed size != stream file size: "
507 "file_size=%" PRIu64 ", total_packets_size=%" PRIu64,
508 ds_file->file->size, total_packets_size);
509 goto error;
510 }
511 end:
512 g_free(directory);
513 g_free(basename);
514 g_free(index_file_path);
515 if (index_basename) {
516 g_string_free(index_basename, TRUE);
517 }
518 if (mapped_file) {
519 g_mapped_file_unref(mapped_file);
520 }
521 bt_put(timestamp_begin_cc);
522 bt_put(timestamp_end_cc);
523 return index;
524 error:
525 ctf_fs_ds_index_destroy(index);
526 index = NULL;
527 goto end;
528 }
529
530 BT_HIDDEN
531 struct ctf_fs_ds_file *ctf_fs_ds_file_create(
532 struct ctf_fs_trace *ctf_fs_trace,
533 struct bt_ctf_notif_iter *notif_iter,
534 struct bt_ctf_stream *stream, const char *path)
535 {
536 int ret;
537 const size_t page_size = bt_common_get_page_size();
538 struct ctf_fs_ds_file *ds_file = g_new0(struct ctf_fs_ds_file, 1);
539
540 if (!ds_file) {
541 goto error;
542 }
543
544 ds_file->file = ctf_fs_file_create();
545 if (!ds_file->file) {
546 goto error;
547 }
548
549 ds_file->stream = bt_get(stream);
550 ds_file->cc_prio_map = bt_get(ctf_fs_trace->cc_prio_map);
551 g_string_assign(ds_file->file->path, path);
552 ret = ctf_fs_file_open(ds_file->file, "rb");
553 if (ret) {
554 goto error;
555 }
556
557 ds_file->notif_iter = notif_iter;
558 bt_ctf_notif_iter_set_medops_data(ds_file->notif_iter, ds_file);
559 if (!ds_file->notif_iter) {
560 goto error;
561 }
562
563 ds_file->mmap_max_len = page_size * 2048;
564
565 goto end;
566
567 error:
568 /* Do not touch "borrowed" file. */
569 ctf_fs_ds_file_destroy(ds_file);
570 ds_file = NULL;
571
572 end:
573 return ds_file;
574 }
575
576 BT_HIDDEN
577 struct ctf_fs_ds_index *ctf_fs_ds_file_build_index(
578 struct ctf_fs_ds_file *ds_file)
579 {
580 return build_index_from_idx_file(ds_file);
581 }
582
583 BT_HIDDEN
584 void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file)
585 {
586 if (!ds_file) {
587 return;
588 }
589
590 bt_put(ds_file->cc_prio_map);
591 bt_put(ds_file->stream);
592 (void) ds_file_munmap(ds_file);
593
594 if (ds_file->file) {
595 ctf_fs_file_destroy(ds_file->file);
596 }
597
598 g_free(ds_file);
599 }
600
601 BT_HIDDEN
602 struct bt_notification_iterator_next_return ctf_fs_ds_file_next(
603 struct ctf_fs_ds_file *ds_file)
604 {
605 enum bt_ctf_notif_iter_status notif_iter_status;
606 struct bt_notification_iterator_next_return ret = {
607 .status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR,
608 .notification = NULL,
609 };
610
611 notif_iter_status = bt_ctf_notif_iter_get_next_notification(
612 ds_file->notif_iter, ds_file->cc_prio_map, &ret.notification);
613
614 switch (notif_iter_status) {
615 case BT_CTF_NOTIF_ITER_STATUS_EOF:
616 ret.status = BT_NOTIFICATION_ITERATOR_STATUS_END;
617 break;
618 case BT_CTF_NOTIF_ITER_STATUS_OK:
619 ret.status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
620 break;
621 case BT_CTF_NOTIF_ITER_STATUS_AGAIN:
622 /*
623 * Should not make it this far as this is
624 * medium-specific; there is nothing for the user to do
625 * and it should have been handled upstream.
626 */
627 abort();
628 case BT_CTF_NOTIF_ITER_STATUS_INVAL:
629 case BT_CTF_NOTIF_ITER_STATUS_ERROR:
630 default:
631 ret.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
632 break;
633 }
634
635 return ret;
636 }
637
638 BT_HIDDEN
639 int ctf_fs_ds_file_get_packet_header_context_fields(
640 struct ctf_fs_ds_file *ds_file,
641 struct bt_ctf_field **packet_header_field,
642 struct bt_ctf_field **packet_context_field)
643 {
644 enum bt_ctf_notif_iter_status notif_iter_status;
645 int ret = 0;
646
647 assert(ds_file);
648 notif_iter_status = bt_ctf_notif_iter_get_packet_header_context_fields(
649 ds_file->notif_iter, packet_header_field, packet_context_field);
650 switch (notif_iter_status) {
651 case BT_CTF_NOTIF_ITER_STATUS_EOF:
652 case BT_CTF_NOTIF_ITER_STATUS_OK:
653 break;
654 case BT_CTF_NOTIF_ITER_STATUS_AGAIN:
655 abort();
656 case BT_CTF_NOTIF_ITER_STATUS_INVAL:
657 case BT_CTF_NOTIF_ITER_STATUS_ERROR:
658 default:
659 goto error;
660 break;
661 }
662
663 goto end;
664
665 error:
666 ret = -1;
667
668 if (packet_header_field) {
669 bt_put(*packet_header_field);
670 }
671
672 if (packet_context_field) {
673 bt_put(*packet_context_field);
674 }
675
676 end:
677 return ret;
678 }
679
680 BT_HIDDEN
681 void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index)
682 {
683 if (!index) {
684 return;
685 }
686
687 if (index->entries) {
688 g_array_free(index->entries, TRUE);
689 }
690 g_free(index);
691 }
This page took 0.041483 seconds and 3 git commands to generate.