-static int priority_from_rcd(Service *s, const char *init_script) {
- char **p;
- unsigned i;
-
- STRV_FOREACH(p, UNIT(s)->meta.manager->sysvrcnd_path)
- for (i = 0; i < ELEMENTSOF(rcnd_table); i += 2) {
- char *path;
- DIR *d;
- struct dirent *de;
-
- if (asprintf(&path, "%s/%s", *p, rcnd_table[i]) < 0)
- return -ENOMEM;
-
- d = opendir(path);
- free(path);
-
- if (!d) {
- if (errno != ENOENT)
- log_warning("opendir() failed on %s: %s", path, strerror(errno));
-
- continue;
- }
-
- while ((de = readdir(d))) {
- int a, b;
-
- if (ignore_file(de->d_name))
- continue;
-
- if (de->d_name[0] != 'S')
- continue;
-
- if (strlen(de->d_name) < 4)
- continue;
-
- if (!streq(de->d_name + 3, init_script))
- continue;
-
- /* Yay, we found it! Now decode the priority */
-
- a = undecchar(de->d_name[1]);
- b = undecchar(de->d_name[2]);
-
- if (a < 0 || b < 0)
- continue;
-
- s->sysv_start_priority = a*10 + b;
-
- log_debug("Determined priority %i from link farm for %s", s->sysv_start_priority, UNIT(s)->meta.id);
-
- closedir(d);
- return 0;
- }
-
- closedir(d);
- }
-
- return 0;
-}
-