|
|
10a327 |
From 1328926a705fdb4728c1f255dd368de928736d39 Mon Sep 17 00:00:00 2001
|
|
|
10a327 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
10a327 |
Date: Fri, 25 Sep 2015 16:09:39 +0200
|
|
|
10a327 |
Subject: [PATCH 1/2] fts: introduce the FTS_NOLEAF flag
|
|
|
10a327 |
|
|
|
10a327 |
The flag is needed to implement the -noleaf option of find.
|
|
|
10a327 |
* lib/fts.c (link_count_optimize_ok): Implement the FTS_NOLEAF flag.
|
|
|
10a327 |
* lib/fts_.h (FTS_NOLEAF): New macro, shifted conflicting constants.
|
|
|
10a327 |
---
|
|
|
10a327 |
gl/lib/fts.c | 4 ++++
|
|
|
10a327 |
gl/lib/fts_.h | 12 +++++++++---
|
|
|
10a327 |
2 files changed, 13 insertions(+), 3 deletions(-)
|
|
|
10a327 |
|
|
|
10a327 |
diff --git a/gl/lib/fts.c b/gl/lib/fts.c
|
|
|
10a327 |
index d2d404f..808466f 100644
|
|
|
10a327 |
--- a/gl/lib/fts.c
|
|
|
10a327 |
+++ b/gl/lib/fts.c
|
|
|
10a327 |
@@ -736,6 +736,10 @@ filesystem_type (FTSENT const *p)
|
|
|
10a327 |
struct dev_type *ent;
|
|
|
10a327 |
struct statfs fs_buf;
|
|
|
10a327 |
|
|
|
10a327 |
+ if (ISSET(FTS_NOLEAF))
|
|
|
10a327 |
+ /* leaf optimization explicitly disabled by the FTS_NOLEAF flag */
|
|
|
10a327 |
+ return 0;
|
|
|
10a327 |
+
|
|
|
10a327 |
/* If we're not in CWDFD mode, don't bother with this optimization,
|
|
|
10a327 |
since the caller is not serious about performance. */
|
|
|
10a327 |
if (!ISSET (FTS_CWDFD))
|
|
|
10a327 |
diff --git a/gl/lib/fts_.h b/gl/lib/fts_.h
|
|
|
10a327 |
index 63d4b74..f1d519b 100644
|
|
|
10a327 |
--- a/gl/lib/fts_.h
|
|
|
10a327 |
+++ b/gl/lib/fts_.h
|
|
|
10a327 |
@@ -155,10 +155,16 @@ typedef struct {
|
|
|
10a327 |
from input path names during fts_open initialization. */
|
|
|
10a327 |
# define FTS_VERBATIM 0x1000
|
|
|
10a327 |
|
|
|
10a327 |
-# define FTS_OPTIONMASK 0x1fff /* valid user option mask */
|
|
|
10a327 |
+ /* Disable leaf optimization (which eliminates stat() calls during traversal,
|
|
|
10a327 |
+ based on the count of nested directories stored in stat.st_nlink of each
|
|
|
10a327 |
+ directory). Note that the optimization is by default enabled only for
|
|
|
10a327 |
+ selected file systems, and only if the FTS_CWDFD flag is set. */
|
|
|
10a327 |
+# define FTS_NOLEAF 0x2000
|
|
|
10a327 |
|
|
|
10a327 |
-# define FTS_NAMEONLY 0x2000 /* (private) child names only */
|
|
|
10a327 |
-# define FTS_STOP 0x4000 /* (private) unrecoverable error */
|
|
|
10a327 |
+# define FTS_OPTIONMASK 0x3fff /* valid user option mask */
|
|
|
10a327 |
+
|
|
|
10a327 |
+# define FTS_NAMEONLY 0x4000 /* (private) child names only */
|
|
|
10a327 |
+# define FTS_STOP 0x8000 /* (private) unrecoverable error */
|
|
|
10a327 |
int fts_options; /* fts_open options, global flags */
|
|
|
10a327 |
|
|
|
10a327 |
/* Map a directory's device number to a boolean. The boolean is
|
|
|
10a327 |
--
|
|
|
10a327 |
2.5.0
|
|
|
10a327 |
|
|
|
10a327 |
|
|
|
10a327 |
From c186934e6e37ddadf7511abb9b1045192757618e Mon Sep 17 00:00:00 2001
|
|
|
10a327 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
10a327 |
Date: Fri, 25 Sep 2015 19:13:15 +0200
|
|
|
10a327 |
Subject: [PATCH 2/2] ftsfind: propagate the -noleaf option to FTS
|
|
|
10a327 |
|
|
|
10a327 |
* find/ftsfind.c (find): Propagate the -noleaf option to FTS.
|
|
|
10a327 |
---
|
|
|
10a327 |
find/ftsfind.c | 3 +++
|
|
|
10a327 |
1 file changed, 3 insertions(+)
|
|
|
10a327 |
|
|
|
10a327 |
diff --git a/find/ftsfind.c b/find/ftsfind.c
|
|
|
10a327 |
index 5159470..e34b672 100644
|
|
|
10a327 |
--- a/find/ftsfind.c
|
|
|
10a327 |
+++ b/find/ftsfind.c
|
|
|
10a327 |
@@ -559,6 +559,9 @@ find (char *arg)
|
|
|
10a327 |
if (options.stay_on_filesystem)
|
|
|
10a327 |
ftsoptions |= FTS_XDEV;
|
|
|
10a327 |
|
|
|
10a327 |
+ if (options.no_leaf_check)
|
|
|
10a327 |
+ ftsoptions |= FTS_NOLEAF;
|
|
|
10a327 |
+
|
|
|
10a327 |
p = fts_open (arglist, ftsoptions, NULL);
|
|
|
10a327 |
if (NULL == p)
|
|
|
10a327 |
{
|
|
|
10a327 |
--
|
|
|
10a327 |
2.5.0
|
|
|
10a327 |
|