shared/bus-unit-util: add bus_dump_transient_settings() helper
bus_append_unit_property() and associated functions accept a long list of properties. But the specific names are only available through code. But it is useful to be able to know the specific list of properties that is supported, in particular for shell completions. Thus, add a way to list the properties that are supported by the code. In the future we could also turn this into a test for the documentation. For various reasons, the list of properties listed in the docs is a partially overlapping set. E.g. for service type, the pull request https://github.com/systemd/systemd/pull/37661 creates a list with 212 entries, and this code generates 7 entries less and 184 more. I didn't check all the differences, but in the few cases I did, the list generated here was actually correctly supported by 'systemd-run -p'. A smoke test is added.
This commit is contained in:
@@ -2063,6 +2063,10 @@ static const char* const cgroup_io_limit_type_table[_CGROUP_IO_LIMIT_TYPE_MAX] =
|
||||
|
||||
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",
|
||||
|
||||
@@ -97,6 +97,7 @@ extern const uint64_t cgroup_io_limit_defaults[_CGROUP_IO_LIMIT_TYPE_MAX];
|
||||
|
||||
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
|
||||
|
||||
@@ -343,6 +343,11 @@ static const char* const rlimit_table[_RLIMIT_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;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
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);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bus-label.h"
|
||||
#include "glyph-util.h"
|
||||
@@ -331,6 +333,10 @@ static const char* const unit_dependency_table[_UNIT_DEPENDENCY_MAX] = {
|
||||
|
||||
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",
|
||||
|
||||
@@ -304,6 +304,7 @@ const char* unit_dbus_interface_from_name(const char *name);
|
||||
|
||||
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_;
|
||||
|
||||
Reference in New Issue
Block a user