d736caf
From f4422844dbcd839ce486bcbc15b7bd5b72c9198d Mon Sep 17 00:00:00 2001
d736caf
From: Rohan Sable <rsable@redhat.com>
d736caf
Date: Mon, 7 Mar 2022 14:14:13 +0000
d736caf
Subject: [PATCH 1/2] ls: avoid triggering automounts
d736caf
d736caf
statx() has different defaults wrt automounting
d736caf
compared to stat() or lstat(), so explicitly
d736caf
set the AT_NO_AUTOMOUNT flag to suppress that behavior,
d736caf
and avoid unintended operations or potential errors.
d736caf
d736caf
* src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior.
d736caf
Fixes https://bugs.gnu.org/54286
d736caf
d736caf
Signed-off-by: Rohan Sable <rsable@redhat.com>
d736caf
d736caf
Upstream-commit: 85c975df2c25bd799370b04bb294e568e001102f
d736caf
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d736caf
---
d736caf
 src/ls.c | 2 +-
d736caf
 1 file changed, 1 insertion(+), 1 deletion(-)
d736caf
d736caf
diff --git a/src/ls.c b/src/ls.c
d736caf
index 1047801..fe0e9f8 100644
d736caf
--- a/src/ls.c
d736caf
+++ b/src/ls.c
d736caf
@@ -1175,7 +1175,7 @@ do_statx (int fd, char const *name, struct stat *st, int flags,
d736caf
 {
d736caf
   struct statx stx;
d736caf
   bool want_btime = mask & STATX_BTIME;
d736caf
-  int ret = statx (fd, name, flags, mask, &stx;;
d736caf
+  int ret = statx (fd, name, flags | AT_NO_AUTOMOUNT, mask, &stx;;
d736caf
   if (ret >= 0)
d736caf
     {
d736caf
       statx_to_stat (&stx, st);
d736caf
-- 
d736caf
2.34.1
d736caf
d736caf
d736caf
From 3d227f9e4f3fe806064721e4b9451ee06526bc80 Mon Sep 17 00:00:00 2001
d736caf
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
d736caf
Date: Mon, 7 Mar 2022 23:29:20 +0000
d736caf
Subject: [PATCH 2/2] stat: only automount with --cached=never
d736caf
d736caf
Revert to the default behavior before the introduction of statx().
d736caf
d736caf
* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never.
d736caf
* doc/coreutils.texi (stat invocation): Mention the automount
d736caf
behavior with --cached=never.
d736caf
d736caf
Fixes https://bugs.gnu.org/54287
d736caf
d736caf
Upstream-commit: 92cb8427c537f37edd43c5cef1909585201372ab
d736caf
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d736caf
---
d736caf
 doc/coreutils.texi | 1 +
d736caf
 src/stat.c         | 3 +++
d736caf
 2 files changed, 4 insertions(+)
d736caf
d736caf
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
d736caf
index 19b535c..0f5c16a 100644
d736caf
--- a/doc/coreutils.texi
d736caf
+++ b/doc/coreutils.texi
d736caf
@@ -12564,6 +12564,7 @@ Always read the already cached attributes if available.
d736caf
 
d736caf
 @item never
d736caf
 Always sychronize with the latest file system attributes.
d736caf
+This also mounts automounted files.
d736caf
 
d736caf
 @item default
d736caf
 Leave the caching behavior to the underlying file system.
d736caf
diff --git a/src/stat.c b/src/stat.c
d736caf
index 0c34501..803340a 100644
d736caf
--- a/src/stat.c
d736caf
+++ b/src/stat.c
d736caf
@@ -1381,6 +1381,9 @@ do_stat (char const *filename, char const *format, char const *format2)
d736caf
   else if (force_sync)
d736caf
     flags |= AT_STATX_FORCE_SYNC;
d736caf
 
d736caf
+  if (! force_sync)
d736caf
+    flags |= AT_NO_AUTOMOUNT;
d736caf
+
d736caf
   fd = statx (fd, pathname, flags, format_to_mask (format), &stx;;
d736caf
   if (fd < 0)
d736caf
     {
d736caf
-- 
d736caf
2.34.1
d736caf