With many files, it is useful to know the cause of open errors, e.g.
File stream openat(): Too many open files
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
* \0). This is the allocated size, not the actual string size.
*/
out = open_memstream(buf, &size);
* \0). This is the allocated size, not the actual string size.
*/
out = open_memstream(buf, &size);
+ if (out == NULL) {
+ perror("Metadata open_memstream");
for (;;) {
ret = ctf_open_trace_metadata_packet_read(td, in, out);
if (ret) {
for (;;) {
ret = ctf_open_trace_metadata_packet_read(td, in, out);
if (ret) {
fclose(in);
/* open for reading */
*fp = fmemopen(*buf, strlen(*buf), "rb");
fclose(in);
/* open for reading */
*fp = fmemopen(*buf, strlen(*buf), "rb");
+ if (!*fp) {
+ perror("Metadata fmemopen");
+ return -errno;
+ }
fp = fdopen(metadata_stream->pos.fd, "r");
if (!fp) {
fprintf(stdout, "[error] Unable to open metadata stream.\n");
fp = fdopen(metadata_stream->pos.fd, "r");
if (!fp) {
fprintf(stdout, "[error] Unable to open metadata stream.\n");
+ perror("Metadata stream open");
ret = -errno;
goto end_stream;
}
ret = -errno;
goto end_stream;
}
struct ctf_file_stream *file_stream;
ret = openat(td->dirfd, path, flags);
struct ctf_file_stream *file_stream;
ret = openat(td->dirfd, path, flags);
+ if (ret < 0) {
+ perror("File stream openat()");
file_stream = g_new0(struct ctf_file_stream, 1);
if (move_pos_slow) {
file_stream = g_new0(struct ctf_file_stream, 1);
if (move_pos_slow) {
td->dirfd = open(path, 0);
if (td->dirfd < 0) {
fprintf(stdout, "[error] Unable to open trace directory file descriptor.\n");
td->dirfd = open(path, 0);
if (td->dirfd < 0) {
fprintf(stdout, "[error] Unable to open trace directory file descriptor.\n");
+ perror("Trace directory open");
+ ret = -errno;