~ubuntu-branches/ubuntu/oneiric/insserv/oneiric-proposed

« back to all changes in this revision

Viewing changes to listing.c

  • Committer: Bazaar Package Importer
  • Author(s): Petter Reinholdtsen
  • Date: 2006-11-02 13:36:10 UTC
  • mfrom: (2.1.1 edgy)
  • Revision ID: james.westby@ubuntu.com-20061102133610-gh6e1y750pwc0id7
Tags: 1.08.0-11
* Add override file for timidity.
* Add override file for powernowd.
* Add override file for laptop-mode.
* Update override file for libnss-ldap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    list_t            d_list;   /* The linked list to other directories */
46
46
    list_t              link;   /* symbolic links in this directory */
47
47
    unsigned int       flags;
48
 
    char               order;
 
48
    char              minord;   /* Default order deep if any */
 
49
    char               order;   /* Current order deep */
49
50
    char              * name;
50
51
    char            * script;
51
52
    unsigned int         lvl;
79
80
        ptr = d_start->prev;
80
81
        this->name   = xstrdup(name);
81
82
        this->script = NULL;
 
83
        this->minord = 1;
82
84
        this->order  = 0;
83
85
        this->flags  = 0;
84
86
        this->lvl    = 0;
118
120
}
119
121
 
120
122
/*
121
 
 * Link a provided service into a required service.
 
123
 * Link the current service into the required service.
122
124
 * If the services do not exist, they will be created.
123
125
 */
124
 
static void ln_sf(const char * isprovided, const char * itrequires)
 
126
static void ln_sf(const char * current, const char * required)
125
127
{
126
 
    dir_t * target = providedir(isprovided);
127
 
    dir_t * dir    = providedir(itrequires);
 
128
    dir_t * target = providedir(current);
 
129
    dir_t * dir    = providedir(required);
128
130
    list_t * l_start = &(dir->link);
129
131
    list_t * dent;
130
132
    link_t * this;
134
136
 
135
137
    list_for_each(dent, l_start) {
136
138
        dir_t * target = getlink(dent)->target;
137
 
        if (!strcmp(target->name, isprovided))
 
139
        if (!strcmp(target->name, current))
138
140
            goto out;
139
141
    }
140
142
 
170
172
 * links within a service dir.
171
173
 * Just like a `find * -follow' within a directory tree
172
174
 * of depth one with cross linked dependencies.
 
175
 *
 
176
 * Be warned: the direction is naturally reversed.  That
 
177
 * means that the most requested services have the lowest
 
178
 * order.  In other word, an empty link list of a service
 
179
 * indicates that this service has a higher order number.
173
180
 */
174
181
#if defined(DEBUG) && (DEBUG > 0)
175
182
# define loop_warn_two(a,b)     \
206
213
        return;
207
214
    }
208
215
 
 
216
    if (deep < dir->minord)     /* Default order deep of this tree is higher */
 
217
        deep = dir->minord;
 
218
 
209
219
    if (deep > MAX_DEEP) {
210
220
        if (!warned)
211
221
            warn("Max recursions depth %d reached\n",  MAX_DEEP);
240
250
        /*
241
251
         * As higher the link depth, as higher the start order.
242
252
         */
243
 
        if (tmp->order > deep) {
 
253
        if (tmp->order > deep)
244
254
            deep = tmp->order;
245
 
        }
246
255
        if (tmp->order < deep)
247
256
            tmp->order = deep;
248
257
 
249
 
        if (++deep > MAX_DEEP)
 
258
        if (list_empty(&(tmp->link)))
 
259
            break;              /* No further service requires this one */
 
260
 
 
261
        /*
 
262
         * Do not count the dependcy deep of the system facilities
 
263
         * but follow them to count the replacing provides.
 
264
         */
 
265
        if ((*tmp->name != '$') && (++deep > MAX_DEEP)) {
 
266
            if (!warned)
 
267
                warn("Max recursions depth %d reached\n",  MAX_DEEP);
 
268
                warned = true;
250
269
            break;
 
270
        }
251
271
 
252
272
        tmp->flags |= DIR_SCAN; /* Mark this service for loop detection */
253
273
 
273
293
                break;          /* Loop detected, stop recursion */
274
294
            }
275
295
 
276
 
            __follow(target, tmp, deep);        /* inner recursion */
 
296
            __follow(target, tmp, deep);        /* The inner recursion */
277
297
 
278
298
            /* Just for the case an inner recursion was stopped */
279
299
            if (loop_check(target) || loop_check(tmp) || loop_check(skip)) {
299
319
inline static void follow(dir_t * dir)
300
320
{
301
321
    /* Link depth starts here with one */
302
 
    __follow(dir, NULL, 1);
 
322
    __follow(dir, NULL, dir->minord);
303
323
}
304
324
 
305
325
/*
617
637
    if (!dir)
618
638
        goto out;
619
639
 
620
 
    if (dir->order >= order) /* nothing to do */
 
640
    if (dir->minord < order)
 
641
        dir->minord = order;            /* Remember lowest default order deep */
 
642
 
 
643
    if (dir->order >= dir->minord)      /* Nothing to do */
621
644
        goto out;
622
645
 
623
646
    if (!recursive) {
624
 
        dir->order = order;
 
647
        dir->order = dir->minord;
625
648
        goto out;
626
649
    }
627
650
 
628
651
    /*
629
652
     * Follow the script and re-calculate the ordering.
630
653
     */
631
 
    __follow(dir, NULL, order);
 
654
    __follow(dir, NULL, dir->minord);
632
655
 
633
656
    /*
634
657
     * Guess order of not installed scripts in comparision