chiark / gitweb /
systemctl: hook up new install logic
[elogind.git] / src / install.c
index e1c69444f99a7d9ea500be597437e620578b2879..b843ee156b5e9843f1a34023339170b00b1d7a33 100644 (file)
@@ -126,8 +126,6 @@ static int add_file_change(
         UnitFileChange *c;
         unsigned i;
 
-        assert(type >= 0);
-        assert(type < _UNIT_FILE_CHANGE_TYPE_MAX);
         assert(path);
         assert(!changes == !n_changes);
 
@@ -1414,6 +1412,10 @@ int unit_file_enable(
                         goto finish;
         }
 
+        /* This will return the number of symlink rules that were
+        supposed to be created, not the ones actually created. This is
+        useful to determine whether the passed files hat any
+        installation data at all. */
         r = install_context_apply(&c, &paths, config_path, root_dir, force, changes, n_changes);
 
 finish:
@@ -1462,7 +1464,7 @@ int unit_file_disable(
 
         q = remove_marked_symlinks(remove_symlinks_to, config_path, changes, n_changes);
         if (r == 0)
-                r = 1;
+                r = q;
 
 finish:
         install_context_done(&c);
@@ -1514,6 +1516,7 @@ int unit_file_reenable(
 
         r = remove_marked_symlinks(remove_symlinks_to, config_path, changes, n_changes);
 
+        /* Returns number of symlinks that where supposed to be installed. */
         q = install_context_apply(&c, &paths, config_path, root_dir, force, changes, n_changes);
         if (r == 0)
                 r = q;
@@ -1763,6 +1766,7 @@ int unit_file_preset(
         if (r == 0)
                 r = q;
 
+        /* Returns number of symlinks that where supposed to be installed. */
         q = install_context_apply(&plus, &paths, config_path, root_dir, force, changes, n_changes);
         if (r == 0)
                 r = q;
@@ -1874,7 +1878,7 @@ int unit_file_get_list(
                         }
 
                         r = null_or_empty_path(f->path);
-                        if (r < 0) {
+                        if (r < 0 && r != -ENOENT) {
                                 free(f->path);
                                 free(f);
                                 goto finish;
@@ -1942,3 +1946,10 @@ static const char* const unit_file_state_table[_UNIT_FILE_STATE_MAX] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP(unit_file_state, UnitFileState);
+
+static const char* const unit_file_change_type_table[_UNIT_FILE_CHANGE_TYPE_MAX] = {
+        [UNIT_FILE_SYMLINK] = "symlink",
+        [UNIT_FILE_UNLINK] = "unlink",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(unit_file_change_type, UnitFileChangeType);