From 7bbccb12133f339f386c423d4368385cc14d263e Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sat, 14 Oct 2023 08:25:56 +0200 Subject: [PATCH] Silence non-critical failure to remove /run/finit/cond/ at reboot The directory may hold various custom generated conditions that are not managed by Finit. Not being able to remove the directory is not a critical error. finit[1]: cond_delpath():Failed removing condition path /var/run/finit/cond/: Directory not empty Therefore, ignore ENOENT and ENOTEMPTY and log everything/anything else. Signed-off-by: Joachim Wiberg --- src/cond-w.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cond-w.c b/src/cond-w.c index e70c331b..25022644 100644 --- a/src/cond-w.c +++ b/src/cond-w.c @@ -222,8 +222,16 @@ static int do_delete(const char *fpath, const struct stat *sb, int tflag, struct static void cond_delpath(const char *path) { nftw(path, do_delete, 20, FTW_DEPTH); - if (remove(path) && errno != ENOENT) - err(1, "Failed removing condition path %s", path); + if (remove(path)) { + switch (errno) { + case ENOENT: /* Ignore */ + case ENOTEMPTY: /* Only at shutdown and for directories */ + break; + default: + err(1, "Failed removing condition path %s", path); + break; + } + } } int cond_set_path(const char *path, enum cond_state next)