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.
This commit is contained in:
Colin Kinloch
2025-11-16 15:56:17 +00:00
parent 298fa45f90
commit 8f8e3a43d7

View File

@@ -1280,7 +1280,19 @@ g_local_file_query_exists (GFile *file,
{ {
GLocalFile *local = G_LOCAL_FILE (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 #endif