From feebbf948082a86af4c3e309b7d9e74e885d5809 Mon Sep 17 00:00:00 2001 From: imp Date: Mon, 7 Jul 2014 23:21:20 +0000 Subject: [PATCH] rm -rf can fail sometimes with an error from fts_read. Make it honor fflag to ignore fts_read errors, but stop deleting from that directory because no further progress can be made. When building a kernel with a high -j value on a high core count machine, during the cleanobj phase we can wind up doing multiple rm -rf at the same time for modules that have subdirectories. This exposed this race (sometimes) as fts_read can return an error if the directory is removed by another rm -rf. Since the intent of the -f flag was to ignore errors, even if this was a bug in fts_read, we should ignore the error like we've been instructed to do. --- bin/rm/rm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/rm/rm.c b/bin/rm/rm.c index 976b4eeb57c2..46807b9e4e58 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -335,7 +335,7 @@ rm_tree(char **argv) warn("%s", p->fts_path); eval = 1; } - if (errno) + if (!fflag && errno) err(1, "fts_read"); fts_close(fts); }