]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #3183 from crawford/preset-array
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 3 May 2016 20:24:09 +0000 (16:24 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 3 May 2016 20:24:09 +0000 (16:24 -0400)
install: cache the presets before evaluating

1  2 
src/shared/install.c
src/test/test-install-root.c

index f02d81504faac3d5e836f7d2fd0e60d5d0a1b64b,d2799bf0df294eaa7f4ee4289f005e6f92ef5259..cc36da185396d869b6b7f0ce848a9d85f7ab96b8
@@@ -66,27 -66,37 +66,56 @@@ typedef struct 
          OrderedHashmap *have_processed;
  } InstallContext;
  
+ typedef enum {
+         PRESET_UNKNOWN,
+         PRESET_ENABLE,
+         PRESET_DISABLE,
+ } PresetAction;
+ typedef struct {
+         char *pattern;
+         PresetAction action;
+ } PresetRule;
+ typedef struct {
+         PresetRule *rules;
+         size_t n_rules;
+ } Presets;
+ static inline void presets_freep(Presets *p) {
+         size_t i;
+         if (!p)
+                 return;
+         for (i = 0; i < p->n_rules; i++)
+                 free(p->rules[i].pattern);
+         free(p->rules);
+         p->n_rules = 0;
+ }
  static int unit_file_lookup_state(UnitFileScope scope, const LookupPaths *paths, const char *name, UnitFileState *ret);
  
 +bool unit_type_may_alias(UnitType type) {
 +        return IN_SET(type,
 +                      UNIT_SERVICE,
 +                      UNIT_SOCKET,
 +                      UNIT_TARGET,
 +                      UNIT_DEVICE,
 +                      UNIT_TIMER,
 +                      UNIT_PATH);
 +}
 +
 +bool unit_type_may_template(UnitType type) {
 +        return IN_SET(type,
 +                      UNIT_SERVICE,
 +                      UNIT_SOCKET,
 +                      UNIT_TARGET,
 +                      UNIT_TIMER,
 +                      UNIT_PATH);
 +}
 +
  static int in_search_path(const LookupPaths *p, const char *path) {
          _cleanup_free_ char *parent = NULL;
          char **i;
Simple merge