*
* Format registration.
*
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#include <babeltrace/format.h>
#include <babeltrace/ctf/types.h>
#include <babeltrace/ctf/metadata.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
#include <inttypes.h>
#include <stdio.h>
#include <uuid/uuid.h>
extern int yydebug;
static
-struct trace_descriptor *ctf_open_trace(const char *path, int flags);
+struct trace_descriptor *ctf_open_trace(const char *path, int flags,
+ void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
+ int whence), FILE *metadata_fp);
static
void ctf_close_trace(struct trace_descriptor *descriptor);
integer_definition->declaration;
uint64_t oldval, newval, updateval;
- if (integer_declaration->len == 64) {
+ if (unlikely(integer_declaration->len == 64)) {
stream->timestamp = integer_definition->value._unsigned;
return;
}
struct ctf_stream_pos *pos =
container_of(ppos, struct ctf_stream_pos, parent);
struct ctf_stream_class *stream_class = stream->stream_class;
- struct ctf_file_event *event;
+ struct ctf_stream_event *event;
uint64_t id = 0;
int ret;
- if (pos->offset == EOF)
+ /* We need to check for EOF here for empty files. */
+ if (unlikely(pos->offset == EOF))
+ return EOF;
+
+ ctf_pos_get_event(pos);
+
+ /*
+ * This is the EOF check after we've advanced the position in
+ * ctf_pos_get_event.
+ */
+ if (unlikely(pos->offset == EOF))
return EOF;
+ assert(pos->offset < pos->content_size);
/* Read event header */
- if (stream->stream_event_header) {
+ if (likely(stream->stream_event_header)) {
struct definition_integer *integer_definition;
struct definition *variant;
ret = generic_rw(ppos, &stream->stream_event_header->p);
- if (ret)
+ if (unlikely(ret))
goto error;
/* lookup event id */
integer_definition = lookup_integer(&stream->stream_event_header->p, "id", FALSE);
id = integer_definition->value._unsigned;
}
}
+ stream->event_id = id;
/* lookup timestamp */
+ stream->has_timestamp = 0;
integer_definition = lookup_integer(&stream->stream_event_header->p, "timestamp", FALSE);
if (integer_definition) {
ctf_update_timestamp(stream, integer_definition);
+ stream->has_timestamp = 1;
} else {
if (variant) {
integer_definition = lookup_integer(variant, "timestamp", FALSE);
if (integer_definition) {
ctf_update_timestamp(stream, integer_definition);
+ stream->has_timestamp = 1;
}
}
}
goto error;
}
- if (id >= stream_class->events_by_id->len) {
+ if (unlikely(id >= stream_class->events_by_id->len)) {
fprintf(stdout, "[error] Event id %" PRIu64 " is outside range.\n", id);
return -EINVAL;
}
event = g_ptr_array_index(stream->events_by_id, id);
- if (!event) {
+ if (unlikely(!event)) {
fprintf(stdout, "[error] Event id %" PRIu64 " is unknown.\n", id);
return -EINVAL;
}
}
/* Read event payload */
- if (event->event_fields) {
+ if (likely(event->event_fields)) {
ret = generic_rw(ppos, &event->event_fields->p);
if (ret)
goto error;
int ctf_write_event(struct stream_pos *pos, struct ctf_stream *stream)
{
struct ctf_stream_class *stream_class = stream->stream_class;
- struct ctf_file_event *event;
- uint64_t id = 0;
+ struct ctf_stream_event *event;
+ uint64_t id;
int ret;
- /* print event header */
- if (stream->stream_event_header) {
- struct definition_integer *integer_definition;
- struct definition *variant;
-
- /* lookup event id */
- integer_definition = lookup_integer(&stream->stream_event_header->p, "id", FALSE);
- if (integer_definition) {
- id = integer_definition->value._unsigned;
- } else {
- struct definition_enum *enum_definition;
-
- enum_definition = lookup_enum(&stream->stream_event_header->p, "id", FALSE);
- if (enum_definition) {
- id = enum_definition->integer->value._unsigned;
- }
- }
-
- variant = lookup_variant(&stream->stream_event_header->p, "v");
- if (variant) {
- integer_definition = lookup_integer(variant, "id", FALSE);
- if (integer_definition) {
- id = integer_definition->value._unsigned;
- }
- }
+ id = stream->event_id;
+ /* print event header */
+ if (likely(stream->stream_event_header)) {
ret = generic_rw(pos, &stream->stream_event_header->p);
if (ret)
goto error;
goto error;
}
- if (id >= stream_class->events_by_id->len) {
+ if (unlikely(id >= stream_class->events_by_id->len)) {
fprintf(stdout, "[error] Event id %" PRIu64 " is outside range.\n", id);
return -EINVAL;
}
event = g_ptr_array_index(stream->events_by_id, id);
- if (!event) {
+ if (unlikely(!event)) {
fprintf(stdout, "[error] Event id %" PRIu64 " is unknown.\n", id);
return -EINVAL;
}
}
/* Read and print event payload */
- if (event->event_fields) {
+ if (likely(event->event_fields)) {
ret = generic_rw(pos, &event->event_fields->p);
if (ret)
goto error;
assert(off >= 0);
pos->offset = 0;
} else {
+ read_next_packet:
switch (whence) {
case SEEK_CUR:
+ if (pos->offset == EOF)
+ return;
/* The reader will expect us to skip padding */
assert(pos->offset + offset == pos->content_size);
++pos->cur_index;
pos->mmap_offset = index->offset;
/* Lookup context/packet size in index */
- file_stream->stream.timestamp = index->timestamp_begin;
+ file_stream->parent.timestamp = index->timestamp_begin;
pos->content_size = index->content_size;
pos->packet_size = index->packet_size;
- if (index->data_offset < index->content_size)
+ if (index->data_offset < index->content_size) {
pos->offset = 0; /* will read headers */
- else {
+ } else if (index->data_offset == index->content_size) {
+ /* empty packet */
+ pos->offset = index->data_offset;
+ offset = 0;
+ whence = SEEK_CUR;
+ goto read_next_packet;
+ } else {
pos->offset = EOF;
return;
}
}
/* update trace_packet_header and stream_packet_context */
- if (file_stream->stream.trace_packet_header) {
+ if (pos->prot != PROT_WRITE && file_stream->parent.trace_packet_header) {
/* Read packet header */
- ret = generic_rw(&pos->parent, &file_stream->stream.trace_packet_header->p);
+ ret = generic_rw(&pos->parent, &file_stream->parent.trace_packet_header->p);
assert(!ret);
}
- if (file_stream->stream.stream_packet_context) {
+ if (pos->prot != PROT_WRITE && file_stream->parent.stream_packet_context) {
/* Read packet context */
- ret = generic_rw(&pos->parent, &file_stream->stream.stream_packet_context->p);
+ ret = generic_rw(&pos->parent, &file_stream->parent.stream_packet_context->p);
assert(!ret);
}
}
if (magic == TSDL_MAGIC) {
ret = 1;
td->byte_order = BYTE_ORDER;
+ CTF_TRACE_SET_FIELD(td, byte_order);
} else if (magic == GUINT32_SWAP_LE_BE(TSDL_MAGIC)) {
ret = 1;
td->byte_order = (BYTE_ORDER == BIG_ENDIAN) ?
LITTLE_ENDIAN : BIG_ENDIAN;
+ CTF_TRACE_SET_FIELD(td, byte_order);
}
- CTF_TRACE_SET_FIELD(td, byte_order);
end:
rewind(fp);
return ret;
}
+/*
+ * Returns 0 on success, -1 on error.
+ */
+static
+int check_version(unsigned int major, unsigned int minor)
+{
+ switch (major) {
+ case 1:
+ switch (minor) {
+ case 8:
+ return 0;
+ default:
+ goto warning;
+ }
+ default:
+ goto warning;
+
+ }
+
+ /* eventually return an error instead of warning */
+warning:
+ fprintf(stdout, "[warning] Unsupported CTF specification version %u.%u. Trying anyway.\n",
+ major, minor);
+ return 0;
+}
+
static
int ctf_open_trace_metadata_packet_read(struct ctf_trace *td, FILE *in,
FILE *out)
header.checksum_scheme);
return -EINVAL;
}
+ if (check_version(header.major, header.minor) < 0)
+ return -EINVAL;
if (!CTF_TRACE_FIELD_IS_SET(td, uuid)) {
memcpy(td->uuid, header.uuid, sizeof(header.uuid));
CTF_TRACE_SET_FIELD(td, uuid);
toread -= readlen;
if (!toread) {
ret = 0; /* continue reading next packet */
- break;
+ goto read_padding;
}
}
return ret;
+
+read_padding:
+ toread = (header.packet_size - header.content_size) / CHAR_BIT;
+ ret = fseek(in, toread, SEEK_CUR);
+ if (ret < 0) {
+ fprintf(stdout, "[warning] Missing padding at end of file\n");
+ ret = 0;
+ }
+ return ret;
}
static
}
static
-int ctf_open_trace_metadata_read(struct ctf_trace *td)
+int ctf_open_trace_metadata_read(struct ctf_trace *td,
+ void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
+ int whence), FILE *metadata_fp)
{
struct ctf_scanner *scanner;
+ struct ctf_file_stream *metadata_stream;
FILE *fp;
char *buf = NULL;
int ret = 0;
- td->metadata.pos.fd = openat(td->dirfd, "metadata", O_RDONLY);
- if (td->metadata.pos.fd < 0) {
- fprintf(stdout, "Unable to open metadata.\n");
- return td->metadata.pos.fd;
+ metadata_stream = g_new0(struct ctf_file_stream, 1);
+
+ if (move_pos_slow) {
+ metadata_stream->pos.move_pos_slow = move_pos_slow;
+ } else {
+ fprintf(stderr, "[error] move_pos_slow function undefined.\n");
+ ret = -1;
+ goto end_stream;
}
- if (babeltrace_debug)
- yydebug = 1;
+ if (metadata_fp) {
+ fp = metadata_fp;
+ } else {
+ td->metadata = &metadata_stream->parent;
+ metadata_stream->pos.fd = openat(td->dirfd, "metadata", O_RDONLY);
+ if (metadata_stream->pos.fd < 0) {
+ fprintf(stdout, "Unable to open metadata.\n");
+ return metadata_stream->pos.fd;
+ }
- fp = fdopen(td->metadata.pos.fd, "r");
- if (!fp) {
- fprintf(stdout, "[error] Unable to open metadata stream.\n");
- ret = -errno;
- goto end_stream;
+ fp = fdopen(metadata_stream->pos.fd, "r");
+ if (!fp) {
+ fprintf(stdout, "[error] Unable to open metadata stream.\n");
+ ret = -errno;
+ goto end_stream;
+ }
}
+ if (babeltrace_debug)
+ yydebug = 1;
if (packet_metadata(td, fp)) {
ret = ctf_open_trace_metadata_stream_read(td, &fp, &buf);
if (ret)
goto end_packet_read;
+ } else {
+ unsigned int major, minor;
+ ssize_t nr_items;
+
+ td->byte_order = BYTE_ORDER;
+
+ /* Check text-only metadata header and version */
+ nr_items = fscanf(fp, "/* CTF %u.%u", &major, &minor);
+ if (nr_items < 2)
+ fprintf(stdout, "[warning] Ill-shapen or missing \"/* CTF x.y\" header for text-only metadata.\n");
+ if (check_version(major, minor) < 0) {
+ ret = -EINVAL;
+ goto end_packet_read;
+ }
+ rewind(fp);
}
scanner = ctf_scanner_alloc(fp);
goto end;
}
ret = ctf_visitor_construct_metadata(stdout, 0, &scanner->ast->root,
- td, BYTE_ORDER);
+ td, td->byte_order);
if (ret) {
fprintf(stdout, "[error] Error in CTF metadata constructor %d\n", ret);
goto end;
fclose(fp);
free(buf);
end_stream:
- close(td->metadata.pos.fd);
+ close(metadata_stream->pos.fd);
+ if (ret)
+ g_free(metadata_stream);
return ret;
}
static
-struct ctf_file_event *create_event_definitions(struct ctf_trace *td,
- struct ctf_stream *stream,
- struct ctf_event *event)
+struct ctf_stream_event *create_event_definitions(struct ctf_trace *td,
+ struct ctf_stream *stream,
+ struct ctf_event *event)
{
- struct ctf_file_event *file_event = g_new0(struct ctf_file_event, 1);
+ struct ctf_stream_event *stream_event = g_new0(struct ctf_stream_event, 1);
if (event->context_decl) {
struct definition *definition =
if (!definition) {
goto error;
}
- file_event->event_context = container_of(definition,
+ stream_event->event_context = container_of(definition,
struct definition_struct, p);
- stream->parent_def_scope = file_event->event_context->p.scope;
+ stream->parent_def_scope = stream_event->event_context->p.scope;
}
if (event->fields_decl) {
struct definition *definition =
if (!definition) {
goto error;
}
- file_event->event_fields = container_of(definition,
+ stream_event->event_fields = container_of(definition,
struct definition_struct, p);
- stream->parent_def_scope = file_event->event_fields->p.scope;
+ stream->parent_def_scope = stream_event->event_fields->p.scope;
}
- return file_event;
+ return stream_event;
error:
- if (file_event->event_fields)
- definition_unref(&file_event->event_fields->p);
- if (file_event->event_context)
- definition_unref(&file_event->event_context->p);
+ if (stream_event->event_fields)
+ definition_unref(&stream_event->event_fields->p);
+ if (stream_event->event_context)
+ definition_unref(&stream_event->event_context->p);
return NULL;
}
g_ptr_array_set_size(stream->events_by_id, stream_class->events_by_id->len);
for (i = 0; i < stream->events_by_id->len; i++) {
struct ctf_event *event = g_ptr_array_index(stream_class->events_by_id, i);
- struct ctf_file_event *file_event;
+ struct ctf_stream_event *stream_event;
if (!event)
continue;
- file_event = create_event_definitions(td, stream, event);
- if (!file_event)
+ stream_event = create_event_definitions(td, stream, event);
+ if (!stream_event)
goto error_event;
- g_ptr_array_index(stream->events_by_id, i) = file_event;
+ g_ptr_array_index(stream->events_by_id, i) = stream_event;
}
return 0;
error_event:
for (i = 0; i < stream->events_by_id->len; i++) {
- struct ctf_file_event *file_event = g_ptr_array_index(stream->events_by_id, i);
- if (file_event)
- g_free(file_event);
+ struct ctf_stream_event *stream_event = g_ptr_array_index(stream->events_by_id, i);
+ if (stream_event)
+ g_free(stream_event);
}
g_ptr_array_free(stream->events_by_id, TRUE);
error:
packet_index.timestamp_end = 0;
/* read and check header, set stream id (and check) */
- if (file_stream->stream.trace_packet_header) {
+ if (file_stream->parent.trace_packet_header) {
/* Read packet header */
- ret = generic_rw(&pos->parent, &file_stream->stream.trace_packet_header->p);
+ ret = generic_rw(&pos->parent, &file_stream->parent.trace_packet_header->p);
if (ret)
return ret;
- len_index = struct_declaration_lookup_field_index(file_stream->stream.trace_packet_header->declaration, g_quark_from_static_string("magic"));
+ len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("magic"));
if (len_index >= 0) {
struct definition_integer *defint;
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->stream.trace_packet_header, len_index);
+ field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
assert(field->declaration->id == CTF_TYPE_INTEGER);
defint = container_of(field, struct definition_integer, p);
assert(defint->declaration->signedness == FALSE);
}
/* check uuid */
- len_index = struct_declaration_lookup_field_index(file_stream->stream.trace_packet_header->declaration, g_quark_from_static_string("uuid"));
+ len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("uuid"));
if (len_index >= 0) {
struct definition_array *defarray;
struct definition *field;
uint64_t i;
uint8_t uuidval[UUID_LEN];
- field = struct_definition_get_field_from_index(file_stream->stream.trace_packet_header, len_index);
+ field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
assert(field->declaration->id == CTF_TYPE_ARRAY);
defarray = container_of(field, struct definition_array, p);
assert(array_len(defarray) == UUID_LEN);
}
- len_index = struct_declaration_lookup_field_index(file_stream->stream.trace_packet_header->declaration, g_quark_from_static_string("stream_id"));
+ len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("stream_id"));
if (len_index >= 0) {
struct definition_integer *defint;
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->stream.trace_packet_header, len_index);
+ field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
assert(field->declaration->id == CTF_TYPE_INTEGER);
defint = container_of(field, struct definition_integer, p);
assert(defint->declaration->signedness == FALSE);
}
}
- if (!first_packet && file_stream->stream_id != stream_id) {
+ if (!first_packet && file_stream->parent.stream_id != stream_id) {
fprintf(stdout, "[error] Stream ID is changing within a stream.\n");
return -EINVAL;
}
if (first_packet) {
- file_stream->stream_id = stream_id;
+ file_stream->parent.stream_id = stream_id;
if (stream_id >= td->streams->len) {
fprintf(stdout, "[error] Stream %" PRIu64 " is not declared in metadata.\n", stream_id);
return -EINVAL;
fprintf(stdout, "[error] Stream %" PRIu64 " is not declared in metadata.\n", stream_id);
return -EINVAL;
}
- file_stream->stream.stream_class = stream;
+ file_stream->parent.stream_class = stream;
+ ret = create_stream_definitions(td, &file_stream->parent);
+ if (ret)
+ return ret;
}
first_packet = 0;
- ret = create_stream_definitions(td, &file_stream->stream);
- if (ret)
- return ret;
-
- if (file_stream->stream.stream_packet_context) {
+ if (file_stream->parent.stream_packet_context) {
/* Read packet context */
- ret = generic_rw(&pos->parent, &file_stream->stream.stream_packet_context->p);
+ ret = generic_rw(&pos->parent, &file_stream->parent.stream_packet_context->p);
if (ret)
return ret;
/* read content size from header */
- len_index = struct_declaration_lookup_field_index(file_stream->stream.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
+ len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
if (len_index >= 0) {
struct definition_integer *defint;
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->stream.stream_packet_context, len_index);
+ field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
assert(field->declaration->id == CTF_TYPE_INTEGER);
defint = container_of(field, struct definition_integer, p);
assert(defint->declaration->signedness == FALSE);
}
/* read packet size from header */
- len_index = struct_declaration_lookup_field_index(file_stream->stream.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
+ len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
if (len_index >= 0) {
struct definition_integer *defint;
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->stream.stream_packet_context, len_index);
+ field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
assert(field->declaration->id == CTF_TYPE_INTEGER);
defint = container_of(field, struct definition_integer, p);
assert(defint->declaration->signedness == FALSE);
}
/* read timestamp begin from header */
- len_index = struct_declaration_lookup_field_index(file_stream->stream.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin"));
+ len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin"));
if (len_index >= 0) {
struct definition_integer *defint;
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->stream.stream_packet_context, len_index);
+ field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
assert(field->declaration->id == CTF_TYPE_INTEGER);
defint = container_of(field, struct definition_integer, p);
assert(defint->declaration->signedness == FALSE);
}
/* read timestamp end from header */
- len_index = struct_declaration_lookup_field_index(file_stream->stream.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end"));
+ len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end"));
if (len_index >= 0) {
struct definition_integer *defint;
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->stream.stream_packet_context, len_index);
+ field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
assert(field->declaration->id == CTF_TYPE_INTEGER);
defint = container_of(field, struct definition_integer, p);
assert(defint->declaration->signedness == FALSE);
if (packet_index.packet_size > (filestats.st_size - packet_index.offset) * CHAR_BIT) {
fprintf(stdout, "[error] Packet size (%zu bits) is larger than remaining file size (%zu bits).\n",
- packet_index.content_size, (filestats.st_size - packet_index.offset) * CHAR_BIT);
+ packet_index.content_size, (size_t) (filestats.st_size - packet_index.offset) * CHAR_BIT);
return -EINVAL;
}
* description (metadata).
*/
static
-int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags)
+int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags,
+ void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
+ int whence))
{
int ret;
struct ctf_file_stream *file_stream;
if (ret < 0)
goto error;
file_stream = g_new0(struct ctf_file_stream, 1);
+
+ if (move_pos_slow) {
+ file_stream->pos.move_pos_slow = move_pos_slow;
+ } else {
+ fprintf(stderr, "[error] move_pos_slow function undefined.\n");
+ ret = -1;
+ goto error_def;
+ }
+
ctf_init_pos(&file_stream->pos, ret, flags);
- ret = create_trace_definitions(td, &file_stream->stream);
+ ret = create_trace_definitions(td, &file_stream->parent);
if (ret)
goto error_def;
ret = create_stream_packet_index(td, file_stream);
if (ret)
goto error_index;
/* Add stream file to stream class */
- g_ptr_array_add(file_stream->stream.stream_class->files, file_stream);
+ g_ptr_array_add(file_stream->parent.stream_class->streams,
+ &file_stream->parent);
return 0;
error_index:
- if (file_stream->stream.trace_packet_header)
- definition_unref(&file_stream->stream.trace_packet_header->p);
+ if (file_stream->parent.trace_packet_header)
+ definition_unref(&file_stream->parent.trace_packet_header->p);
error_def:
ctf_fini_pos(&file_stream->pos);
close(file_stream->pos.fd);
}
static
-int ctf_open_trace_read(struct ctf_trace *td, const char *path, int flags)
+int ctf_open_trace_read(struct ctf_trace *td, const char *path, int flags,
+ void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
+ int whence), FILE *metadata_fp)
{
int ret;
struct dirent *dirent;
* Keep the metadata file separate.
*/
- ret = ctf_open_trace_metadata_read(td);
+ ret = ctf_open_trace_metadata_read(td, move_pos_slow, metadata_fp);
if (ret) {
goto error_metadata;
}
|| !strcmp(diriter->d_name, "..")
|| !strcmp(diriter->d_name, "metadata"))
continue;
- ret = ctf_open_file_stream_read(td, diriter->d_name, flags);
+ ret = ctf_open_file_stream_read(td, diriter->d_name, flags, move_pos_slow);
if (ret) {
fprintf(stdout, "[error] Open file stream error.\n");
goto readdir_error;
}
static
-struct trace_descriptor *ctf_open_trace(const char *path, int flags)
+struct trace_descriptor *ctf_open_trace(const char *path, int flags,
+ void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
+ int whence), FILE *metadata_fp)
{
struct ctf_trace *td;
int ret;
fprintf(stdout, "[error] Path missing for input CTF trace.\n");
goto error;
}
- ret = ctf_open_trace_read(td, path, flags);
+ ret = ctf_open_trace_read(td, path, flags, move_pos_slow, metadata_fp);
if (ret)
goto error;
break;
stream = g_ptr_array_index(td->streams, i);
if (!stream)
continue;
- for (j = 0; j < stream->files->len; j++) {
+ for (j = 0; j < stream->streams->len; j++) {
struct ctf_file_stream *file_stream;
- file_stream = g_ptr_array_index(stream->files, j);
+ file_stream = container_of(g_ptr_array_index(stream->streams, j), struct ctf_file_stream, parent);
ctf_close_file_stream(file_stream);
}