7b76bb
From 17e470dc1acca4824b70328d733d5f99c12d0d65 Mon Sep 17 00:00:00 2001
7b76bb
From: Kamil Dudka <kdudka@redhat.com>
7b76bb
Date: Wed, 11 May 2011 16:46:45 +0200
7b76bb
Subject: [PATCH 3/4] findutils-4.4.2-xautofs.patch
7b76bb
7b76bb
---
7b76bb
 doc/find.texi  |    4 ++++
7b76bb
 find/defs.h    |    3 +++
7b76bb
 find/find.1    |    3 +++
7b76bb
 find/ftsfind.c |    6 ++++++
7b76bb
 find/parser.c  |   11 ++++++++++-
7b76bb
 find/util.c    |    1 +
7b76bb
 6 files changed, 27 insertions(+), 1 deletions(-)
7b76bb
7b76bb
diff --git a/doc/find.texi b/doc/find.texi
7b76bb
index c584298..9731b71 100644
7b76bb
--- a/doc/find.texi
7b76bb
+++ b/doc/find.texi
7b76bb
@@ -1446,6 +1446,10 @@ them.
7b76bb
 There are two ways to avoid searching certain filesystems.  One way is
7b76bb
 to tell @code{find} to only search one filesystem:
7b76bb
 
7b76bb
+@deffn Option -xautofs
7b76bb
+Don't descend directories on autofs filesystems.
7b76bb
+@end deffn
7b76bb
+
7b76bb
 @deffn Option -xdev
7b76bb
 @deffnx Option -mount
7b76bb
 Don't descend directories on other filesystems.  These options are
7b76bb
diff --git a/find/defs.h b/find/defs.h
7b76bb
index 11d1d00..f95ce72 100644
7b76bb
--- a/find/defs.h
7b76bb
+++ b/find/defs.h
7b76bb
@@ -557,6 +557,9 @@ struct options
7b76bb
   /* If true, don't cross filesystem boundaries. */
7b76bb
   bool stay_on_filesystem;
7b76bb
 
7b76bb
+  /* If true, don't descend directories on autofs filesystems. */
7b76bb
+  bool bypass_autofs;
7b76bb
+
7b76bb
   /* If true, we ignore the problem where we find that a directory entry
7b76bb
    * no longer exists by the time we get around to processing it.
7b76bb
    */
7b76bb
diff --git a/find/find.1 b/find/find.1
7b76bb
index e851f82..a4799ff 100644
7b76bb
--- a/find/find.1
7b76bb
+++ b/find/find.1
7b76bb
@@ -520,6 +520,9 @@ to stat them; this gives a significant increase in search speed.
7b76bb
 .IP "\-version, \-\-version"
7b76bb
 Print the \fBfind\fR version number and exit.
7b76bb
 
7b76bb
+.IP \-xautofs
7b76bb
+Don't descend directories on autofs filesystems.
7b76bb
+
7b76bb
 .IP \-xdev
7b76bb
 Don't descend directories on other filesystems.
7b76bb
 
7b76bb
diff --git a/find/ftsfind.c b/find/ftsfind.c
7b76bb
index 9fdb8ef..bd7cc37 100644
7b76bb
--- a/find/ftsfind.c
7b76bb
+++ b/find/ftsfind.c
7b76bb
@@ -485,6 +485,12 @@ consider_visiting (FTS *p, FTSENT *ent)
7b76bb
 	}
7b76bb
     }
7b76bb
 
7b76bb
+  if (options.bypass_autofs &&
7b76bb
+      0 == strcmp ("autofs", filesystem_type (&statbuf, ent->fts_name)))
7b76bb
+    {
7b76bb
+      fts_set(p, ent, FTS_SKIP); /* descend no further */
7b76bb
+    }
7b76bb
+
7b76bb
   if ( (ent->fts_info == FTS_D) && !options.do_dir_first )
