Merge pull request #29630 from DaanDeMeyer/manager-json
Various refactoring in preparation for adding JSON dump to pid 1
This commit is contained in:
+4
-1
@@ -2135,7 +2135,9 @@ int _hashmap_dump_sorted(HashmapBase *h, void ***ret, size_t *ret_n) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
entries = new(struct hashmap_base_entry*, _hashmap_size(h));
|
||||
/* We append one more element than needed so that the resulting array can be used as a strv. We
|
||||
* don't count this entry in the returned size. */
|
||||
entries = new(struct hashmap_base_entry*, _hashmap_size(h) + 1);
|
||||
if (!entries)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2143,6 +2145,7 @@ int _hashmap_dump_sorted(HashmapBase *h, void ***ret, size_t *ret_n) {
|
||||
entries[n++] = bucket_at(h, idx);
|
||||
|
||||
assert(n == _hashmap_size(h));
|
||||
entries[n] = NULL;
|
||||
|
||||
typesafe_qsort_r(entries, n, hashmap_entry_compare, h->hash_ops->compare);
|
||||
|
||||
|
||||
@@ -68,6 +68,14 @@ const char *unit_dbus_interface_from_name(const char *name) {
|
||||
return unit_dbus_interface_from_type(t);
|
||||
}
|
||||
|
||||
const char* unit_type_to_capitalized_string(UnitType t) {
|
||||
const char *di = unit_dbus_interface_from_type(t);
|
||||
if (!di)
|
||||
return NULL;
|
||||
|
||||
return ASSERT_PTR(startswith(di, "org.freedesktop.systemd1."));
|
||||
}
|
||||
|
||||
static const char* const unit_type_table[_UNIT_TYPE_MAX] = {
|
||||
[UNIT_SERVICE] = "service",
|
||||
[UNIT_SOCKET] = "socket",
|
||||
|
||||
@@ -287,6 +287,8 @@ 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_;
|
||||
|
||||
const char* unit_type_to_capitalized_string(UnitType t);
|
||||
|
||||
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