DEFINE_STRING_TABLE_LOOKUP(cgroup_io_limit_type, CGroupIOLimitType);
+void cgroup_io_limits_list(void) {
+ DUMP_STRING_TABLE(cgroup_io_limit_type, CGroupIOLimitType, _CGROUP_IO_LIMIT_TYPE_MAX);
+}
+
static const char *const cgroup_controller_table[_CGROUP_CONTROLLER_MAX] = {
[CGROUP_CONTROLLER_CPU] = "cpu",
[CGROUP_CONTROLLER_CPUACCT] = "cpuacct",
const char* cgroup_io_limit_type_to_string(CGroupIOLimitType t) _const_;
CGroupIOLimitType cgroup_io_limit_type_from_string(const char *s) _pure_;
+void cgroup_io_limits_list(void);
/* Special values for the io.bfq.weight attribute */
#define CGROUP_BFQ_WEIGHT_INVALID UINT64_MAX
DEFINE_STRING_TABLE_LOOKUP(rlimit, int);
+void rlimits_list(const char *prefix) {
+ FOREACH_ELEMENT(field, rlimit_table)
+ printf("%s%s\n", strempty(prefix), *field);
+}
+
int rlimit_from_string_harder(const char *s) {
const char *suffix;
const char* rlimit_to_string(int i) _const_;
int rlimit_from_string(const char *s) _pure_;
int rlimit_from_string_harder(const char *s) _pure_;
+void rlimits_list(const char *prefix);
int setrlimit_closest(int resource, const struct rlimit *rlim);
int setrlimit_closest_all(const struct rlimit * const *rlim, int *which_failed);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <stdio.h>
+
#include "alloc-util.h"
#include "bus-label.h"
#include "glyph-util.h"
DEFINE_STRING_TABLE_LOOKUP(unit_dependency, UnitDependency);
+void unit_types_list(void) {
+ DUMP_STRING_TABLE(unit_dependency, UnitDependency, _UNIT_DEPENDENCY_MAX);
+}
+
static const char* const notify_access_table[_NOTIFY_ACCESS_MAX] = {
[NOTIFY_NONE] = "none",
[NOTIFY_MAIN] = "main",
const char* unit_type_to_string(UnitType i) _const_;
UnitType unit_type_from_string(const char *s) _pure_;
+void unit_types_list(void);
const char* unit_load_state_to_string(UnitLoadState i) _const_;
UnitLoadState unit_load_state_from_string(const char *s) _pure_;
return 1;
}
+static void dump_resource_limits(void) {
+ rlimits_list("Limit");
+}
+
static int bus_append_string_with_ignore(sd_bus_message *m, const char *field, const char *eq) {
int ignore = 0;
const char *s = eq;
field, trigger, negate, p);
}
+static void dump_conditions(void) {
+ condition_types_list();
+ assert_types_list();
+}
+
static int bus_try_append_unit_dependency(sd_bus_message *m, const char *field, const char *eq) {
if (unit_dependency_from_string(field) < 0)
return 0;
typedef struct BusProperty {
const char *name;
int (*convert)(sd_bus_message *m, const char *field, const char *eq);
+ void (*dump)(void);
} BusProperty;
static const BusProperty cgroup_properties[] = {
{ "BlockIOWriteBandwidth", warn_deprecated },
{ "CPUAccounting", warn_deprecated },
- { NULL, bus_try_append_parse_cgroup_io_limit },
+ { NULL, bus_try_append_parse_cgroup_io_limit, cgroup_io_limits_list },
{}
};
{ "ProtectHostname", bus_append_protect_hostname },
{ "ProtectHostnameEx", bus_append_protect_hostname },
- { NULL, bus_try_append_resource_limit },
+ { NULL, bus_try_append_resource_limit, dump_resource_limits },
{}
};
{ "WantsMountsFor", bus_append_strv },
{ "Markers", bus_append_strv },
- { NULL, bus_try_append_unit_dependency },
- { NULL, bus_try_append_condition },
+ { NULL, bus_try_append_unit_dependency, unit_types_list },
+ { NULL, bus_try_append_condition, dump_conditions },
{}
};
return 0;
}
+void bus_dump_transient_settings(UnitType t) {
+ assert(t >= 0 && t < _UNIT_TYPE_MAX);
+
+ for (const BusProperty** tables = ASSERT_PTR(unit_type_properties[t]); *tables; tables++)
+ for (const BusProperty *item = *tables; item->convert; item++) {
+ assert(item->name || item->dump);
+
+ /* Do not print deprecated names */
+ if (item->convert == warn_deprecated)
+ continue;
+
+ if (item->name)
+ puts(item->name);
+ else
+ item->dump();
+ }
+}
+
int bus_append_scope_pidref(sd_bus_message *m, const PidRef *pidref, bool allow_pidfd) {
assert(m);
int unit_freezer_freeze(UnitFreezer *f);
int unit_freezer_thaw(UnitFreezer *f);
+
+void bus_dump_transient_settings(UnitType t);
return _condition_type_from_string(s);
}
+void condition_types_list(void) {
+ DUMP_STRING_TABLE(_condition_type, ConditionType, _CONDITION_TYPE_MAX);
+}
+
static const char* const _assert_type_table[_CONDITION_TYPE_MAX] = {
[CONDITION_ARCHITECTURE] = "AssertArchitecture",
[CONDITION_FIRMWARE] = "AssertFirmware",
return _assert_type_from_string(s);
}
+void assert_types_list(void) {
+ DUMP_STRING_TABLE(_assert_type, ConditionType, _CONDITION_TYPE_MAX);
+}
+
static const char* const condition_result_table[_CONDITION_RESULT_MAX] = {
[CONDITION_UNTESTED] = "untested",
[CONDITION_SUCCEEDED] = "succeeded",
const char* condition_type_to_string(ConditionType t) _const_;
ConditionType condition_type_from_string(const char *s) _pure_;
+void condition_types_list(void);
const char* assert_type_to_string(ConditionType t) _const_;
ConditionType assert_type_from_string(const char *s) _pure_;
+void assert_types_list(void);
const char* condition_result_to_string(ConditionResult r) _const_;
ConditionResult condition_result_from_string(const char *s) _pure_;
'test-blockdev-util.c',
'test-bootspec.c',
'test-build-path.c',
+ 'test-bus-unit-util.c',
'test-bus-util.c',
'test-calendarspec.c',
'test-cgroup-util.c',
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "bus-unit-util.h"
+#include "unit-def.h"
+#include "tests.h"
+
+TEST(bus_dump_transient_settings) {
+ /* -1 is for generic unit, natural numbers are for specific unit types */
+ for (UnitType t = 0; t < _UNIT_TYPE_MAX; t++) {
+ log_info("==================== %s ====================", t < 0 ? "unit" : unit_type_to_string(t));
+ bus_dump_transient_settings(t);
+ }
+}
+
+DEFINE_TEST_MAIN(LOG_DEBUG);