]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: unit_name_from_path() does not return -ENAMETOOLONG anymore
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 13 May 2022 02:40:55 +0000 (11:40 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Aug 2022 16:34:55 +0000 (01:34 +0900)
Follow-ups for a7fb1f2eae3314c28d451822302283a7ab1bc1c0 and
1d0727e76fd5e9a07cc9991ec9a10ea1d78a99c7.

src/core/mount.c
src/core/swap.c
src/core/unit.c

index 8aaa9e966b9d9d7e9089b4c756d9be1d00abd6ab..4263610e8281a2eb576c190f2976ac0274ec7620 100644 (file)
@@ -1717,37 +1717,14 @@ static int mount_setup_unit(
         if (!is_path(where))
                 return 0;
 
-        /* Mount unit names have to be (like all other unit names) short enough to fit into file names. This
-         * means there's a good chance that overly long mount point paths after mangling them to look like a
-         * unit name would result in unit names we don't actually consider valid. This should be OK however
-         * as such long mount point paths should not happen on regular systems — and if they appear
-         * nonetheless they are generally synthesized by software, and thus managed by that other
-         * software. Having such long names just means you cannot use systemd to manage those specific mount
-         * points, which should be an OK restriction to make. After all we don't have to be able to manage
-         * all mount points in the world — as long as we don't choke on them when we encounter them. */
         r = unit_name_from_path(where, ".mount", &e);
-        if (r < 0) {
-                static RateLimit rate_limit = { /* Let's log about this at warning level at most once every
-                                                 * 5s. Given that we generate this whenever we read the file
-                                                 * otherwise we probably shouldn't flood the logs with
-                                                 * this */
-                        .interval = 5 * USEC_PER_SEC,
-                        .burst = 1,
-                };
-
-                if (r == -ENAMETOOLONG)
-                        return log_struct_errno(
-                                        ratelimit_below(&rate_limit) ? LOG_WARNING : LOG_DEBUG, r,
-                                        "MESSAGE_ID=" SD_MESSAGE_MOUNT_POINT_PATH_NOT_SUITABLE_STR,
-                                        "MOUNT_POINT=%s", where,
-                                        LOG_MESSAGE("Mount point path '%s' too long to fit into unit name, ignoring mount point.", where));
-
+        if (r < 0)
                 return log_struct_errno(
-                                ratelimit_below(&rate_limit) ? LOG_WARNING : LOG_DEBUG, r,
+                                LOG_WARNING, r,
                                 "MESSAGE_ID=" SD_MESSAGE_MOUNT_POINT_PATH_NOT_SUITABLE_STR,
                                 "MOUNT_POINT=%s", where,
-                                LOG_MESSAGE("Failed to generate valid unit name from mount point path '%s', ignoring mount point: %m", where));
-        }
+                                LOG_MESSAGE("Failed to generate valid unit name from mount point path '%s', ignoring mount point: %m",
+                                            where));
 
         u = manager_get_unit(m, e);
         if (u)
index 222c76cf79c28438be431d42b58456c97c02f4cb..2d1190d0182c21942904349011867a3dbbb1354b 100644 (file)
@@ -1437,8 +1437,7 @@ int swap_process_device_new(Manager *m, sd_device *dev) {
                 int q;
 
                 q = unit_name_from_path(devlink, ".swap", &n);
-                if (IN_SET(q, -EINVAL, -ENAMETOOLONG)) /* If name too long or otherwise not convertible to
-                                                        * unit name, we can't manage it */
+                if (q == -EINVAL) /* If the name is not convertible to unit name, we can't manage it */
                         continue;
                 if (q < 0)
                         return q;
index a082741bf84f1aca2a3901d8fd88a87ba14ed2d2..07c83c90a4c1e0aa9b8ae929f69407b962ea166a 100644 (file)
@@ -1519,7 +1519,7 @@ static int unit_add_mount_dependencies(Unit *u) {
                         Unit *m;
 
                         r = unit_name_from_path(prefix, ".mount", &p);
-                        if (IN_SET(r, -EINVAL, -ENAMETOOLONG))
+                        if (r == -EINVAL)
                                 continue; /* If the path cannot be converted to a mount unit name, then it's
                                            * not manageable as a unit by systemd, and hence we don't need a
                                            * dependency on it. Let's thus silently ignore the issue. */