return 1;
}
+static int _control_unlink(const char *control)
+{
+ if (unlink(control) && (errno != ENOENT)) {
+ log_sys_error("unlink", control);
+ return -1;
+ }
+
+ return 0;
+}
+
/*
* Returns 1 if it exists on returning; 0 if it doesn't; -1 if it's wrong.
*/
if (!S_ISCHR(buf.st_mode)) {
log_verbose("%s: Wrong inode type", control);
- if (!unlink(control))
- return 0;
- log_sys_error("unlink", control);
- return -1;
+ return _control_unlink(control);
}
if (major && buf.st_rdev != MKDEV(major, minor)) {
"(%u, %u)", control,
MAJOR(buf.st_mode), MINOR(buf.st_mode),
major, minor);
- if (!unlink(control))
- return 0;
- log_sys_error("unlink", control);
- return -1;
+ return _control_unlink(control);
}
return 1;
if (info.st_rdev == dev)
return 1;
- if (unlink(path) < 0) {
- log_error("Unable to unlink device node for '%s'",
- dev_name);
+ if (unlink(path) && (errno != ENOENT)) {
+ log_sys_error("unlink", path);
return 0;
}
} else if (_warn_if_op_needed(warn_if_udev_failed))
"Falling back to direct node removal.", path);
/* udev may already have deleted the node. Ignore ENOENT. */
- if (unlink(path) < 0 && errno != ENOENT) {
- log_error("Unable to unlink device node for '%s'", dev_name);
+ if (unlink(path) && (errno != ENOENT)) {
+ log_sys_error("unlink", path);
return 0;
}
return 1;
}
+static int _control_unlink(const char *control)
+{
+ if (unlink(control) && (errno != ENOENT)) {
+ log_sys_error("unlink", control);
+ return -1;
+ }
+
+ return 0;
+}
+
/*
* Returns 1 if it exists on returning; 0 if it doesn't; -1 if it's wrong.
*/
if (!S_ISCHR(buf.st_mode)) {
log_verbose("%s: Wrong inode type", control);
- if (!unlink(control))
- return 0;
- log_sys_error("unlink", control);
- return -1;
+ return _control_unlink(control);
}
if (major && buf.st_rdev != MKDEV(major, minor)) {
"(%u, %u)", control,
MAJOR(buf.st_mode), MINOR(buf.st_mode),
major, minor);
- if (!unlink(control))
- return 0;
- log_sys_error("unlink", control);
- return -1;
+ return _control_unlink(control);
}
return 1;
if (info.st_rdev == dev)
return 1;
- if (unlink(path) < 0) {
- log_error("Unable to unlink device node for '%s'",
- dev_name);
+ if (unlink(path) && (errno != ENOENT)) {
+ log_sys_error("unlink", path);
return 0;
}
} else if (_warn_if_op_needed(warn_if_udev_failed))
"Falling back to direct node removal.", path);
/* udev may already have deleted the node. Ignore ENOENT. */
- if (unlink(path) < 0 && errno != ENOENT) {
- log_error("Unable to unlink device node for '%s'", dev_name);
+ if (unlink(path) && (errno != ENOENT)) {
+ log_sys_error("unlink", path);
return 0;
}