From db6bb6e90bc3a7e5d0f9b0b89cf5dd9b5e7e3bad Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 30 Apr 2024 13:48:01 +0200 Subject: [PATCH] cleanup: unlink passes with ENOENT --- lib/activate/fs.c | 8 ++++---- lib/format_text/archive.c | 2 +- lib/format_text/archiver.c | 2 +- lib/log/log.c | 4 ++-- lib/misc/lvm-file.c | 2 +- lib/misc/lvm-flock.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/activate/fs.c b/lib/activate/fs.c index c8b304f9d..808721e5a 100644 --- a/lib/activate/fs.c +++ b/lib/activate/fs.c @@ -112,7 +112,7 @@ static void _rm_blks(const char *dir) if (!S_ISBLK(buf.st_mode)) continue; log_very_verbose("Removing %s", path); - if (unlink(path) < 0) + if (unlink(path) && (errno != ENOENT)) log_sys_debug("unlink", path); } } @@ -168,7 +168,7 @@ static int _mk_link(const char *dev_dir, const char *vg_name, _rm_blks(vg_path); log_very_verbose("Removing %s", lvm1_group_path); - if (unlink(lvm1_group_path) < 0) + if (unlink(lvm1_group_path) && (errno != ENOENT)) log_sys_debug("unlink", lvm1_group_path); } } @@ -200,7 +200,7 @@ static int _mk_link(const char *dev_dir, const char *vg_name, } log_very_verbose("Removing %s", lv_path); - if (unlink(lv_path) < 0) { + if (unlink(lv_path) && (errno != ENOENT)) { log_sys_error("unlink", lv_path); return 0; } @@ -252,7 +252,7 @@ static int _rm_link(const char *dev_dir, const char *vg_name, } log_very_verbose("Removing link %s", lv_path); - if (unlink(lv_path) < 0) { + if (unlink(lv_path) && (errno != ENOENT)) { log_sys_error("unlink", lv_path); return 0; } diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c index 0872a2cb4..12d14ebf8 100644 --- a/lib/format_text/archive.c +++ b/lib/format_text/archive.c @@ -209,7 +209,7 @@ static void _remove_expired(const char *dir, const char *vgname, continue; log_very_verbose("Expiring archive %s", path); - if (unlink(path)) + if (unlink(path) && (errno != ENOENT)) log_sys_debug("unlink", path); /* Don't delete any more if we've reached the minimum */ diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c index 165c029aa..1f9eda39d 100644 --- a/lib/format_text/archiver.c +++ b/lib/format_text/archiver.c @@ -300,7 +300,7 @@ int backup_remove(struct cmd_context *cmd, const char *vg_name) /* * Let this fail silently. */ - if (unlink(path)) + if (unlink(path) && (errno != ENOENT)) log_sys_debug("unlink", path); return 1; diff --git a/lib/log/log.c b/lib/log/log.c index dc013e8a6..07ea5b2eb 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -331,8 +331,8 @@ void unlink_log_file(int ret) (env = getenv("LVM_EXPECTED_EXIT_STATUS")) && ((env[0] == '>' && ret > atoi(env + 1)) || (atoi(env) == ret))) { - if (unlink(_log_file_path)) - log_sys_error("unlink", _log_file_path); + if (unlink(_log_file_path) && (errno != ENOENT)) + log_sys_debug("unlink", _log_file_path); _log_file_path[0] = '\0'; } } diff --git a/lib/misc/lvm-file.c b/lib/misc/lvm-file.c index b06f05d9f..c635fbfec 100644 --- a/lib/misc/lvm-file.c +++ b/lib/misc/lvm-file.c @@ -104,7 +104,7 @@ int lvm_rename(const char *old, const char *new) return 0; } - if (unlink(old)) { + if (unlink(old) && (errno != ENOENT)) { log_sys_error("unlink", old); return 0; } diff --git a/lib/misc/lvm-flock.c b/lib/misc/lvm-flock.c index d48ff22e1..4ba85e0fb 100644 --- a/lib/misc/lvm-flock.c +++ b/lib/misc/lvm-flock.c @@ -49,7 +49,7 @@ static void _undo_flock(const char *file, int fd) !stat(file, &buf1) && !fstat(fd, &buf2) && is_same_inode(buf1, buf2)) - if (unlink(file)) + if (unlink(file) && (errno != ENOENT)) log_sys_debug("unlink", file); if (close(fd) < 0)