Blame SOURCES/findutils-4.4.2-xautofs.patch

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