Age | Commit message (Collapse) | Author | Files | Lines |
|
Wasn't even build tested, apparently.
|
|
This still doesn't do a great job of handling errors, but at least the
user may see some reasonable information if they occur.
|
|
Since we can now have an arbitrary number of nodes pointing to the same
initd type, a reference count is added so that the initd is only
destroyed when there are no references left.
|
|
Currently, the entire initd structure is duplicated each time a list is
copied. Since the initd is not specific to each list, this could cause
problems where changing a value in one initd would not be reflected in
the equivalent initd in another list. This also wastes memory as each
initd duplicated when only one copy is needed.
This change introduces the initd_node type. It points to an initd type
and contains the list pointers for inclusion in an initd_list type.
The typical constructors and destructors have been added for handling
these types in lists.
Quite a few places needed to be changed where there were iterations over
lists. We should really add accessor functions and use those whenever
we need access to members of a list.
|
|
|
|
After readdir completes, errno is check to see if any errors were
produced. However, if readdir is successful, it will not change the
current errno value. Reset it before the loop to ensure any errors are
due to the readdir calls.
|
|
When an missing dependency from Should-Start or Should-Stop was
encountered, all the processing was being skipped instead just moving to
the next dependency.
|
|
The logic for writing new stop links was walking through the ordered
list backwards, causing the stop links to be created incorrectly.
|
|
Trying to use the d_type field from the dirent structure returns
DT_UNKNOWN sometimes causing the pool to never be populated. Remove it
for now in favor of the more portable stat() usage.
|
|
When the user is installing links, they may not have the rc*.d
directories created yet. This changes the behavior to attempt to create
the directory if it doesn't exist.
|
|
Since the libinitd headers are used throughout the tree, we want to
avoid naming conflicts, such as util.h.
|
|
Rather than having all the programs include each header they need, just
have initd.h include all the headers that define interfaces in libinitd.
|
|
Added wrappers for the basename() and dirname() functions that handle
the copying of the strings correctly. The initd_parse routine has been
adjusted to use this wrapper instead of the libc version.
|
|
The dep removal logic was always adding the requested services to the
remove list, causing all links to be rewritten. Now, check if it's
active before adding it. This means that requesting to remove an
inactive script will just do nothing.
|
|
Fixed a bug where the removal process didn't actually include the
requested service in the set to be removed.
|
|
Previously, there was a single change field cstart/stop that was
overloaded to contain both installation and removal status. It was
difficult to differentiate between whether a service was to be removed,
to be installed, or unchanged.
This commit converts the change field into two dedicated fields,
instart/stop and rmstart/stop to differentiate the cases better.
|
|
There's no sane way to set the changed bits to active without destroying
valid deactived levels in some cases. Instead, we just have to rely on
the fact that they'll be correct already.
|
|
A few changes in the installrm functions:
- When removing an existing symlink, we clear the active bit for that
level.
- When installing a new link, we set the active bit for that level.
- Before installing a new link, we check that the script is supposed to
start in that level and that it's not marked for removal.
|
|
|
|
Added the initd_clear_rc function as the complement to initd_set_rc.
It clears level bits from an rc type in the initd. Refactored the rc_t
evaluation into a separate function, initd_get_rc_from_key.
|
|
When told to remove services through initd_remove_recurse_deps, their
changed fields are cleared to indicate that they will no longer be
available. This is an improvement over the previous hack where the
active bits were being cleared and then restored at the end of the
function.
With the changed fields cleared, we can skip services that are currently
active, but will be going away in add_all_actives. This fixes a bug
where a service can be asked to be removed, but then added right back in
because it's currently active.
When each rc level is verified after recursion has completed, the added
services are checked to see if they are marked for removal. This fixes a
bug where a service was asked to be removed, but added back because it
was a dependency of another service. When each service is verified at
that level, it is marked to change to active.
Using the changed field clearing in remove_recurse_deps and the setting
in verify_level, we should be able to install and remove scripts just by
checking the changed field.
Finally, fixed two tests which were passing with false positives due to
these bugs.
|
|
To differentiate between currently active rc levels and to-be-changed
rc levels, new members cstart and cstop have been added to the initd_t
type. These will be used in the dep solver to test for deps that are
marked for removal.
|
|
Another active field will be added, so we need to allow initd_is_active
to differentiate between them. Just using the sk type is not enough, so
now it takes the key name, returning false if an invalid key type was
passed.
|
|
The recurse_deps functions are now consistent in returning errors. Since
there are valid cases where an empty list may be returned, an error is
only indicated by returning NULL. This means callers of recurse_deps
must check that the list is not empty before iterating the members.
|
|
|
|
|
|
This adds the initd_installrm_links function and its helpers for
installing and removing symlinks. The function takes an ordered start or
kill list and the init.d directory to operate on. There is just a single
entry point since the determination of removal or addition is done in
the dependency ordering.
|
|
The rcpair struct and the static instances rcdirs and rcsdirs will be
reused, so they're moved into a separate internal header.
|
|
When scanning the rc?.d directories to find which services are active,
we now add paths to the active links in the initd_t astart_links and
astop_links fields. These paths are relative to the init.d directory,
e.g., ../rc1.d/S20foo.
|
|
When the rc?.d directories are walked, we'd like to cache the names of
the links in addition to just flagging the active levels. The names can
be used later when adding or removing links. To this effect, two new
members have been added to initd_t: astart_links and astop_links.
|
|
Added a new function, initd_remove_recurse_deps, which verifies that the
dependencies of the active services are still valid if specified
services are removed. There is a bit of hackery to play with the active
flags of the to-be-removed services and then restoring them.
A new test program, tremove, has been added to exercise this function.
It is basically the compliment to tverify (should be tinstall).
|
|
Forgot to add these before...
|
|
Renamed initd_recurse_deps to initd_add_recurse_deps in anticipation of
the recursive removal function, initd_remove_recurse_deps.
|
|
Made the enumerations for rc and sk clearer by changing the initd_sk_t
names to SK_START and SK_STOP.
|
|
After parsing the init.d directory with initd_list_from_dir, we call
initd_list_set_actives so it doesn't need to be explicitly called.
|
|
|
|
Parsing for the sysinit level in Default-Start/Stop was broken because
the unconditional atoi() would result in a valid level 0 for any input.
Now we check that the token is a single digit before converting it and
skip on to the sysinit checks otherwise.
|
|
Added new function initd_list_verify_deps, which takes an ordered list
of deps and verifies that they are valid for starting or stopping at
each level. Currently, this is just called from initd_recurse_deps.
The test program trdeps has been adjusted to set valid start and stop
levels to exercise this functionality.
|
|
Add the utility function initd_rc_level_char for converting an rc_t to
a char.
|
|
Conflicts:
lib/initd-list.c
lib/initd.h
|
|
|
|
Services depend on each other by their provided services, not by their
names.
|
|
|
|
Usually, a script will just provide the services listed in the Provides
field in the LSB header. However, there may be cases where other scripts
depend on it by its name, rather than by the service it provides. This
adds the script's name to its provides member if it is not already
included. This also solves the problem where we want to add a service by
name, but the dep solver operates on provided services.
|
|
The final order of the dependencies matters when processing recursively
as this will eventually determine the order of the S and K links. Since
this may cause an unchanged link to become out of order when one of its
dependents changes, we add all currently active services to the
requested set. This should ensure that the final order is correct.
|
|
The recursive deps function has been converted to operating on initd
list structures instead of just dep lists. This will help when we start
considering the "Provides" field instead of just the name.
|
|
|
|
Added the initd_is_active function for checking whether a script is
active in a given level. A third parameter specifies whether it is a
start or stop link.
|
|
Since push is the opposite of pop, macros have been added to alias the
various add functions.
|
|
Added the initd_list_pop function for popping the last list element off
an initd_list.
|