From 6d0d11a57c03c157f14b33b79d800e9af7e1fc9c Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 21 Oct 2019 16:09:19 -0400 Subject: [PATCH] src.ctf.fs: append error causes in ctf_fs_file_open I hit an fopen failure in ctf_fs_file_open and noticed we were missing some error causes for the message to be precise. This patch adds them. This is the result I now get when fopen fails: ... CAUSED BY [auto-disc-source-ctf-fs-37: 'source.ctf.fs'] (/home/smarchi/src/babeltrace/src/plugins/ctf/fs-src/file.c:98) Cannot open file: Too many open files: path=/tmp/lttng-traces/000300/mon_10.196.130.21-20180202-144403/ust/uid/0/64-bit/ch-1_4, mode=rb Change-Id: I4dae278695b56cbedc9c7e3e5a67bc60fe6584d7 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2230 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- src/plugins/ctf/fs-src/file.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/ctf/fs-src/file.c b/src/plugins/ctf/fs-src/file.c index 9c116782..2191b671 100644 --- a/src/plugins/ctf/fs-src/file.c +++ b/src/plugins/ctf/fs-src/file.c @@ -93,15 +93,18 @@ int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode) BT_COMP_LOGI("Opening file \"%s\" with mode \"%s\"", file->path->str, mode); file->fp = fopen(file->path->str, mode); if (!file->fp) { - BT_COMP_LOGE("Cannot open file \"%s\" with mode \"%s\": %s", - file->path->str, mode, strerror(errno)); + BT_COMP_LOGE_APPEND_CAUSE_ERRNO(file->self_comp, + "Cannot open file", ": path=%s, mode=%s", + file->path->str, mode); goto error; } BT_COMP_LOGI("Opened file: %p", file->fp); if (fstat(fileno(file->fp), &stat)) { - BT_COMP_LOGE("Cannot get file information: %s", strerror(errno)); + BT_COMP_LOGE_APPEND_CAUSE_ERRNO(file->self_comp, + "Cannot get file information", + ": path=%s", file->path->str); goto error; } -- 2.34.1