diff options
-rw-r--r-- | lib/active.c | 28 | ||||
-rw-r--r-- | lib/initd.h | 2 | ||||
-rw-r--r-- | lib/installrm.c | 4 | ||||
-rw-r--r-- | lib/rdep.c | 12 |
4 files changed, 29 insertions, 17 deletions
diff --git a/lib/active.c b/lib/active.c index 88845ab..232f90a 100644 --- a/lib/active.c +++ b/lib/active.c @@ -56,25 +56,29 @@ void initd_list_set_actives(initd_list_t *ilp, const char *dir) free(cwd); } -bool initd_is_active(const initd_t *ip, initd_rc_t rc, initd_sk_t sk) +bool initd_is_active(const initd_t *ip, initd_rc_t rc, initd_key_t key) { + initd_rc_t match; + if (!ip) return false; - switch (sk) { - case SK_START: - if (ip->astart & rc) - return true; - else - return false; - case SK_STOP: - if (ip->astop & rc) - return true; - else - return false; + switch (key) { + case KEY_ASTART: + match = ip->astart; + break; + case KEY_ASTOP: + match = ip->astop; + break; default: + /* Wrong key type */ return false; } + + if (match & rc) + return true; + else + return false; } static bool read_dir_symlinks(initd_list_t *ilp, const struct rcpair *rcp) diff --git a/lib/initd.h b/lib/initd.h index 526b634..e6b8e23 100644 --- a/lib/initd.h +++ b/lib/initd.h @@ -53,7 +53,7 @@ extern bool initd_provides(const initd_t *ip, const char *serv); extern bool initd_list_provides(const initd_list_t *ilp, const char *serv); extern bool initd_is_active(const initd_t *ip, initd_rc_t rc, - initd_sk_t sk); + initd_key_t key); extern char *initd_verify_deps(const initd_list_t *ilp, const initd_t *ip, initd_key_t key); extern char *initd_list_verify_all(const initd_list_t *ilp); diff --git a/lib/installrm.c b/lib/installrm.c index d0549b3..abea9ac 100644 --- a/lib/installrm.c +++ b/lib/installrm.c @@ -104,7 +104,7 @@ static void install_level_links(const initd_list_t *ilp, if (sk == SK_START) { for (ip = ilp->first; ip; ip = ip->next) { /* skip script if not active in this level */ - if (!initd_is_active(ip, rc, sk)) + if (!initd_is_active(ip, rc, KEY_ASTART)) continue; remove_existing_link(ip, dir, sk); @@ -112,7 +112,7 @@ static void install_level_links(const initd_list_t *ilp, } else { for (ip = ilp->last; ip; ip = ip->prev) { /* skip script if not active in this level */ - if (!initd_is_active(ip, rc, sk)) + if (!initd_is_active(ip, rc, KEY_ASTOP)) continue; remove_existing_link(ip, dir, sk); @@ -77,6 +77,7 @@ initd_list_t *initd_remove_recurse_deps(initd_list_t *pool, int n; dep_t *all_active = NULL; char *rm; + initd_key_t key; if (!pool) goto out; @@ -91,6 +92,11 @@ initd_list_t *initd_remove_recurse_deps(initd_list_t *pool, /* initialize the initd save list */ save = initd_list_new(); + if (sk == SK_START) + key = KEY_ASTART; + else + key = KEY_ASTOP; + /* Check that the specified services to remove are in the pool. * If they are, add them to a saved list so we can clear their * active field and then restore it afterwards. */ @@ -102,7 +108,7 @@ initd_list_t *initd_remove_recurse_deps(initd_list_t *pool, rm); goto err; } - if (initd_is_active(orig, RC_ALL, sk)) { + if (initd_is_active(orig, RC_ALL, key)) { copy = initd_copy(orig); initd_list_add(save, copy); orig->astart = orig->astop = 0; @@ -196,13 +202,15 @@ static dep_t *add_all_active(const initd_list_t *pool, { dep_t *active; initd_t *ip; + initd_key_t key; if (!pool) return NULL; active = dep_copy(init); + key = (sk == SK_START) ? KEY_ASTART : KEY_ASTOP; for (ip = pool->first; ip; ip = ip->next) { - if (initd_is_active(ip, RC_ALL, sk)) + if (initd_is_active(ip, RC_ALL, key)) dep_add(active, ip->name); } |