Blob Blame History Raw
diff --git a/doc/find.texi b/doc/find.texi
index 2e5958d..8944096 100644
--- a/doc/find.texi
+++ b/doc/find.texi
@@ -1413,6 +1413,10 @@ them.
 There are two ways to avoid searching certain filesystems.  One way is
 to tell @code{find} to only search one filesystem:
 
+@deffn Option -xautofs
+Don't descend directories on autofs filesystems.
+@end deffn
+
 @deffn Option -xdev
 @deffnx Option -mount
 Don't descend directories on other filesystems.  These options are
diff --git a/find/defs.h b/find/defs.h
index 1708d83..a0e7059 100644
--- a/find/defs.h
+++ b/find/defs.h
@@ -550,6 +550,9 @@ struct options
   /* If true, don't cross filesystem boundaries. */
   boolean stay_on_filesystem;
   
+  /* If true, don't descend directories on autofs filesystems. */
+  boolean bypass_autofs;
+
   /* If true, we ignore the problem where we find that a directory entry 
    * no longer exists by the time we get around to processing it.
    */
diff --git a/find/find.1 b/find/find.1
index 8b67ae3..f9c61a3 100644
--- a/find/find.1
+++ b/find/find.1
@@ -451,6 +451,9 @@ if standard input is a tty, and to
 .B \-nowarn
 otherwise.
 
+.IP \-xautofs
+Don't descend directories on autofs filesystems.
+
 .IP \-xdev
 Don't descend directories on other filesystems.
 
diff --git a/find/ftsfind.c b/find/ftsfind.c
index b59d896..838b81f 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -525,6 +525,12 @@ consider_visiting(FTS *p, FTSENT *ent)
 	}
     }
 
+  if (options.bypass_autofs &&
+      0 == strcmp ("autofs", filesystem_type (&statbuf, ent->fts_name)))
+    {
+      fts_set(p, ent, FTS_SKIP); /* descend no further */
+    }
+
   if ( (ent->fts_info == FTS_D) && !options.do_dir_first )
     {
       /* this is the preorder visit, but user said -depth */ 
diff --git a/find/parser.c b/find/parser.c
index 534b670..036ddb8 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -150,6 +150,7 @@ static boolean parse_user          PARAMS((const struct parser_table*, char *arg
 static boolean parse_version       PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
 static boolean parse_wholename     PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
 static boolean parse_xdev          PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
+static boolean parse_xautofs       PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
 static boolean parse_ignore_race   PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
 static boolean parse_noignore_race PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
 static boolean parse_warn          PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
@@ -320,6 +321,7 @@ static struct parser_table const parse_table[] =
   PARSE_TEST_NP    ("wholename",             wholename), /* GNU, replaced -path, but anyway -path will soon be in POSIX */
   {ARG_TEST,       "writable",               parse_accesscheck, pred_writable}, /* GNU, 4.3.0+ */
   PARSE_OPTION     ("xdev",                  xdev), /* POSIX */
+  PARSE_OPTION     ("xautofs",               xautofs),
   PARSE_TEST       ("xtype",                 xtype),	     /* GNU */
 #ifdef UNIMPLEMENTED_UNIX
   /* It's pretty ugly for find to know about archive formats.
@@ -2560,6 +2562,16 @@ parse_xdev (const struct parser_table* entry, char **argv, int *arg_ptr)
 }
 
 static boolean
+parse_xautofs (const struct parser_table* entry, char **argv, int *arg_ptr)
+{
+  (void) argv;
+  (void) arg_ptr;
+  (void) entry;
+  options.bypass_autofs = true;
+  return true;
+}
+
+static boolean
 parse_ignore_race (const struct parser_table* entry, char **argv, int *arg_ptr)
 {
   options.ignore_readdir_race = true;
diff --git a/find/util.c b/find/util.c
index a06eada..d3cb467 100644
--- a/find/util.c
+++ b/find/util.c
@@ -933,6 +933,7 @@ set_option_defaults(struct options *p)
 
   p->full_days = false;
   p->stay_on_filesystem = false;
+  p->bypass_autofs = false;
   p->ignore_readdir_race = false;
 
   if (p->posixly_correct)