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