core: add generic "clean" operation to units

This adds basic infrastructure to implement a "clean" operation for unit
types. This "clean" operation is supposed to remove on-disk resources of
units, and is supposed to be used in a later commit to clean our
RuntimeDirectory=, StateDirectory= and so on of service units.

Later commits will open this up to the bus, and hook up service units
with this.

This also adds a new generic ActiveState called UNIT_MAINTENANCE. It's
supposed to cover all kinds of "maintainance" state of units.
Specifically, this is supposed to cover the "cleaning" operations later
added for service units which might take a bit of time. This high-level,
generic, abstract state is called UNIT_MAINTENANCE instead of the
more specific "UNIT_CLEANING", since I think this should be kept open
for different operations possibly later on that could be nicely subsumed
under this (for example, maybe a recursive chown()ing operation could be
covered by this, and similar).
This commit is contained in:
Lennart Poettering
2019-07-11 12:18:51 +02:00
parent c0228b4fa3
commit 380dc8b0a2
5 changed files with 74 additions and 1 deletions
+13
View File
@@ -132,6 +132,19 @@ typedef struct ExecDirectory {
mode_t mode;
} ExecDirectory;
typedef enum ExecCleanMask {
/* In case you wonder why the bitmask below doesn't use "directory" in its name: we want to keep this
* generic so that .timer timestamp files can nicely be covered by this too, and similar. */
EXEC_CLEAN_RUNTIME = 1U << EXEC_DIRECTORY_RUNTIME,
EXEC_CLEAN_STATE = 1U << EXEC_DIRECTORY_STATE,
EXEC_CLEAN_CACHE = 1U << EXEC_DIRECTORY_CACHE,
EXEC_CLEAN_LOGS = 1U << EXEC_DIRECTORY_LOGS,
EXEC_CLEAN_CONFIGURATION = 1U << EXEC_DIRECTORY_CONFIGURATION,
EXEC_CLEAN_NONE = 0,
EXEC_CLEAN_ALL = (1U << _EXEC_DIRECTORY_TYPE_MAX) - 1,
_EXEC_CLEAN_MASK_INVALID = -1,
} ExecCleanMask;
/* Encodes configuration parameters applied to invoked commands. Does not carry runtime data, but only configuration
* changes sourced from unit files and suchlike. ExecContext objects are usually embedded into Unit objects, and do not
* change after being loaded. */