Blame SOURCES/findutils-4.4.2-xautofs.patch

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