Blame SOURCES/findutils-4.4.2-xautofs.patch

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