(void) device_update_description(u, dev, path);
- /* So the user wants the mount units to be bound to the device but a mount unit might has been seen by systemd
- * before the device appears on its radar. In this case the device unit is partially initialized and includes
- * the deps on the mount unit but at that time the "bind mounts" flag wasn't not present. Fix this up now. */
+ /* So the user wants the mount units to be bound to the device but a mount unit might has been seen
+ * by systemd before the device appears on its radar. In this case the device unit is partially
+ * initialized and includes the deps on the mount unit but at that time the "bind mounts" flag wasn't
+ * present. Fix this up now. */
if (dev && device_is_bound_by_mounts(DEVICE(u), dev))
device_upgrade_mount_deps(u);
return r;
}
-static int device_process_new(Manager *m, sd_device *dev) {
+static void device_process_new(Manager *m, sd_device *dev) {
const char *sysfs, *dn, *alias;
dev_t devnum;
int r;
assert(m);
if (sd_device_get_syspath(dev, &sysfs) < 0)
- return 0;
+ return;
- /* Add the main unit named after the sysfs path */
- r = device_setup_unit(m, dev, sysfs, true);
- if (r < 0)
- return r;
+ /* Add the main unit named after the sysfs path. If this one fails, don't bother with the rest, as
+ * this one shall be the main device unit the others just follow. (Compare with how
+ * device_following() is implemented, see below, which looks for the sysfs device.) */
+ if (device_setup_unit(m, dev, sysfs, true) < 0)
+ return;
/* Add an additional unit for the device node */
if (sd_device_get_devname(dev, &dn) >= 0)
if (PATH_STARTSWITH_SET(p, "/dev/block/", "/dev/char/"))
continue;
- /* Verify that the symlink in the FS actually belongs
- * to this device. This is useful to deal with
- * conflicting devices, e.g. when two disks want the
- * same /dev/disk/by-label/xxx link because they have
- * the same label. We want to make sure that the same
- * device that won the symlink wins in systemd, so we
- * check the device node major/minor */
+ /* Verify that the symlink in the FS actually belongs to this device. This is useful
+ * to deal with conflicting devices, e.g. when two disks want the same
+ * /dev/disk/by-label/xxx link because they have the same label. We want to make sure
+ * that the same device that won the symlink wins in systemd, so we check the device
+ * node major/minor */
if (stat(p, &st) >= 0 &&
((!S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode)) ||
st.st_rdev != devnum))
/* Add additional units for all explicitly configured aliases */
if (sd_device_get_property_value(dev, "SYSTEMD_ALIAS", &alias) < 0)
- return 0;
+ return;
for (;;) {
_cleanup_free_ char *word = NULL;
if (r == 0)
break;
if (r == -ENOMEM)
- return log_oom();
+ return (void) log_oom();
if (r < 0)
- return log_device_warning_errno(dev, r, "Failed to parse SYSTEMD_ALIAS property: %m");
+ return (void) log_device_warning_errno(dev, r, "Failed to parse SYSTEMD_ALIAS property, ignoring: %m");
if (!path_is_absolute(word))
log_device_warning(dev, "SYSTEMD_ALIAS is not an absolute path, ignoring: %s", word);
else
(void) device_setup_unit(m, dev, word, false);
}
-
- return 0;
}
static void device_found_changed(Device *d, DeviceFound previous, DeviceFound now) {
if (!device_is_ready(dev))
continue;
- (void) device_process_new(m, dev);
+ device_process_new(m, dev);
if (sd_device_get_syspath(dev, &sysfs) < 0)
continue;
} else if (device_is_ready(dev)) {
- (void) device_process_new(m, dev);
+ device_process_new(m, dev);
r = swap_process_device_new(m, dev);
if (r < 0)