mirror of
https://github.com/systemd/systemd.git
synced 2025-03-13 00:58:27 +03:00
udev-node: do not ignore unexpected errors on removing symlink in stack directory
Only acceptable error here is -ENOENT.
This commit is contained in:
parent
3df566a667
commit
0706cdf4ec
@ -334,25 +334,30 @@ static int update_stack_directory(sd_device *dev, const char *dirname, bool add)
|
|||||||
return log_oom_debug();
|
return log_oom_debug();
|
||||||
|
|
||||||
if (!add) {
|
if (!add) {
|
||||||
bool unlink_failed = false;
|
int unlink_error = 0, stat_error = 0;
|
||||||
|
|
||||||
if (stat(dirname, &st) < 0) {
|
if (stat(dirname, &st) < 0) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return 0; /* The stack directory is already removed. That's OK. */
|
return 0; /* The stack directory is already removed. That's OK. */
|
||||||
log_device_debug_errno(dev, errno, "Failed to stat %s, ignoring: %m", dirname);
|
stat_error = -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlink(filename) < 0) {
|
if (unlink(filename) < 0)
|
||||||
unlink_failed = true;
|
unlink_error = -errno;
|
||||||
if (errno != ENOENT)
|
|
||||||
log_device_debug_errno(dev, errno, "Failed to remove %s, ignoring: %m", filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rmdir(dirname) >= 0 || errno == ENOENT)
|
if (rmdir(dirname) >= 0 || errno == ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (unlink_failed)
|
if (unlink_error < 0) {
|
||||||
return 0; /* If we failed to remove the symlink, there is almost nothing we can do. */
|
if (unlink_error == -ENOENT)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* If we failed to remove the symlink, then there is almost nothing we can do. */
|
||||||
|
return log_device_debug_errno(dev, unlink_error, "Failed to remove %s: %m", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat_error < 0)
|
||||||
|
return log_device_debug_errno(dev, stat_error, "Failed to stat %s: %m", dirname);
|
||||||
|
|
||||||
/* The symlink was removed. Check if the timestamp of directory is changed. */
|
/* The symlink was removed. Check if the timestamp of directory is changed. */
|
||||||
r = update_timestamp(dev, dirname, &st);
|
r = update_timestamp(dev, dirname, &st);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user