summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2020-09-15 10:08:14 +0100
committerSimon McVittie <smcv@collabora.com>2020-09-15 10:09:46 +0100
commit642baa50fa561f7abfbbfe5ac9a10351a706b95a (patch)
tree31ac131bbfd4fa95ad041666ebaa728f949a3c6c /gio
parent9bc61def1f815948ea28d92b59f506d3b2024ea0 (diff)
downloadglib-642baa50fa561f7abfbbfe5ac9a10351a706b95a.tar.gz
glocalfile: Never require G_LOCAL_FILE_STAT_FIELD_ATIMEwip/issue2205
Some filesystems don't have meaningful access times under at least some circumstances (see #2189, #2205). In this situation the traditional stat() and related kernel interfaces have to put something meaningless in the st_atime field, and have no way to signal that it is meaningless. However, statx() does have a way to signal that the atime is meaningless: if the filesystem doesn't provide a useful access time, it will unset the STATX_ATIME bit (as well as filling in the same meaningless value for the stx_atime field that stat() would have used, for compatibility). We don't actually *need* the atime, so never include it in the required mask. This was already done for one code path in commit 6fc143bb "gio: Allow no atime from statx" to fix #2189, but other callers were left unchanged in that commit, and receive the same change here. It is not actually guaranteed that *any* of the flags in the returned stx_mask will be set (the only guarantee is that items in STATX_BASIC_STATS have at least a harmless compatibility value, even if their corresponding flag is cleared), so it might be better to follow this up by removing the concept of the required mask entirely. However, as of Linux 5.8 it looks as though STATX_ATIME is the only flag in STATX_BASIC_STATS that might be cleared in practice, so this simpler change fixes the immediate regression. Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2205 Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'gio')
-rw-r--r--gio/glocalfile.c3
-rw-r--r--gio/glocalfileinfo.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index f92e6ed20..a87de9cc4 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -2703,7 +2703,8 @@ g_local_file_measure_size_of_file (gint parent_fd,
#if defined (AT_FDCWD)
if (g_local_file_fstatat (parent_fd, name->data, AT_SYMLINK_NOFOLLOW,
- G_LOCAL_FILE_STAT_FIELD_BASIC_STATS, G_LOCAL_FILE_STAT_FIELD_ALL,
+ G_LOCAL_FILE_STAT_FIELD_BASIC_STATS,
+ G_LOCAL_FILE_STAT_FIELD_ALL & (~G_LOCAL_FILE_STAT_FIELD_ATIME),
&buf) != 0)
{
int errsv = errno;
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 0690e1da2..90fcb3336 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -1858,7 +1858,7 @@ _g_local_file_info_get (const char *basename,
{
res = g_local_file_stat (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),
&statbuf2);
/* Report broken links as symlinks */
@@ -2081,7 +2081,7 @@ _g_local_file_info_get_from_fd (int fd,
if (g_local_file_fstat (fd,
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),
&stat_buf) == -1)
{
int errsv = errno;