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