bug#54286: [PATCH] fcntl-h: add AT_NO_AUTOMOUNT
On 3/7/22 06:08, Pádraig Brady wrote: * lib/fcntl.in.h: Define AT_NO_AUTOMOUNT to 0 where not defined. This is available on Linux since 2.6.38. Looks good. Please feel free to install this sort of thing without waiting for review.
bug#54286: [PATCH] Fix ls -l triggering automounts.
On Monday, March 7, 2022 3:26:27 PM CET Pádraig Brady wrote: > Updated patch for ls attached as per discussion. > Added a NEWS entry. Works as expected. Thank you both! Kamil
bug#54287: [PATCH] Fix stat command triggering automount.
On Monday, March 7, 2022 3:40:25 PM CET Pádraig Brady wrote: > 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 Works as expected. Thank you both! Kamil
bug#54287: [PATCH] Fix stat command triggering automount.
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ádraigFrom 3fddd0f4eb0eb9b47294f951195233e1c5f12e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 7 Mar 2022 14:32:03 + 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
bug#54286: [PATCH] Fix ls -l triggering automounts.
Updated patch for ls attached as per discussion. Added a NEWS entry.From e4c7fccc0c057a772b6be3f002003ba005cc89d7 Mon Sep 17 00:00:00 2001 From: Rohan Sable Date: Mon, 7 Mar 2022 14:14:13 + Subject: [PATCH] ls: avoid triggering automounts statx() has different defaults wrt automounting compared to stat() or lstat(), so explicitly set the AT_NO_AUTOMOUNT flag to suppress that behavior, and avoid unintended operations or potential errors. * src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior. * NEWS: Mention the bug fix. Signed-off-by: Rohan Sable --- NEWS | 4 src/ls.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index af6596b06..12051cd15 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,10 @@ 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. + [bug introduced in coreutils-8.32] + On macOS, 'mv A B' no longer fails with "Operation not supported" when A and B are in the same tmpfs file system. [bug introduced in coreutils-9.0] diff --git a/src/ls.c b/src/ls.c index 1930e4abb..255789061 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1177,7 +1177,7 @@ do_statx (int fd, char const *name, struct stat *st, int flags, { struct statx stx; bool want_btime = mask & STATX_BTIME; - int ret = statx (fd, name, flags, mask, &stx); + int ret = statx (fd, name, flags | AT_NO_AUTOMOUNT, mask, &stx); if (ret >= 0) { statx_to_stat (&stx, st); -- 2.26.2
bug#54286: [PATCH] fcntl-h: add AT_NO_AUTOMOUNT
* lib/fcntl.in.h: Define AT_NO_AUTOMOUNT to 0 where not defined. This is available on Linux since 2.6.38. --- ChangeLog | 6 ++ lib/fcntl.in.h | 4 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index c5a80fd3f3..e3f0ed216c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2022-03-07 Pádraig Brady + + fcntl-h: add AT_NO_AUTOMOUNT + * lib/fcntl.in.h: Define AT_NO_AUTOMOUNT to 0 where not defined. + This is available on Linux since 2.6.38. + 2022-03-01 Paul Eggert Create lib/Makefile.am after gnulib-comp.m4 diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index 3e0c302af3..9270ced897 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -435,6 +435,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - " # define AT_EACCESS 4 #endif +/* Ignore this flag if not supported. */ +#ifndef AT_NO_AUTOMOUNT +# define AT_NO_AUTOMOUNT 0 +#endif #endif /* _@GUARD_PREFIX@_FCNTL_H */ #endif /* _@GUARD_PREFIX@_FCNTL_H */ -- 2.26.2
bug#54286: [PATCH] Fix ls -l triggering automounts.
On 07/03/2022 07:54, Rohan Sable wrote: Running ls -l on a path that has autofs mounts, triggers a mount or in case of unmountable shares, triggers errors : ~~~ [root@rsablerhel85 mnt2]# ll ls: cannot access 'testshare2': No such file or directory < Error total 0 drwxrwxrwx. 3 1000 1000 15 Jan 17 12:08 testshare < mount is triggerd for testshare d?? ? ?? ?? testshare2< Path we know that is inaccessible throws an error [root@rsablerhel85 mnt2]# mount | grep -i test rsable76server:/testshare on /mnt2/testshare type nfs (rw,relatime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,proto=tcp,timeo=600,retrans=6,sec=sys,mountaddr=192.168.122.58,mountvers=3,mountport=20048,mountproto=tcp,local_lock=none,addr=192.168.122.58) ~~~ Added AT_NO_AUTOMOUNT flag to do_lstat to fix this behavior. Yes we should handle this, but a bit differently I think. In this and the stat(1) patch you're only doing the adjustment for lstat(). I'd be more inclined to do this for all statx() uses because: - stat() and lstat() behave as if AT_NO_AUTOMOUNT is set - stat can be significant here for ondemand dirs, bind mounted entries, or network contexts etc. - ls(1) and stat(1) are operating on meta-data so should avoid mounts by default Also we have to provide some ifdef protection around AT_NO_AUTOMOUNT use. That's best done in gnulib in fcntl.in.h Also we have related control in the --cached=never option in stat(1), which is meant to ensure we go the whole way to the source file system, which maps well with _not_ setting AT_NO_AUTOMOUNT for that case only. I'll follow up with some patches along those lines. thanks, Pádraig
bug#54286: [PATCH] Fix ls -l triggering automounts.
Running ls -l on a path that has autofs mounts, triggers a mount or in case of unmountable shares, triggers errors : ~~~ [root@rsablerhel85 mnt2]# ll ls: cannot access 'testshare2': No such file or directory < Error total 0 drwxrwxrwx. 3 1000 1000 15 Jan 17 12:08 testshare < mount is triggerd for testshare d?? ? ?? ?? testshare2< Path we know that is inaccessible throws an error [root@rsablerhel85 mnt2]# mount | grep -i test rsable76server:/testshare on /mnt2/testshare type nfs (rw,relatime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,proto=tcp,timeo=600,retrans=6,sec=sys,mountaddr=192.168.122.58,mountvers=3,mountport=20048,mountproto=tcp,local_lock=none,addr=192.168.122.58) ~~~ Added AT_NO_AUTOMOUNT flag to do_lstat to fix this behavior. Signed-off-by: Rohan Sable --- src/ls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ls.c b/src/ls.c index 1930e4abb..bf79ef8b9 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1204,7 +1204,7 @@ do_stat (char const *name, struct stat *st) static int do_lstat (char const *name, struct stat *st) { - return do_statx (AT_FDCWD, name, st, AT_SYMLINK_NOFOLLOW, calc_req_mask ()); + return do_statx (AT_FDCWD, name, st, AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT, calc_req_mask ()); } static int -- 2.34.1
bug#54287: [PATCH] Fix stat command triggering automount.
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 --- 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