From 8f8e3a43d749a35a231a29d80c2bcb3d70c1d361 Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Sun, 16 Nov 2025 15:56:17 +0000 Subject: [PATCH] glocalfile: Complain if `faccessat` sets an unusual error Many libc implementations seem to be incompatible with this optimisation. Printing an error when the error is either `EINVAL` or `EBADF` should make it easier to identify any more problematic platforms. --- gio/glocalfile.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gio/glocalfile.c b/gio/glocalfile.c index e026bed37..64e2de691 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -1280,7 +1280,19 @@ g_local_file_query_exists (GFile *file, { GLocalFile *local = G_LOCAL_FILE (file); - return faccessat (0, local->filename, F_OK, AT_EACCESS | AT_SYMLINK_NOFOLLOW) == 0; + if (faccessat (0, local->filename, F_OK, AT_EACCESS | AT_SYMLINK_NOFOLLOW) == 0) + return TRUE; + + if G_UNLIKELY (errno == EBADF) + { + g_critical ("g_local_file_query_exists: faccessat didn't accept supplied dirfd"); + } + else if G_UNLIKELY (errno == EINVAL) + { + g_critical ("g_local_file_query_exists: faccessat doesn't support supplied flags"); + } + + return FALSE; } #endif