1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-06 10:00:40 +03:00

cleanup: unlink passes with ENOENT

This commit is contained in:
Zdenek Kabelac 2024-04-30 13:48:01 +02:00
parent 061fa7b690
commit db6bb6e90b
6 changed files with 10 additions and 10 deletions

View File

@ -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;
}

View File

@ -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 */

View File

@ -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;

View File

@ -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';
}
}

View File

@ -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;
}

View File

@ -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)