summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-21 03:26:34 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-21 03:26:34 +0100
commitcd2dbd7df9f1b8c46386b2898523aec3dd4578fd (patch)
tree41b3677d84516467f495a06b89d31380782c6775 /job.c
parente094e853a047e10f0d2989eed76b6aa430e3ea1a (diff)
only accept valid job types for specific names
Diffstat (limited to 'job.c')
-rw-r--r--job.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/job.c b/job.c
index d22ce19ee1..4688164e5a 100644
--- a/job.c
+++ b/job.c
@@ -266,10 +266,33 @@ bool job_type_is_superset(JobType a, JobType b) {
}
bool job_type_is_conflicting(JobType a, JobType b) {
-
- /* Checks whether two types are "conflicting" */
+ assert(a >= 0 && a < _JOB_TYPE_MAX);
+ assert(b >= 0 && b < _JOB_TYPE_MAX);
return
(a == JOB_STOP && b != JOB_STOP) ||
(b == JOB_STOP && a != JOB_STOP);
}
+
+bool job_type_applicable(JobType j, NameType n) {
+ assert(j >= 0 && j < _JOB_TYPE_MAX);
+ assert(n >= 0 && n < _NAME_TYPE_MAX);
+
+ switch (j) {
+ case JOB_START:
+ case JOB_STOP:
+ case JOB_VERIFY_STARTED:
+ return true;
+
+ case JOB_RELOAD:
+ case JOB_RELOAD_OR_START:
+ return n == NAME_SERVICE || n == NAME_TIMER || n == NAME_MOUNT;
+
+ case JOB_RESTART:
+ case JOB_TRY_RESTART:
+ return n == NAME_SERVICE || n == NAME_TIMER || n == NAME_SOCKET || NAME_MOUNT || NAME_SNAPSHOT;
+
+ default:
+ assert_not_reached("Invalid job type");
+ }
+}