mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 09:16:17 +01:00
glocalfile: Never require G_LOCAL_FILE_STAT_FIELD_ATIME
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>
This commit is contained in:
parent
9bc61def1f
commit
642baa50fa
@ -2703,7 +2703,8 @@ g_local_file_measure_size_of_file (gint parent_fd,
|
|||||||
|
|
||||||
#if defined (AT_FDCWD)
|
#if defined (AT_FDCWD)
|
||||||
if (g_local_file_fstatat (parent_fd, name->data, AT_SYMLINK_NOFOLLOW,
|
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)
|
&buf) != 0)
|
||||||
{
|
{
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
|
@ -1858,7 +1858,7 @@ _g_local_file_info_get (const char *basename,
|
|||||||
{
|
{
|
||||||
res = g_local_file_stat (path,
|
res = g_local_file_stat (path,
|
||||||
G_LOCAL_FILE_STAT_FIELD_BASIC_STATS | G_LOCAL_FILE_STAT_FIELD_BTIME,
|
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);
|
&statbuf2);
|
||||||
|
|
||||||
/* Report broken links as symlinks */
|
/* Report broken links as symlinks */
|
||||||
@ -2081,7 +2081,7 @@ _g_local_file_info_get_from_fd (int fd,
|
|||||||
|
|
||||||
if (g_local_file_fstat (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_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)
|
&stat_buf) == -1)
|
||||||
{
|
{
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user