gio: Allow no atime from statx

statx does not provide stx_atime when querying a file in a read-only
mounted file system. So call to statx should not expect it to be in
the mask. Otherwise we would fail with ERANGE for querying any file in
a read-only file system.

Fixes #2189.
This commit is contained in:
Valentin David 2020-08-23 16:41:17 +02:00
parent 153ec62e7e
commit 6fc143bba8
No known key found for this signature in database
GPG Key ID: 1496F0F95959AB6E

View File

@ -1026,12 +1026,15 @@ set_info_from_stat (GFileInfo *info,
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_USEC, _g_stat_mtim_nsec (statbuf) / 1000);
#endif
if (_g_stat_has_field (statbuf, G_LOCAL_FILE_STAT_FIELD_ATIME))
{
_g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS, _g_stat_atime (statbuf));
#if defined (HAVE_STRUCT_STAT_ST_ATIMENSEC)
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS_USEC, statbuf->st_atimensec / 1000);
#elif defined (HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC)
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS_USEC, _g_stat_atim_nsec (statbuf) / 1000);
#endif
}
#endif
#ifndef G_OS_WIN32
@ -1805,7 +1808,7 @@ _g_local_file_info_get (const char *basename,
res = g_local_file_lstat (path,
G_LOCAL_FILE_STAT_FIELD_BASIC_STATS | G_LOCAL_FILE_STAT_FIELD_BTIME,
G_LOCAL_FILE_STAT_FIELD_ALL & (~G_LOCAL_FILE_STAT_FIELD_BTIME),
G_LOCAL_FILE_STAT_FIELD_ALL & (~G_LOCAL_FILE_STAT_FIELD_BTIME) & (~G_LOCAL_FILE_STAT_FIELD_ATIME),
&statbuf);
if (res == -1)