There are expected situtations in which CTF producers (like LTTng) can
generate empty CTF trace files. The current babeltrace behavior is to
trigger an error when an empty file is encountered. Change this to allow
reading the rest of the trace anyway.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ret = 0;
goto fd_is_dir_ok;
}
+ if (!statbuf.st_size) {
+ /** Skip empty files. */
+ ret = 0;
+ goto fd_is_empty_file;
+ }
file_stream = g_new0(struct ctf_file_stream, 1);
file_stream->pos.last_offset = LAST_OFFSET_POISON;
index_name = malloc((strlen(path) + sizeof(INDEX_PATH)) * sizeof(char));
if (!index_name) {
fprintf(stderr, "[error] Cannot allocate index filename\n");
+ ret = -ENOMEM;
goto error_def;
}
snprintf(index_name, strlen(path) + sizeof(INDEX_PATH),
fprintf(stderr, "Error on ctf_fini_pos\n");
}
g_free(file_stream);
+fd_is_empty_file:
fd_is_dir_ok:
fstat_error:
closeret = close(fd);