sysv-generator: initialize LookupPaths just once
With debugging on, sysv-generator would print the full set of lookup paths for *every* sysv script. While at it, pass LookupPaths as a pointer in sysv-generator, and constify it everywhere.
This commit is contained in:
@@ -719,10 +719,10 @@ static int fix_order(SysvStub *s, Hashmap *all_services) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
|
||||
static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) {
|
||||
char **path;
|
||||
|
||||
STRV_FOREACH(path, lp.sysvinit_path) {
|
||||
STRV_FOREACH(path, lp->sysvinit_path) {
|
||||
_cleanup_closedir_ DIR *d = NULL;
|
||||
struct dirent *de;
|
||||
|
||||
@@ -764,7 +764,7 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
|
||||
if (!fpath)
|
||||
return log_oom();
|
||||
|
||||
if (unit_file_get_state(UNIT_FILE_SYSTEM, NULL, name) >= 0) {
|
||||
if (unit_file_lookup_state(UNIT_FILE_SYSTEM, NULL, lp, name) >= 0) {
|
||||
log_debug("Native unit for %s already exists, skipping", name);
|
||||
continue;
|
||||
}
|
||||
@@ -789,7 +789,7 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
|
||||
static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_services) {
|
||||
char **p;
|
||||
unsigned i;
|
||||
_cleanup_closedir_ DIR *d = NULL;
|
||||
@@ -800,7 +800,7 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
|
||||
_cleanup_set_free_ Set *shutdown_services = NULL;
|
||||
int r = 0;
|
||||
|
||||
STRV_FOREACH(p, lp.sysvrcnd_path)
|
||||
STRV_FOREACH(p, lp->sysvrcnd_path)
|
||||
for (i = 0; i < ELEMENTSOF(rcnd_table); i ++) {
|
||||
struct dirent *de;
|
||||
|
||||
@@ -950,13 +950,13 @@ int main(int argc, char *argv[]) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
r = enumerate_sysv(lp, all_services);
|
||||
r = enumerate_sysv(&lp, all_services);
|
||||
if (r < 0) {
|
||||
log_error("Failed to generate units for all init scripts.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
r = set_dependencies_from_rcnd(lp, all_services);
|
||||
r = set_dependencies_from_rcnd(&lp, all_services);
|
||||
if (r < 0) {
|
||||
log_error("Failed to read runlevels from rcnd links.");
|
||||
return EXIT_FAILURE;
|
||||
|
||||
Reference in New Issue
Block a user