From: Kienan Stewart Date: Mon, 15 Apr 2024 19:15:28 +0000 (-0400) Subject: lttng: Indicate file path and error reason when open_config fails X-Git-Url: http://git.lttng.org./?a=commitdiff_plain;h=dcffe9462d11f9de5b441b801da5b2b7ae42c79a;hp=dcffe9462d11f9de5b441b801da5b2b7ae42c79a;p=lttng-tools.git lttng: Indicate file path and error reason when open_config fails Observed issue ============== In a test environment where the configuration file had been chowned to no longer be writeable by the current user, `lttng` commands would work but return a non-zero exit code and print `Error: Unable to create config file`. This doesn't give the user much information to work with to address the issue. Solution ======== The `PWARN` macro is used to print the file_path and reason when the call to `fopen` fails. This is done since the `file_path` percolated up to where the existing error message is may be null for multiple reasons (eg. allocation failure). Known drawbacks =============== The output of `PWARN` is inconsistent with the output used for most of the `lttng` client. Eg. ``` $ lttng create Spawning a session daemon Session auto-20240415-151450 created. Traces will be output to /home/lttng-traces/auto-20240415-151450 PWARN - 15:14:50.420628389 [1184515/1184515]: fopen '/home/.lttngrc': Permission denied (in open_config() at conf.cpp:57) Error: Unable to create config file ``` Change-Id: I5a9253fb02f3a712e7c5c2567311920dc33d36c7 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau ---