Skip to content

Commit

Permalink
core/device: unit_name_from_path() does not return -ENAMETOOLONG anymore
Browse files Browse the repository at this point in the history
Follow-up for 1d0727e.
  • Loading branch information
yuwata committed Apr 29, 2022
1 parent 47e7217 commit a7fb1f2
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions src/core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,32 +490,12 @@ static int device_setup_unit(Manager *m, sd_device *dev, const char *path, bool
}

r = unit_name_from_path(path, ".device", &e);
if (r < 0) {
/* Let's complain about overly long device names only at most once every 5s or so. This is
* something we should mention, since relevant devices are not manageable by systemd, but not
* flood the log about. */
static RateLimit rate_limit = {
.interval = 5 * USEC_PER_SEC,
.burst = 1,
};

/* If we cannot convert a device name to a unit name then let's ignore the device. So far,
* devices with such long names weren't really the kind you want to manage with systemd
* anyway, hence this shouldn't be a problem. */

if (r == -ENAMETOOLONG)
return log_struct_errno(
ratelimit_below(&rate_limit) ? LOG_WARNING : LOG_DEBUG, r,
"MESSAGE_ID=" SD_MESSAGE_DEVICE_PATH_NOT_SUITABLE_STR,
"DEVICE=%s", path,
LOG_MESSAGE("Device path '%s' too long to fit into unit name, ignoring device.", path));

if (r < 0)
return log_struct_errno(
ratelimit_below(&rate_limit) ? LOG_WARNING : LOG_DEBUG, r,
LOG_WARNING, r,
"MESSAGE_ID=" SD_MESSAGE_DEVICE_PATH_NOT_SUITABLE_STR,
"DEVICE=%s", path,
LOG_MESSAGE("Failed to generate valid unit name from device path '%s', ignoring device: %m", path));
}

u = manager_get_unit(m, e);
if (u) {
Expand Down

0 comments on commit a7fb1f2

Please sign in to comment.