diff options
Diffstat (limited to 'meta/recipes-extended/findutils/findutils/0001-find-make-delete-honour-the-ignore_readdir_race-opti.patch')
-rw-r--r-- | meta/recipes-extended/findutils/findutils/0001-find-make-delete-honour-the-ignore_readdir_race-opti.patch | 144 |
1 files changed, 0 insertions, 144 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 deleted file mode 100644 index a570473ccb..0000000000 --- a/meta/recipes-extended/findutils/findutils/0001-find-make-delete-honour-the-ignore_readdir_race-opti.patch +++ /dev/null | |||
@@ -1,144 +0,0 @@ | |||
1 | From a3f4821c4a3f723d21c9298d54bee8a656bfd7fb Mon Sep 17 00:00:00 2001 | ||
2 | From: Bernhard Voelker <mail@bernhard-voelker.de> | ||
3 | Date: Tue, 30 Jan 2018 23:30:09 +0100 | ||
4 | Subject: [PATCH] find: make -delete honour the -ignore_readdir_race option | ||
5 | |||
6 | * find/pred.c (pred_delete): Return true when the -ignore_readdir_race | ||
7 | option 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 | |||
13 | For now, it seems a bit hard to add a proper test for this, | ||
14 | so 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 | |||
27 | Reported by Alexander Golubev in | ||
28 | https://savannah.gnu.org/bugs/?52981 | ||
29 | |||
30 | Upstream-Status: Backport | ||
31 | Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com> | ||
32 | |||
33 | --- | ||
34 | NEWS | 4 ++++ | ||
35 | doc/find.texi | 15 ++++++++++++++- | ||
36 | find/find.1 | 22 ++++++++++++++++++++++ | ||
37 | find/pred.c | 6 ++++++ | ||
38 | 4 files changed, 46 insertions(+), 1 deletion(-) | ||
39 | |||
40 | diff --git a/NEWS b/NEWS | ||
41 | index 660c241..b86ec1e 100644 | ||
42 | --- a/NEWS | ||
43 | +++ b/NEWS | ||
44 | @@ -42,6 +42,10 @@ Updated the Danish translation. | ||
45 | |||
46 | ** Bug Fixes: | ||
47 | |||
48 | +#52981: find: the '-delete' action no longer complains about disappeared files | ||
49 | + when the '-ignore_readdir_race' option is given, too. That action will | ||
50 | + also returns true in such a case now. | ||
51 | + | ||
52 | Applied patch #8688: Spelling fixes. | ||
53 | |||
54 | * Major changes in release 4.5.18, 2015-12-27 | ||
55 | diff --git a/doc/find.texi b/doc/find.texi | ||
56 | index fdeb841..247c19a 100644 | ||
57 | --- a/doc/find.texi | ||
58 | +++ b/doc/find.texi | ||
59 | @@ -1418,7 +1418,15 @@ gives a significant increase in search speed. | ||
60 | If a file disappears after its name has been read from a directory but | ||
61 | before @code{find} gets around to examining the file with @code{stat}, | ||
62 | don't issue an error message. If you don't specify this option, an | ||
63 | -error message will be issued. This option can be useful in system | ||
64 | +error message will be issued. | ||
65 | + | ||
66 | +Furthermore, @code{find} with the @samp{-ignore_readdir_race} option | ||
67 | +will ignore errors of the @samp{-delete} action in the case the file | ||
68 | +has disappeared since the parent directory was read: it will not output | ||
69 | +an error diagnostic, and the return code of the @samp{-delete} action | ||
70 | +will be true. | ||
71 | + | ||
72 | +This option can be useful in system | ||
73 | scripts (cron scripts, for example) that examine areas of the | ||
74 | filesystem that change frequently (mail queues, temporary directories, | ||
75 | and so forth), because this scenario is common for those sorts of | ||
76 | @@ -2779,6 +2787,11 @@ explicitly. | ||
77 | |||
78 | If @samp{-delete} fails, @code{find}'s exit status will be nonzero | ||
79 | (when it eventually exits). | ||
80 | + | ||
81 | +Together with the @samp{-ignore_readdir_race} option, @code{find} will | ||
82 | +ignore errors of the @samp{-delete} action in the case the file has disappeared | ||
83 | +since the parent directory was read: it will not output an error diagnostic, and | ||
84 | +the return code of the @samp{-delete} action will be true. | ||
85 | @end deffn | ||
86 | |||
87 | @node Adding Tests | ||
88 | diff --git a/find/find.1 b/find/find.1 | ||
89 | index 7b141b8..0eec41c 100644 | ||
90 | --- a/find/find.1 | ||
91 | +++ b/find/find.1 | ||
92 | @@ -479,6 +479,17 @@ one part of the filesystem with this option on and part of it with this option | ||
93 | off (if you need to do that, you will need to issue two \fBfind\fR commands | ||
94 | instead, one with the option and one without it). | ||
95 | |||
96 | +Furthermore, | ||
97 | +.B find | ||
98 | +with the | ||
99 | +.B \-ignore_readdir_race | ||
100 | +option will ignore errors of the | ||
101 | +.B \-delete | ||
102 | +action in the case the file has disappeared since the parent directory was read: | ||
103 | +it will not output an error diagnostic, and the return code of the | ||
104 | +.B \-delete | ||
105 | +action will be true. | ||
106 | + | ||
107 | .IP "\-maxdepth \fIlevels\fR" | ||
108 | Descend at most \fIlevels\fR (a non-negative integer) levels of | ||
109 | directories below the starting-points. | ||
110 | @@ -1030,6 +1041,17 @@ and | ||
111 | .B \-delete | ||
112 | together. | ||
113 | |||
114 | +Together with the | ||
115 | +.B \-ignore_readdir_race | ||
116 | +option, | ||
117 | +.B find | ||
118 | +will ignore errors of the | ||
119 | +.B \-delete | ||
120 | +action in the case the file has disappeared since the parent directory was | ||
121 | +read: it will not output an error diagnostic, and the return code of the | ||
122 | +.B \-delete | ||
123 | +action will be true. | ||
124 | + | ||
125 | .IP "\-exec \fIcommand\fR ;" | ||
126 | Execute \fIcommand\fR; true if 0 status is returned. All following | ||
127 | arguments to | ||
128 | diff --git a/find/pred.c b/find/pred.c | ||
129 | index 32938fb..431f065 100644 | ||
130 | --- a/find/pred.c | ||
131 | +++ b/find/pred.c | ||
132 | @@ -324,6 +324,12 @@ pred_delete (const char *pathname, struct stat *stat_buf, struct predicate *pred | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | + if (ENOENT == errno && options.ignore_readdir_race) | ||
137 | + { | ||
138 | + /* Ignore unlink() error for vanished files. */ | ||
139 | + errno = 0; | ||
140 | + return true; | ||
141 | + } | ||
142 | if (EISDIR == errno) | ||
143 | { | ||
144 | if ((flags & AT_REMOVEDIR) == 0) | ||