7b76bb
     {
7b76bb
       /* this is the preorder visit, but user said -depth */
7b76bb
diff --git a/find/parser.c b/find/parser.c
7b76bb
index 52a1ef6..995aec3 100644
7b76bb
--- a/find/parser.c
7b76bb
+++ b/find/parser.c
7b76bb
@@ -146,6 +146,7 @@ static bool parse_user          (const struct parser_table*, char *argv[], int *
7b76bb
 static bool parse_version       (const struct parser_table*, char *argv[], int *arg_ptr);
7b76bb
 static bool parse_wholename     (const struct parser_table*, char *argv[], int *arg_ptr);
7b76bb
 static bool parse_xdev          (const struct parser_table*, char *argv[], int *arg_ptr);
7b76bb
+static bool parse_xautofs       (const struct parser_table*, char *argv[], int *arg_ptr);
7b76bb
 static bool parse_ignore_race   (const struct parser_table*, char *argv[], int *arg_ptr);
7b76bb
 static bool parse_noignore_race (const struct parser_table*, char *argv[], int *arg_ptr);
7b76bb
 static bool parse_warn          (const struct parser_table*, char *argv[], int *arg_ptr);
7b76bb
@@ -306,6 +307,7 @@ static struct parser_table const parse_table[] =
7b76bb
   PARSE_TEST_NP    ("wholename",             wholename), /* GNU, replaced -path, but anyway -path will soon be in POSIX */
7b76bb
   {ARG_TEST,       "writable",               parse_accesscheck, pred_writable}, /* GNU, 4.3.0+ */
7b76bb
   PARSE_OPTION     ("xdev",                  xdev), /* POSIX */
7b76bb
+  PARSE_OPTION     ("xautofs",               xautofs),
7b76bb
   PARSE_TEST       ("xtype",                 xtype),	     /* GNU */
7b76bb
 #ifdef UNIMPLEMENTED_UNIX
7b76bb
   /* It's pretty ugly for find to know about archive formats.
7b76bb
@@ -1239,7 +1241,7 @@ operators (decreasing precedence; -and is implicit where no others are given):\n
7b76bb
 positional options (always true): -daystart -follow -regextype\n\n\
7b76bb
 normal options (always true, specified before other expressions):\n\
7b76bb
       -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf\n\
7b76bb
-      --version -xdev -ignore_readdir_race -noignore_readdir_race\n"));
7b76bb
+      --version -xautofs -xdev -ignore_readdir_race -noignore_readdir_race\n"));
7b76bb
   puts (_("\
7b76bb
 tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N\n\
7b76bb
       -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME\n\
7b76bb
@@ -2683,6 +2685,13 @@ parse_xdev (const struct parser_table* entry, char **argv, int *arg_ptr)
7b76bb
 }
7b76bb
 
7b76bb
 static bool
7b76bb
+parse_xautofs (const struct parser_table* entry, char **argv, int *arg_ptr)
7b76bb
+{
7b76bb
+  options.bypass_autofs = true;
7b76bb
+  return parse_noop (entry, argv, arg_ptr);
7b76bb
+}
7b76bb
+
7b76bb
+static bool
7b76bb
 parse_ignore_race (const struct parser_table* entry, char **argv, int *arg_ptr)
7b76bb
 {
7b76bb
   options.ignore_readdir_race = true;
7b76bb
diff --git a/find/util.c b/find/util.c
7b76bb
index 8577396..4d45f84 100644
7b76bb
--- a/find/util.c
7b76bb
+++ b/find/util.c
7b76bb
@@ -1017,6 +1017,7 @@ set_option_defaults (struct options *p)
7b76bb
 
7b76bb
   p->full_days = false;
7b76bb
   p->stay_on_filesystem = false;
7b76bb
+  p->bypass_autofs = false;
7b76bb
   p->ignore_readdir_race = false;
7b76bb
 
7b76bb
   if (p->posixly_correct)
7b76bb
-- 
7b76bb
1.7.4.4
7b76bb