]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/install: add some more debug messages and comments
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 4 May 2016 14:09:52 +0000 (10:09 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 9 May 2016 19:17:55 +0000 (15:17 -0400)
$ systemctl --root=/ preset foobar.service
Cannot find unit foobar.service.
Failed to preset: No such file or directory.
$ systemctl --root=/ preset foobar@.service
Cannot find unit foobar@.service.
Failed to preset: No such file or directory.
$ systemctl --root=/ preset foobar@blah.service
Cannot find unit foobar@blah.service or foobar@.service.
Failed to preset: No such file or directory.

src/shared/install.c

index f0b63506a911a7e695e5fbb42d06d81e3f87d227..427e5eaf7b4335b76e6f6e327074021015fc0100 100644 (file)
@@ -116,6 +116,14 @@ bool unit_type_may_template(UnitType type) {
                       UNIT_PATH);
 }
 
+static const char *unit_file_type_table[_UNIT_FILE_TYPE_MAX] = {
+        [UNIT_FILE_TYPE_REGULAR] = "regular",
+        [UNIT_FILE_TYPE_SYMLINK] = "symlink",
+        [UNIT_FILE_TYPE_MASKED] = "masked",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(unit_file_type, UnitFileType);
+
 static int in_search_path(const LookupPaths *p, const char *path) {
         _cleanup_free_ char *parent = NULL;
         char **i;
@@ -1223,6 +1231,7 @@ static int unit_file_search(
                 const LookupPaths *paths,
                 SearchFlags flags) {
 
+        _cleanup_free_ char *template = NULL;
         char **p;
         int r;
 
@@ -1260,8 +1269,6 @@ static int unit_file_search(
                  * enablement was requested.  We will check if it is
                  * possible to load template unit file. */
 
-                _cleanup_free_ char *template = NULL;
-
                 r = unit_name_template(info->name, &template);
                 if (r < 0)
                         return r;
@@ -1283,6 +1290,7 @@ static int unit_file_search(
                 }
         }
 
+        log_debug("Cannot find unit %s%s%s.", info->name, template ? " or " : "", strempty(template));
         return -ENOENT;
 }
 
@@ -1314,6 +1322,11 @@ static int install_info_follow(
         return unit_file_load_or_readlink(c, i, i->path, root_dir, flags);
 }
 
+/**
+ * Search for the unit file. If the unit name is a symlink,
+ * follow the symlink to the target, maybe more than once.
+ * Propagate the instance name if present.
+ */
 static int install_info_traverse(
                 UnitFileScope scope,
                 InstallContext *c,
@@ -1684,8 +1697,12 @@ static int install_context_mark_for_removal(
                 if (r < 0)
                         return r;
 
-                if (i->type != UNIT_FILE_TYPE_REGULAR)
+                if (i->type != UNIT_FILE_TYPE_REGULAR) {
+                        log_debug("Unit %s has type %s, ignoring.",
+                                  i->name,
+                                  unit_file_type_to_string(i->type) ?: "invalid");
                         continue;
+                }
 
                 r = mark_symlink_for_removal(remove_symlinks_to, i->name);
                 if (r < 0)