coreutils/backport-stat-only-automount-with-cached-never.patch
ship_harbour 30c20060a7 backport some patches from upstream
(cherry picked from commit 3880704c78bdeda3bad94725c232e1f28e188786)
2022-10-21 18:36:06 +08:00

68 lines
2.1 KiB
Diff

From 92cb8427c537f37edd43c5cef1909585201372ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Mon, 7 Mar 2022 23:29:20 +0000
Subject: [PATCH] stat: only automount with --cached=never
Revert to the default behavior before the introduction of statx().
* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never.
* doc/coreutils.texi (stat invocation): Mention the automount
behavior with --cached=never.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/54287
Reference: https://github.com/coreutils/coreutils/commit/92cb8427c537f37edd43c5cef1909585201372ab
Conflict: NEWS Context adaptation
---
NEWS | 4 ++++
doc/coreutils.texi | 1 +
src/stat.c | 3 +++
3 files changed, 8 insertions(+)
diff --git a/NEWS b/NEWS
index 76a6986..81f5cf5 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU coreutils NEWS -*- outline -*-
** Bug fixes
+ stat no longer tries to automount files by default, reverting to the
+ behavior before the statx() call was introduced in coreutils-8.32.
+ Only `stat --cached=never` will continue to automount files.
+
ls no longer tries to automount files, reverting to the behavior
before the statx() call was introduced in coreutils-8.32.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 467f635..ff8e7a6 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -12382,6 +12382,7 @@ Always read the already cached attributes if available.
@item never
Always sychronize with the latest file system attributes.
+This also mounts automounted files.
@item default
Leave the caching behavior to the underlying file system.
diff --git a/src/stat.c b/src/stat.c
index 5012622..1f1c8e4 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1355,6 +1355,9 @@ do_stat (char const *filename, char const *format, char const *format2)
else if (force_sync)
flags |= AT_STATX_FORCE_SYNC;
+ if (! force_sync)
+ flags |= AT_NO_AUTOMOUNT;
+
fd = statx (fd, pathname, flags, format_to_mask (format), &stx);
if (fd < 0)
{
--
2.27.0