From 39ff1fa4d5687c82f738a97571e34f9c2f9736d1 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Fri, 19 Feb 2021 18:24:33 +0000 Subject: [PATCH] resolve-in-sysroot: Produce better diagnostics on failure to open If we pass in SRT_RESOLVE_FLAGS_READABLE or SRT_RESOLVE_FLAGS_DIRECTORY, and something goes wrong while we are opening the file, then the best diagnostics libglnx can give us will be something like "openat(/proc/self/fd/21): <strerror result>", which is not very informative. Adding current_path turns this into something more like "Unable to open "foo/bar": openat(/proc/self/fd/21): <strerror result>", which gives us more hope of figuring it out. I originally suspected this was the error path being hit in <https://github.com/ValveSoftware/steam-runtime/issues/366>, but now I think it probably isn't. Signed-off-by: Simon McVittie <smcv@collabora.com> --- steam-runtime-tools/resolve-in-sysroot.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/steam-runtime-tools/resolve-in-sysroot.c b/steam-runtime-tools/resolve-in-sysroot.c index 21965157e..c4dbb581d 100644 --- a/steam-runtime-tools/resolve-in-sysroot.c +++ b/steam-runtime-tools/resolve-in-sysroot.c @@ -313,12 +313,20 @@ _srt_resolve_in_sysroot (int sysroot, if (flags & SRT_RESOLVE_FLAGS_DIRECTORY) { if (!glnx_opendirat (-1, proc_fd_name, TRUE, &fd, error)) - return -1; + { + g_prefix_error (error, "Unable to open \"%s\" as directory: ", + current_path->str); + return -1; + } } else { if (!glnx_openat_rdonly (-1, proc_fd_name, TRUE, &fd, error)) - return -1; + { + g_prefix_error (error, "Unable to open \"%s\": ", + current_path->str); + return -1; + } } if (real_path_out != NULL) -- GitLab