Backport fix for GGO #2189 (error accessing some filesystems)

Upstream commit refers only to read-only filesystems, but the
bug also affects CIFS shares (and this patch fixes that case
too).
This commit is contained in:
Adam Williamson 2020-08-25 11:55:46 -07:00
parent 683c99b0e4
commit c3df0e5227
2 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From 6fc143bba81a02cac0ca6bc47e8249b65ffc0ad9 Mon Sep 17 00:00:00 2001
From: Valentin David <valentin.david@codethink.co.uk>
Date: Sun, 23 Aug 2020 16:41:17 +0200
Subject: [PATCH] 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.
---
gio/glocalfileinfo.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index a34c1b78a..0690e1da2 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -1025,13 +1025,16 @@ set_info_from_stat (GFileInfo *info,
#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_USEC, _g_stat_mtim_nsec (statbuf) / 1000);
#endif
-
- _g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS, _g_stat_atime (statbuf));
+
+ 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);
+ _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);
+ _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)
--
2.28.0

View File

@ -1,6 +1,6 @@
Name: glib2
Version: 2.65.2
Release: 2%{?dist}
Release: 3%{?dist}
Summary: A library of handy utility functions
License: LGPLv2+
@ -9,6 +9,11 @@ Source0: http://download.gnome.org/sources/glib/2.65/glib-%{version}.tar.xz
# Avoid requiring a too new gtk-doc version for building glib
Patch0: gtk-doc-1-32.patch
# Fixes errors accessing read-only file systems (and possibly CIFS
# shares)
# https://gitlab.gnome.org/GNOME/glib/-/issues/2189
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1630
Patch1: 0001-gio-Allow-no-atime-from-statx.patch
BuildRequires: chrpath
BuildRequires: gcc
@ -217,6 +222,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_datadir}/installed-tests
%changelog
* Tue Aug 25 2020 Adam Williamson <awilliam@redhat.com> - 2.65.2-3
- Backport fix for GGO #2189 (error accessing some filesystems)
* Thu Aug 20 2020 Jeff Law <law@redhat.com> - 2.65.2-2
- Re-enable LTO