Subject: bug#54287: closed (Re: bug#54287: [PATCH] Fix stat command triggering automount.)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 07 Mar 2022 14:41:02 +0000

Your bug report

#54287: [PATCH] Fix stat command triggering automount.

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
54287: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=54287
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#54287: [PATCH] Fix stat command triggering automount.
From: Pádraig Brady <[email-masked]>
To: Rohan Sable <[email-masked]>, [email-masked]
Cc: [email-masked], [email-masked], [email-masked]
Date: Mon, 7 Mar 2022 14:40:25 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

New stat patch attached to apply AT_NO_AUTOMOUNT
unless --cached=never is specified.

See https://bugs.gnu.org/54286 for more general discussion.
Marking this as done.

cheers,
Pádraig

From 3fddd0f4eb0eb9b47294f951195233e1c5f12e72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Mon, 7 Mar 2022 14:32:03 +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 fix.

Fixes https://bugs.gnu.org/54287
---
 NEWS               | 5 +++--
 doc/coreutils.texi | 1 +
 src/stat.c         | 3 +++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 12051cd15..8e95be755 100644
--- a/NEWS
+++ b/NEWS
@@ -34,8 +34,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   and the documentation has been clarified for unusual cases.
   [bug introduced in coreutils-7.0]
 
-  ls no longer tries to automount files, reverting to the behavior
-  before the statx() call was introduced.
+  ls and stat no longer try to automount files, reverting to the behavior
+  before the statx() call was introduced.  Only `stat --cached=never`
+  will continue to automount files.
   [bug introduced in coreutils-8.32]
 
   On macOS, 'mv A B' no longer fails with "Operation not supported"
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index e9be0993a..05dc5ee21 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -12608,6 +12608,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 edafd0285..3765a8f65 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1394,6 +1394,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.26.2

Subject: [PATCH] Fix stat command triggering automount.
From: Rohan Sable <[email-masked]>
To: [email-masked]
Cc: [email-masked], [email-masked], [email-masked]
Date: Mon, 7 Mar 2022 13:25:26 +0530
List-Id: <debbugs-submit.debbugs.gnu.org>

Stat command now internally uses statx syscall.
AT_NO_AUTOMOUNT flag was not set when statx was called.
This triggered the mount of autofs shares.
Added AT_NO_AUTOMOUNT flag to fix this behavior.

Signed-off-by: Rohan Sable <[email-masked]>
---
 src/stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/stat.c b/src/stat.c
index edafd0285..d173d2f17 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1386,7 +1386,7 @@ do_stat (char const *filename, char const *format, char const *format2)
     }
   else if (!follow_links)
     {
-      flags = AT_SYMLINK_NOFOLLOW;
+      flags = AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT;
     }
 
   if (dont_sync)
-- 
2.34.1