summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
diff options
context:
space:
mode:
authorZhixiong Chi <zhixiong.chi@windriver.com>2018-06-19 03:24:18 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-06-21 09:34:40 +0100
commitac6f587692968956d069d2a1a508e659d8560d16 (patch)
tree700e9e6379c72ac4be41ed7a2c35bdc4abcbdf78 /meta/recipes-extended
parent4623554463685000907eb3e17b4b23136f3759a2 (diff)
downloadpoky-ac6f587692968956d069d2a1a508e659d8560d16.tar.gz
findutils: make -delete honour the -ignore_readdir_race option
the '-delete' action no longer complains about disappeared files when the '-ignore_readdir_race' option is given, too. That action will also returns true in such a case now. (From OE-Core rev: f0808ee03a244be1fb485e0046983a05193b23b6) Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r--meta/recipes-extended/findutils/findutils/0001-find-make-delete-honour-the-ignore_readdir_race-opti.patch145
-rw-r--r--meta/recipes-extended/findutils/findutils_4.6.0.bb4
2 files changed, 148 insertions, 1 deletions
diff --git a/meta/recipes-extended/findutils/findutils/0001-find-make-delete-honour-the-ignore_readdir_race-opti.patch b/meta/recipes-extended/findutils/findutils/0001-find-make-delete-honour-the-ignore_readdir_race-opti.patch
new file mode 100644
index 0000000000..420e10da02
--- /dev/null
+++ b/meta/recipes-extended/findutils/findutils/0001-find-make-delete-honour-the-ignore_readdir_race-opti.patch
@@ -0,0 +1,145 @@
1From 0afb2efada7e435ae18ef7d3db0758464189f44f Mon Sep 17 00:00:00 2001
2From: Bernhard Voelker <mail@bernhard-voelker.de>
3Date: Tue, 30 Jan 2018 23:30:09 +0100
4Subject: find: make -delete honour the -ignore_readdir_race option
5
6* find/pred.c (pred_delete): Return true when the -ignore_readdir_race
7option is active and unlinkat() came back with ENOENT.
8* doc/find.texi (Option -ignore_readdir_race): Document the change.
9(Action -delete): Likewise.
10* find/find.1: Likewise.
11* NEWS (Bug Fixes): Mention the fix.
12
13For now, it seems a bit hard to add a proper test for this,
14so the following shell snippet demonstrates the race:
15
16 $ seq 10 | xargs touch
17 $ env time -f 'find exit status: %x\nfind time: %e' \
18 find -ignore_readdir_race -type f \
19 -delete \
20 -exec sh -c 'sleep $(basename {})' \; \
21 -printf 'find deleted: %p\n' \
22 & \
23 sleep 20; \
24 seq 10 | xargs rm -fv; \
25 wait $!
26
27Reported by Alexander Golubev in
28https://savannah.gnu.org/bugs/?52981
29
30Upstream-Status: Backport
31Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
32---
33 NEWS | 4 ++++
34 doc/find.texi | 15 ++++++++++++++-
35 find/find.1 | 22 ++++++++++++++++++++++
36 find/pred.c | 6 ++++++
37 4 files changed, 46 insertions(+), 1 deletion(-)
38
39diff --git a/NEWS b/NEWS
40index 88cf17d..9809bf4 100644
41--- a/NEWS
42+++ b/NEWS
43@@ -42,6 +42,10 @@
44
45 ** Bug Fixes
46
47+#52981: find: the '-delete' action no longer complains about disappeared files
48+ when the '-ignore_readdir_race' option is given, too. That action will
49+ also returns true in such a case now.
50+
51 Applied patch #8688: Spelling fixes.
52
53 * Major changes in release 4.5.18, 2015-12-27
54diff --git a/doc/find.texi b/doc/find.texi
55index 3580be7..0089193 100644
56--- a/doc/find.texi
57+++ b/doc/find.texi
58@@ -1418,7 +1418,15 @@ gives a significant increase in search speed.
59 If a file disappears after its name has been read from a directory but
60 before @code{find} gets around to examining the file with @code{stat},
61 don't issue an error message. If you don't specify this option, an
62-error message will be issued. This option can be useful in system
63+error message will be issued.
64+
65+Furthermore, @code{find} with the @samp{-ignore_readdir_race} option
66+will ignore errors of the @samp{-delete} action in the case the file
67+has disappeared since the parent directory was read: it will not output
68+an error diagnostic, and the return code of the @samp{-delete} action
69+will be true.
70+
71+This option can be useful in system
72 scripts (cron scripts, for example) that examine areas of the
73 filesystem that change frequently (mail queues, temporary directories,
74 and so forth), because this scenario is common for those sorts of
75@@ -2779,6 +2787,11 @@ explicitly.
76
77 If @samp{-delete} fails, @code{find}'s exit status will be nonzero
78 (when it eventually exits).
79+
80+Together with the @samp{-ignore_readdir_race} option, @code{find} will
81+ignore errors of the @samp{-delete} action in the case the file has disappeared
82+since the parent directory was read: it will not output an error diagnostic, and
83+the return code of the @samp{-delete} action will be true.
84 @end deffn
85
86 @node Adding Tests
87diff --git a/find/find.1 b/find/find.1
88index 0437cd8..0d44c37 100644
89--- a/find/find.1
90+++ b/find/find.1
91@@ -479,6 +479,17 @@ this option on and part of it with this option off
92 (if you need to do that, you will need to issue two \fBfind\fR commands
93 instead, one with the option and one without it).
94
95+Furthermore,
96+.B find
97+with the
98+.B \-ignore_readdir_race
99+option will ignore errors of the
100+.B \-delete
101+action in the case the file has disappeared since the parent directory was read:
102+it will not output an error diagnostic, and the return code of the
103+.B \-delete
104+action will be true.
105+
106 .IP "\-maxdepth \fIlevels\fR"
107 Descend at most \fIlevels\fR (a non-negative integer) levels of
108 directories below the starting-points.
109@@ -1030,6 +1041,17 @@ and
110 .B \-delete
111 together.
112
113+Together with the
114+.B \-ignore_readdir_race
115+option,
116+.B find
117+will ignore errors of the
118+.B \-delete
119+action in the case the file has disappeared since the parent directory was
120+read: it will not output an error diagnostic, and the return code of the
121+.B \-delete
122+action will be true.
123+
124 .IP "\-exec \fIcommand\fR ;"
125 Execute \fIcommand\fR; true if 0 status is returned. All following
126 arguments to
127diff --git a/find/pred.c b/find/pred.c
128index 7e2a7bd..af3bacb 100644
129--- a/find/pred.c
130+++ b/find/pred.c
131@@ -324,6 +324,12 @@ pred_delete (const char *pathname, struct stat *stat_buf, struct predicate *pred
132 }
133 else
134 {
135+ if (ENOENT == errno && options.ignore_readdir_race)
136+ {
137+ /* Ignore unlink() error for vanished files. */
138+ errno = 0;
139+ return true;
140+ }
141 if (EISDIR == errno)
142 {
143 if ((flags & AT_REMOVEDIR) == 0)
144--
145cgit v1.0-41-gc330
diff --git a/meta/recipes-extended/findutils/findutils_4.6.0.bb b/meta/recipes-extended/findutils/findutils_4.6.0.bb
index 072d3b3c05..db03252f54 100644
--- a/meta/recipes-extended/findutils/findutils_4.6.0.bb
+++ b/meta/recipes-extended/findutils/findutils_4.6.0.bb
@@ -6,7 +6,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=f27defe1e96c2e1ecd4e0c9be8967949"
6 6
7DEPENDS = "bison-native" 7DEPENDS = "bison-native"
8 8
9SRC_URI += "file://0001-Unset-need_charset_alias-when-building-for-musl.patch" 9SRC_URI += "file://0001-Unset-need_charset_alias-when-building-for-musl.patch \
10 file://0001-find-make-delete-honour-the-ignore_readdir_race-opti.patch \
11"
10 12
11SRC_URI[md5sum] = "9936aa8009438ce185bea2694a997fc1" 13SRC_URI[md5sum] = "9936aa8009438ce185bea2694a997fc1"
12SRC_URI[sha256sum] = "ded4c9f73731cd48fec3b6bdaccce896473b6d8e337e9612e16cf1431bb1169d" 14SRC_URI[sha256sum] = "ded4c9f73731cd48fec3b6bdaccce896473b6d8e337e9612e16cf1431bb1169d"