From: Zbigniew Jędrzejewski-Szmek Date: Tue, 3 May 2016 20:24:09 +0000 (-0400) Subject: Merge pull request #3183 from crawford/preset-array X-Git-Tag: v230~88 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=348dc14569eebfb7a1fbab59ba2f5b2228b5b25e;p=thirdparty%2Fsystemd.git Merge pull request #3183 from crawford/preset-array install: cache the presets before evaluating --- 348dc14569eebfb7a1fbab59ba2f5b2228b5b25e diff --cc src/shared/install.c index f02d81504fa,d2799bf0df2..cc36da18539 --- a/src/shared/install.c +++ b/src/shared/install.c @@@ -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;