]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: when looping over mount/swap names, continue if we find one which doesn't trans...
authorLennart Poettering <lennart@poettering.net>
Tue, 1 Jun 2021 20:20:55 +0000 (22:20 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 1 Jun 2021 21:08:21 +0000 (23:08 +0200)
src/core/swap.c
src/core/unit.c

index 74da2428c2993d21375899180c9b521316668b8f..ecf42ad1196c7fd1b6714446804b06b4a7aef6b5 100644 (file)
@@ -1448,6 +1448,9 @@ 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 */
+                        continue;
                 if (q < 0)
                         return q;
 
index dbdf7d9b372d458b22760abe7d17fb2903dc4b4b..4332263a9a687448e887ff0f3751d3756c86c5bc 100644 (file)
@@ -1473,16 +1473,17 @@ static int unit_add_mount_dependencies(Unit *u) {
                         Unit *m;
 
                         r = unit_name_from_path(prefix, ".mount", &p);
+                        if (IN_SET(r, -EINVAL, -ENAMETOOLONG))
+                                continue; /* If the path cannot be converted to a mount unit name, then it's
+                                           * not managable as a unit by systemd, and hence we don't need a
+                                           * dependency on it. Let's thus silently ignore the issue. */
                         if (r < 0)
                                 return r;
 
                         m = manager_get_unit(u->manager, p);
                         if (!m) {
-                                /* Make sure to load the mount unit if
-                                 * it exists. If so the dependencies
-                                 * on this unit will be added later
-                                 * during the loading of the mount
-                                 * unit. */
+                                /* Make sure to load the mount unit if it exists. If so the dependencies on
+                                 * this unit will be added later during the loading of the mount unit. */
                                 (void) manager_load_unit_prepare(u->manager, p, NULL, NULL, &m);
                                 continue;
                         }