1
0
mirror of https://github.com/systemd/systemd synced 2026-03-19 11:34:46 +01:00

Compare commits

...

11 Commits

Author SHA1 Message Date
Yu Watanabe
f29a0b3151 dissect-image: fix typo
Follow-up for 771085291dab707b2c7502420b81f7890aa61213.
2026-01-02 04:32:48 +09:00
Yu Watanabe
78247787e9 ssh-proxy: fix typo
Follow-up for dc3e544104218052664e2c6b08d1ae397e9a4faf.
2026-01-02 04:30:58 +09:00
Mike Yuan
05aea9f73b core/dynamic-user: drop unused /run/systemd/dynamic-uid/direct: kludge
Follow-up for 1684c56f40f020e685e70b3d1785d596ff16f892
This effectively reverts fd63e712b2025d235ce4bfbb512fada10e2690b5

This was originally introduced to resolve deadlock caused by
dbus broker calling into nss-systemd which in turn goes via
dbus for user lookup. This is now handled differently and
the interface has been sitting unused for half a decade now.
Kill it.
2026-01-02 04:28:01 +09:00
Daan De Meyer
aec52c1e6e string-table: Introduce DECLARE_STRING_TABLE_LOOKUP() and friends
Let's introduce these for the following two reasons:
- Using them makes sure the parameter names match between declaration
  and definition (if both use the corresponding macros).
- They make sure developers can't forget the _const_ and _pure_
  attributes for the declarations.

This commit also includes some include sorting fixes
2026-01-02 04:05:45 +09:00
Daan De Meyer
daff8ea8bb tree-wide: Introduce DECLARE_TRIVIAL_REF_UNREF_FUNC() and friends 2026-01-02 04:04:19 +09:00
David Santamaría Rogado
11adc8bad5
quirks: Re-add D330 accel_matrix as identity one (#40226)
When testing to correct accelerometer values I set locally the identity
matrix to override the quirk. The values were fine but removing all the
matrices give incorrect values.

The mistake was thinking that identity matrix is the default one when no
quirks are set. It is, but only when the ACPI doesn't have another one.

Set identity matrix for this device to correct accelerometer values.

Follow-up for a07b184e8ccbecafc1fce5a0cfffe87c6a497134.
2026-01-02 03:52:56 +09:00
David Santamaría Rogado
e9b3bfb3f5 quirks: sensor: add info about ACPI accel_matrix
Just inform about if an ACPI accel matrix exists, is the default one instead
the indentity matrix.
2026-01-02 03:49:45 +09:00
tuhaowen
3c586354aa udev/scsi_id: increase MAX_SERIAL_LEN from 256 to 512
The current MAX_SERIAL_LEN value of 256 is insufficient for some SCSI
devices with non-standard serial number lengths. In do_scsi_page80_inquiry(),
the required buffer length is calculated as:

    len = 1 + VENDOR_LENGTH + MODEL_LENGTH + buf[3]
        = 1 + 8 + 16 + buf[3]
        = 25 + buf[3]

where buf[3] contains the serial number length reported by the device.
According to the SCSI specification, this field is an unsigned 8-bit
value, meaning it can theoretically be up to 255 bytes. This results
in a maximum required length of 280 bytes, exceeding the current limit
of 256 bytes.

When this occurs, scsi_id fails with an error message like:
    "length 256 too short - need 280"

This has been observed with certain vendor devices that report unusually
long serial numbers in VPD page 0x80.

Increase MAX_SERIAL_LEN to 512 to accommodate the maximum possible
serial number length plus all required prefixes (vendor, model, and
type identifiers), providing sufficient headroom for non-compliant
devices while maintaining reasonable memory usage.

Signed-off-by: tuhaowen <tuhaowen@uniontech.com>
2026-01-02 03:48:28 +09:00
dependabot[bot]
ecfe1bddaf build(deps): bump meson from 1.9.1 to 1.10.0 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.9.1...1.10.0)

---
updated-dependencies:
- dependency-name: meson
  dependency-version: 1.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-02 03:35:50 +09:00
dependabot[bot]
31ca68030b build(deps): bump actions/labeler from 5.0.0 to 6.0.1
Bumps [actions/labeler](https://github.com/actions/labeler) from 5.0.0 to 6.0.1.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](8558fd7429...634933edcd)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-02 03:35:36 +09:00
dependabot[bot]
5323c6e47c build(deps): bump redhat-plumbers-in-action/gather-pull-request-metadata
Bumps [redhat-plumbers-in-action/gather-pull-request-metadata](https://github.com/redhat-plumbers-in-action/gather-pull-request-metadata) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/redhat-plumbers-in-action/gather-pull-request-metadata/releases)
- [Commits](5da2967931...b3dbc3f843)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/gather-pull-request-metadata
  dependency-version: 1.8.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-02 03:35:21 +09:00
197 changed files with 483 additions and 789 deletions

View File

@ -20,7 +20,7 @@ jobs:
- id: metadata
name: Gather Pull Request Metadata
uses: redhat-plumbers-in-action/gather-pull-request-metadata@5da2967931dd7c4b9ccd22f49b045e2c1f05165b
uses: redhat-plumbers-in-action/gather-pull-request-metadata@b3dbc3f843e8343dbcb2af5bffba72c974d3a07a
- name: Upload Pull Request Metadata artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3

View File

@ -34,7 +34,7 @@ jobs:
if: github.event_name == 'pull_request'
- name: Label PR based on policy in labeler.yml
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9
uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b
if: startsWith(github.event_name, 'pull_request') && github.base_ref == 'main' && github.event.action != 'closed'
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

View File

@ -1,5 +1,6 @@
meson==1.9.1 \
--hash=sha256:f824ab770c041a202f532f69e114c971918ed2daff7ea56583d80642564598d0
meson==1.10.0 \
--hash=sha256:4b27aafce281e652dcb437b28007457411245d975c48b5db3a797d3e93ae1585 \
--hash=sha256:8071860c1f46a75ea34801490fd1c445c9d75147a65508cd3a10366a7006cc1c
ninja==1.11.1.4 \
--hash=sha256:055f386fb550c2c9d6157e45e20a84d29c47968876b9c5794ae2aec46f952306 \
--hash=sha256:096487995473320de7f65d622c3f1d16c3ad174797602218ca8c967f51ec38a0 \

View File

@ -41,7 +41,9 @@
# PROXIMITY_NEAR_LEVEL=<value>
#
# where <matrix> is a mount-matrix in the format specified in the IIO
# subsystem[1]. The default, when unset, is equivalent to:
# subsystem[1]. The default, when unset, is the one defined by the ACPI
# found in /sys/bus/iio/devices/iio\:deviceXXX/in_mount_matrix or, in
# absence of it, is equivalent to:
# ACCEL_MOUNT_MATRIX=1, 0, 0; 0, 1, 0; 0, 0, 1
# eg. the identity matrix,
# and <value> is an integer value above or equal to which an object is
@ -760,6 +762,11 @@ sensor:modalias:acpi:BMA250E*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-1030:*
sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-830:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
# IdeaPad D330-10IGM (both 81H3 and 81MD product names)
# ACPI in_mount_matrix is 0, -1, 0; 1, 0, 0; 0, 0, 1, but the correct one is identity matrix.
sensor:modalias:acpi:BOSC0200*:dmi:*:svnLENOVO:*:pvrLenovoideapadD330-10IGM:*
ACCEL_MOUNT_MATRIX=1, 0, 0; 0, 1, 0; 0, 0, 1
# IdeaPad Miix 300
sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrMIIX300-*:*
ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1

View File

@ -19,5 +19,4 @@ int verify_prepare_filename(const char *filename, char **ret);
int verify_executable(Unit *u, const ExecCommand *exec, const char *root);
int verify_units(char **filenames, RuntimeScope scope, bool check_man, bool run_generators, RecursiveErrors recursive_errors, const char *root);
const char* recursive_errors_to_string(RecursiveErrors i) _const_;
RecursiveErrors recursive_errors_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(recursive_errors, RecursiveErrors);

View File

@ -13,8 +13,7 @@ typedef enum ColorMode {
_COLOR_MODE_INVALID = -EINVAL,
} ColorMode;
const char* color_mode_to_string(ColorMode m) _const_;
ColorMode color_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(color_mode, ColorMode);
ColorMode get_color_mode(void);
static inline bool colors_enabled(void) {

View File

@ -242,5 +242,4 @@ Architecture uname_architecture(void);
# error "Please register your architecture here!"
#endif
const char* architecture_to_string(Architecture a) _const_;
Architecture architecture_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(architecture, Architecture);

View File

@ -3,20 +3,21 @@
/* IWYU pragma: always_keep */
#include <errno.h> /* IWYU pragma: export */
#include <inttypes.h> /* IWYU pragma: export */
#include <limits.h> /* IWYU pragma: export */
#include <paths.h> /* IWYU pragma: export */
#include <stdarg.h> /* IWYU pragma: export */
#include <stdbool.h> /* IWYU pragma: export */
#include <stddef.h> /* IWYU pragma: export */
#include <stdint.h> /* IWYU pragma: export */
#include <sys/types.h> /* IWYU pragma: export */
#include <uchar.h> /* IWYU pragma: export */
#include <errno.h> /* IWYU pragma: export */
#include <inttypes.h> /* IWYU pragma: export */
#include <limits.h> /* IWYU pragma: export */
#include <paths.h> /* IWYU pragma: export */
#include <stdarg.h> /* IWYU pragma: export */
#include <stdbool.h> /* IWYU pragma: export */
#include <stddef.h> /* IWYU pragma: export */
#include <stdint.h> /* IWYU pragma: export */
#include <sys/types.h> /* IWYU pragma: export */
#include <uchar.h> /* IWYU pragma: export */
#include "assert-util.h" /* IWYU pragma: export */
#include "cleanup-util.h" /* IWYU pragma: export */
#include "macro.h" /* IWYU pragma: export */
#include "assert-util.h" /* IWYU pragma: export */
#include "cleanup-util.h" /* IWYU pragma: export */
#include "macro.h" /* IWYU pragma: export */
#include "string-table-fundamental.h" /* IWYU pragma: export */
/* Generic types */

View File

@ -95,8 +95,7 @@ typedef enum CGroupIOLimitType {
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_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_io_limit_type, CGroupIOLimitType);
void cgroup_io_limits_list(void);
/* Special values for the io.bfq.weight attribute */
@ -243,8 +242,7 @@ int cg_mask_to_string(CGroupMask mask, char **ret);
bool cg_kill_supported(void);
const char* cgroup_controller_to_string(CGroupController c) _const_;
CGroupController cgroup_controller_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_controller, CGroupController);
typedef enum ManagedOOMMode {
MANAGED_OOM_AUTO,
@ -253,8 +251,7 @@ typedef enum ManagedOOMMode {
_MANAGED_OOM_MODE_INVALID = -EINVAL,
} ManagedOOMMode;
const char* managed_oom_mode_to_string(ManagedOOMMode m) _const_;
ManagedOOMMode managed_oom_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(managed_oom_mode, ManagedOOMMode);
typedef enum ManagedOOMPreference {
MANAGED_OOM_PREFERENCE_NONE = 0,
@ -264,5 +261,4 @@ typedef enum ManagedOOMPreference {
_MANAGED_OOM_PREFERENCE_INVALID = -EINVAL,
} ManagedOOMPreference;
const char* managed_oom_preference_to_string(ManagedOOMPreference a) _const_;
ManagedOOMPreference managed_oom_preference_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(managed_oom_preference, ManagedOOMPreference);

View File

@ -74,6 +74,16 @@ typedef void* (*mfree_func_t)(void *p);
DEFINE_TRIVIAL_REF_FUNC(type, name); \
DEFINE_TRIVIAL_UNREF_FUNC(type, name, free_func);
#define DECLARE_TRIVIAL_REF_FUNC(type, name) \
type* name##_ref(type *p)
#define DECLARE_TRIVIAL_UNREF_FUNC(type, name) \
type* name##_unref(type *p)
#define DECLARE_TRIVIAL_REF_UNREF_FUNC(type, name) \
DECLARE_TRIVIAL_REF_FUNC(type, name); \
DECLARE_TRIVIAL_UNREF_FUNC(type, name)
#define DEFINE_PRIVATE_TRIVIAL_REF_UNREF_FUNC(type, name, free_func) \
DEFINE_PRIVATE_TRIVIAL_REF_FUNC(type, name); \
DEFINE_PRIVATE_TRIVIAL_UNREF_FUNC(type, name, free_func);

View File

@ -12,10 +12,8 @@ typedef enum Compression {
_COMPRESSION_INVALID = -EINVAL,
} Compression;
const char* compression_to_string(Compression compression) _const_;
Compression compression_from_string(const char *s) _pure_;
const char* compression_lowercase_to_string(Compression compression) _const_;
Compression compression_lowercase_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(compression, Compression);
DECLARE_STRING_TABLE_LOOKUP(compression_lowercase, Compression);
bool compression_supported(Compression c);

View File

@ -20,5 +20,4 @@ typedef enum ConfidentialVirtualization {
ConfidentialVirtualization detect_confidential_virtualization(void);
const char* confidential_virtualization_to_string(ConfidentialVirtualization v) _const_;
ConfidentialVirtualization confidential_virtualization_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(confidential_virtualization, ConfidentialVirtualization);

View File

@ -36,8 +36,7 @@ int locale_is_installed(const char *name);
bool is_locale_utf8(void);
const char* locale_variable_to_string(LocaleVariable i) _const_;
LocaleVariable locale_variable_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(locale_variable, LocaleVariable);
static inline void freelocalep(locale_t *p) {
if (*p == (locale_t) 0)

View File

@ -57,8 +57,7 @@ LogContext* log_context_new_iov(struct iovec *input_iovec, size_t n_input_iovec,
LogContext* log_context_new_strv_consume(char **fields);
LogContext* log_context_new_iov_consume(struct iovec *input_iovec, size_t n_input_iovec);
LogContext *log_context_ref(LogContext *c);
LogContext *log_context_unref(LogContext *c);
DECLARE_TRIVIAL_REF_UNREF_FUNC(LogContext, log_context);
DEFINE_TRIVIAL_CLEANUP_FUNC(LogContext*, log_context_unref);

View File

@ -40,8 +40,7 @@ static inline void clear_log_syntax_callback(dummy_t *dummy) {
set_log_syntax_callback(/* cb= */ NULL, /* userdata= */ NULL);
}
const char* log_target_to_string(LogTarget target) _const_;
LogTarget log_target_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(log_target, LogTarget);
void log_set_target(LogTarget target);
void log_set_target_and_open(LogTarget target);
int log_set_target_from_string(const char *e);

View File

@ -14,8 +14,7 @@ typedef enum ImageClass {
_IMAGE_CLASS_INVALID = -EINVAL,
} ImageClass;
const char* image_class_to_string(ImageClass cl) _const_;
ImageClass image_class_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(image_class, ImageClass);
/* The *_extension_release flavours will look for /usr/lib/extension-release/extension-release.NAME
* for sysext images and for /etc/extension-release.d/extension-release.NAME for confext images

View File

@ -107,11 +107,8 @@ const char* personality_to_string(unsigned long);
int safe_personality(unsigned long p);
int opinionated_personality(unsigned long *ret);
const char* sigchld_code_to_string(int i) _const_;
int sigchld_code_from_string(const char *s) _pure_;
int sched_policy_to_string_alloc(int i, char **ret);
int sched_policy_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(sigchld_code, int);
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int);
static inline pid_t PTR_TO_PID(const void *p) {
return (pid_t) ((uintptr_t) p);

View File

@ -7,8 +7,7 @@
#define _RLIMIT_MAX RLIMIT_NLIMITS
const char* rlimit_to_string(int i) _const_;
int rlimit_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(rlimit, int);
int rlimit_from_string_harder(const char *s) _pure_;
void rlimits_list(const char *prefix);

View File

@ -11,10 +11,8 @@ typedef enum RuntimeScope {
_RUNTIME_SCOPE_INVALID = -EINVAL,
} RuntimeScope;
const char* runtime_scope_to_string(RuntimeScope scope) _const_;
RuntimeScope runtime_scope_from_string(const char *s) _const_;
const char* runtime_scope_cmdline_option_to_string(RuntimeScope scope) _const_;
DECLARE_STRING_TABLE_LOOKUP(runtime_scope, RuntimeScope);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(runtime_scope_cmdline_option, RuntimeScope);
static inline mode_t runtime_scope_to_socket_mode(RuntimeScope scope) {
/* Returns the right socket mode to use for binding AF_UNIX sockets intended for the specified

View File

@ -31,8 +31,7 @@ int sigset_add_many_internal(sigset_t *ss, ...);
int sigprocmask_many_internal(int how, sigset_t *ret_old_mask, ...);
#define sigprocmask_many(...) sigprocmask_many_internal(__VA_ARGS__, -1)
const char* signal_to_string(int signo) _const_;
int signal_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(signal, int);
void nop_signal_handler(int sig);

View File

@ -55,8 +55,7 @@ typedef struct SocketAddress {
#define socket_address_family(a) ((a)->sockaddr.sa.sa_family)
const char* socket_address_type_to_string(int t) _const_;
int socket_address_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_address_type, int);
int sockaddr_un_unlink(const struct sockaddr_un *sa);
@ -87,8 +86,7 @@ int getsockname_pretty(int fd, char **ret);
int socknameinfo_pretty(const struct sockaddr *sa, socklen_t salen, char **_ret);
int netlink_family_to_string_alloc(int i, char **ret);
int netlink_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(netlink_family, int);
bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b);
@ -101,8 +99,7 @@ static inline int fd_increase_rxbuf(int fd, size_t n) {
return fd_set_rcvbuf(fd, n, true);
}
int ip_tos_to_string_alloc(int i, char **ret);
int ip_tos_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ip_tos, int);
typedef enum {
IFNAME_VALID_ALTERNATIVE = 1 << 0, /* Allow "altnames" too */

View File

@ -97,8 +97,7 @@ void inode_hash_func(const struct stat *q, struct siphash *state);
int inode_compare_func(const struct stat *a, const struct stat *b);
extern const struct hash_ops inode_hash_ops;
const char* inode_type_to_string(mode_t m) _const_;
mode_t inode_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(inode_type, mode_t);
/* Macros that check whether the stat/statx structures have been initialized already. For "struct stat" we
* use a check for .st_dev being non-zero, since the kernel unconditionally fills that in, mapping the file

View File

@ -3,12 +3,10 @@
#include "basic-forward.h"
int log_facility_unshifted_to_string_alloc(int i, char **ret);
int log_facility_unshifted_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_facility_unshifted, int);
bool log_facility_unshifted_is_valid(int faciliy);
int log_level_to_string_alloc(int i, char **ret);
int log_level_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_level, int);
bool log_level_is_valid(int level);
int syslog_parse_priority(const char **p, int *priority, bool with_facility);

View File

@ -232,5 +232,4 @@ int usleep_safe(usec_t usec);
int time_change_fd(void);
const char* timestamp_style_to_string(TimestampStyle t) _const_;
TimestampStyle timestamp_style_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(timestamp_style, TimestampStyle);

View File

@ -313,67 +313,47 @@ int unit_name_from_dbus_path(const char *path, char **name);
const char* unit_dbus_interface_from_type(UnitType t);
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_;
DECLARE_STRING_TABLE_LOOKUP(unit_type, UnitType);
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_;
DECLARE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState);
const char* unit_active_state_to_string(UnitActiveState i) _const_;
UnitActiveState unit_active_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(unit_active_state, UnitActiveState);
const char* freezer_state_to_string(FreezerState i) _const_;
FreezerState freezer_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(freezer_state, FreezerState);
FreezerState freezer_state_finish(FreezerState state) _const_;
FreezerState freezer_state_objective(FreezerState state) _const_;
const char* unit_marker_to_string(UnitMarker m) _const_;
UnitMarker unit_marker_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(unit_marker, UnitMarker);
const char* automount_state_to_string(AutomountState i) _const_;
AutomountState automount_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(automount_state, AutomountState);
const char* device_state_to_string(DeviceState i) _const_;
DeviceState device_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(device_state, DeviceState);
const char* mount_state_to_string(MountState i) _const_;
MountState mount_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(mount_state, MountState);
const char* path_state_to_string(PathState i) _const_;
PathState path_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(path_state, PathState);
const char* scope_state_to_string(ScopeState i) _const_;
ScopeState scope_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(scope_state, ScopeState);
const char* service_state_to_string(ServiceState i) _const_;
ServiceState service_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_state, ServiceState);
const char* slice_state_to_string(SliceState i) _const_;
SliceState slice_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(slice_state, SliceState);
const char* socket_state_to_string(SocketState i) _const_;
SocketState socket_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_state, SocketState);
const char* swap_state_to_string(SwapState i) _const_;
SwapState swap_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(swap_state, SwapState);
const char* target_state_to_string(TargetState i) _const_;
TargetState target_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(target_state, TargetState);
const char* timer_state_to_string(TimerState i) _const_;
TimerState timer_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(timer_state, TimerState);
const char* unit_dependency_to_string(UnitDependency i) _const_;
UnitDependency unit_dependency_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(unit_dependency, UnitDependency);
const char* notify_access_to_string(NotifyAccess i) _const_;
NotifyAccess notify_access_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess);
const char* job_mode_to_string(JobMode t) _const_;
JobMode job_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(job_mode, JobMode);
const char* exec_directory_type_to_string(ExecDirectoryType i) _const_;
ExecDirectoryType exec_directory_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_directory_type, ExecDirectoryType);
Glyph unit_active_state_to_glyph(UnitActiveState state);

View File

@ -62,6 +62,5 @@ Virtualization detect_virtualization(void);
int running_in_userns(void);
int running_in_chroot(void);
const char* virtualization_to_string(Virtualization v) _const_;
Virtualization virtualization_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(virtualization, Virtualization);
bool has_cpu_with_flag(const char *flag);

View File

@ -34,8 +34,7 @@ typedef enum LogLevel {
_LOG_INVALID = -1,
} LogLevel;
LogLevel log_level_from_string(const char *s) _pure_;
const char* log_level_to_string(LogLevel l) _const_;
DECLARE_STRING_TABLE_LOOKUP(log_level, LogLevel);
LogLevel log_get_max_level(void) _pure_;
int log_set_max_level(LogLevel level);

View File

@ -13,6 +13,7 @@
#include "cleanup-fundamental.h" /* IWYU pragma: export */
#include "efi-fundamental.h" /* IWYU pragma: export */
#include "macro-fundamental.h" /* IWYU pragma: export */
#include "string-table-fundamental.h" /* IWYU pragma: export */
#if SD_BOOT
/* uchar.h/wchar.h are not suitable for freestanding environments. */

View File

@ -41,5 +41,5 @@ void install_security_override(security_validator_t validator, const void *valid
void uninstall_security_override(void);
bool security_override_available(void);
const char* secure_boot_enroll_to_string(secure_boot_enroll e) _const_;
const char* secure_boot_enroll_action_to_string(secure_boot_enroll_action e) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(secure_boot_enroll, secure_boot_enroll);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(secure_boot_enroll_action, secure_boot_enroll_action);

View File

@ -38,7 +38,6 @@ typedef struct Automount {
extern const UnitVTable automount_vtable;
const char* automount_result_to_string(AutomountResult i) _const_;
AutomountResult automount_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(automount_result, AutomountResult);
DEFINE_CAST(AUTOMOUNT, Automount);

View File

@ -450,8 +450,7 @@ void unit_invalidate_cgroup_bpf_firewall(Unit *u);
void manager_invalidate_startup_units(Manager *m);
const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_;
CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_device_policy, CGroupDevicePolicy);
void unit_cgroup_catchup(Unit *u);
@ -461,8 +460,7 @@ int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name);
int unit_cgroup_freezer_action(Unit *u, FreezerAction action);
const char* freezer_action_to_string(FreezerAction a) _const_;
FreezerAction freezer_action_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(freezer_action, FreezerAction);
CGroupRuntime* cgroup_runtime_new(void);
CGroupRuntime* cgroup_runtime_free(CGroupRuntime *crt);
@ -471,20 +469,14 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(CGroupRuntime*, cgroup_runtime_free);
int cgroup_runtime_serialize(Unit *u, FILE *f, FDSet *fds);
int cgroup_runtime_deserialize_one(Unit *u, const char *key, const char *value, FDSet *fds);
const char* cgroup_pressure_watch_to_string(CGroupPressureWatch a) _const_;
CGroupPressureWatch cgroup_pressure_watch_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_pressure_watch, CGroupPressureWatch);
const char* cgroup_device_permissions_to_string(CGroupDevicePermissions p) _const_;
CGroupDevicePermissions cgroup_device_permissions_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_device_permissions, CGroupDevicePermissions);
const char* cgroup_ip_accounting_metric_to_string(CGroupIPAccountingMetric m) _const_;
CGroupIPAccountingMetric cgroup_ip_accounting_metric_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_ip_accounting_metric, CGroupIPAccountingMetric);
const char* cgroup_io_accounting_metric_to_string(CGroupIOAccountingMetric m) _const_;
CGroupIOAccountingMetric cgroup_io_accounting_metric_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_io_accounting_metric, CGroupIOAccountingMetric);
const char* cgroup_effective_limit_type_to_string(CGroupLimitType m) _const_;
CGroupLimitType cgroup_effective_limit_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_effective_limit_type, CGroupLimitType);
const char* cgroup_memory_accounting_metric_to_string(CGroupMemoryAccountingMetric m) _const_;
CGroupMemoryAccountingMetric cgroup_memory_accounting_metric_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(cgroup_memory_accounting_metric, CGroupMemoryAccountingMetric);

View File

@ -11,8 +11,7 @@ typedef enum CrashAction {
_CRASH_ACTION_INVALID = -EINVAL,
} CrashAction;
const char* crash_action_to_string(CrashAction action);
CrashAction crash_action_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(crash_action, CrashAction);
_noreturn_ void freeze_or_exit_or_reboot(void);
void install_crash_handler(void);

View File

@ -145,44 +145,6 @@ static int dynamic_user_acquire(Manager *m, const char *name, DynamicUser** ret)
return 1;
}
static int make_uid_symlinks(uid_t uid, const char *name, bool b) {
char path1[STRLEN("/run/systemd/dynamic-uid/direct:") + DECIMAL_STR_MAX(uid_t) + 1];
const char *path2;
int r = 0, k;
/* Add direct additional symlinks for direct lookups of dynamic UIDs and their names by userspace code. The
* only reason we have this is because dbus-daemon cannot use D-Bus for resolving users and groups (since it
* would be its own client then). We hence keep these world-readable symlinks in place, so that the
* unprivileged dbus user can read the mappings when it needs them via these symlinks instead of having to go
* via the bus. Ideally, we'd use the lock files we keep for this anyway, but we can't since we use BSD locks
* on them and as those may be taken by any user with read access we can't make them world-readable. */
xsprintf(path1, "/run/systemd/dynamic-uid/direct:" UID_FMT, uid);
if (unlink(path1) < 0 && errno != ENOENT)
r = -errno;
if (b && symlink(name, path1) < 0) {
k = log_warning_errno(errno, "Failed to symlink \"%s\": %m", path1);
if (r == 0)
r = k;
}
path2 = strjoina("/run/systemd/dynamic-uid/direct:", name);
if (unlink(path2) < 0 && errno != ENOENT) {
k = -errno;
if (r == 0)
r = k;
}
if (b && symlink(path1 + STRLEN("/run/systemd/dynamic-uid/direct:"), path2) < 0) {
k = log_warning_errno(errno, "Failed to symlink \"%s\": %m", path2);
if (r == 0)
r = k;
}
return r;
}
static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
/* Find a suitable free UID. We use the following strategy to find a suitable UID:
@ -315,7 +277,6 @@ static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
}
(void) ftruncate(lock_fd, l);
(void) make_uid_symlinks(candidate, name, true); /* also add direct lookup symlinks */
*ret_uid = candidate;
return TAKE_FD(lock_fd);
@ -359,7 +320,7 @@ static int dynamic_user_push(DynamicUser *d, uid_t uid, int lock_fd) {
return send_one_fd_iov(d->storage_socket[1], lock_fd, &iov, 1, MSG_DONTWAIT);
}
static void unlink_uid_lock(int lock_fd, uid_t uid, const char *name) {
static void unlink_uid_lock(int lock_fd, uid_t uid) {
char lock_path[STRLEN("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
if (lock_fd < 0)
@ -367,8 +328,6 @@ static void unlink_uid_lock(int lock_fd, uid_t uid, const char *name) {
xsprintf(lock_path, "/run/systemd/dynamic-uid/" UID_FMT, uid);
(void) unlink(lock_path);
(void) make_uid_symlinks(uid, name, false); /* remove direct lookup symlinks */
}
static int dynamic_user_realize(
@ -456,7 +415,7 @@ static int dynamic_user_realize(
/* So, we found a working UID/lock combination. Let's see if we actually still need it. */
r = posix_lock(d->storage_socket[0], LOCK_EX);
if (r < 0) {
unlink_uid_lock(uid_lock_fd, num, d->name);
unlink_uid_lock(uid_lock_fd, num);
return r;
}
@ -464,14 +423,14 @@ static int dynamic_user_realize(
if (r < 0) {
if (r != -EAGAIN) {
/* OK, something bad happened, let's get rid of the bits we acquired. */
unlink_uid_lock(uid_lock_fd, num, d->name);
unlink_uid_lock(uid_lock_fd, num);
return r;
}
} else {
/* Hmm, so as it appears there's now something stored in the storage socket.
* Throw away what we acquired, and use what's stored now. */
unlink_uid_lock(uid_lock_fd, num, d->name);
unlink_uid_lock(uid_lock_fd, num);
safe_close(uid_lock_fd);
num = new_uid;
@ -570,7 +529,7 @@ static int dynamic_user_close(DynamicUser *d) {
return r;
/* This dynamic user was realized and dynamically allocated. In this case, let's remove the lock file. */
unlink_uid_lock(lock_fd, uid, d->name);
unlink_uid_lock(lock_fd, uid);
return 1;
}

View File

@ -44,4 +44,4 @@ void dynamic_creds_close(DynamicCreds *creds);
DEFINE_TRIVIAL_CLEANUP_FUNC(DynamicCreds*, dynamic_creds_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(DynamicCreds*, dynamic_creds_destroy);
DynamicUser *dynamic_user_ref(DynamicUser *user);
DECLARE_TRIVIAL_REF_FUNC(DynamicUser, dynamic_user);

View File

@ -40,7 +40,6 @@ void emergency_action(
int exit_status,
const char *reason);
const char* emergency_action_to_string(EmergencyAction i) _const_;
EmergencyAction emergency_action_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(emergency_action, EmergencyAction);
int parse_emergency_action(const char *value, RuntimeScope runtime_scope, EmergencyAction *ret);

View File

@ -569,7 +569,7 @@ void exec_status_reset(ExecStatus *s);
int exec_shared_runtime_acquire(Manager *m, const ExecContext *c, const char *id, bool create, ExecSharedRuntime **ret);
ExecSharedRuntime *exec_shared_runtime_destroy(ExecSharedRuntime *r);
ExecSharedRuntime *exec_shared_runtime_unref(ExecSharedRuntime *r);
DECLARE_TRIVIAL_UNREF_FUNC(ExecSharedRuntime, exec_shared_runtime);
DEFINE_TRIVIAL_CLEANUP_FUNC(ExecSharedRuntime*, exec_shared_runtime_unref);
int exec_shared_runtime_serialize(const Manager *m, FILE *f, FDSet *fds);
@ -597,31 +597,23 @@ int exec_directory_add(ExecDirectory *d, const char *path, const char *symlink,
void exec_directory_sort(ExecDirectory *d);
bool exec_directory_is_private(const ExecContext *context, ExecDirectoryType type);
ExecCleanMask exec_clean_mask_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(exec_clean_mask, ExecCleanMask);
const char* exec_output_to_string(ExecOutput i) _const_;
ExecOutput exec_output_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_output, ExecOutput);
const char* exec_input_to_string(ExecInput i) _const_;
ExecInput exec_input_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_input, ExecInput);
const char* exec_utmp_mode_to_string(ExecUtmpMode i) _const_;
ExecUtmpMode exec_utmp_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_utmp_mode, ExecUtmpMode);
const char* exec_preserve_mode_to_string(ExecPreserveMode i) _const_;
ExecPreserveMode exec_preserve_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_preserve_mode, ExecPreserveMode);
const char* exec_keyring_mode_to_string(ExecKeyringMode i) _const_;
ExecKeyringMode exec_keyring_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_keyring_mode, ExecKeyringMode);
const char* exec_directory_type_symlink_to_string(ExecDirectoryType i) _const_;
ExecDirectoryType exec_directory_type_symlink_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_directory_type_symlink, ExecDirectoryType);
const char* exec_directory_type_mode_to_string(ExecDirectoryType i) _const_;
ExecDirectoryType exec_directory_type_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_directory_type_mode, ExecDirectoryType);
const char* exec_resource_type_to_string(ExecDirectoryType i) _const_;
ExecDirectoryType exec_resource_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(exec_resource_type, ExecDirectoryType);
bool exec_needs_mount_namespace(const ExecContext *context, const ExecParameters *params, const ExecRuntime *runtime);
bool exec_needs_network_namespace(const ExecContext *context);

View File

@ -209,14 +209,11 @@ void job_add_to_gc_queue(Job *j);
int job_get_before(Job *j, Job*** ret);
int job_get_after(Job *j, Job*** ret);
const char* job_type_to_string(JobType t) _const_;
JobType job_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(job_type, JobType);
const char* job_state_to_string(JobState t) _const_;
JobState job_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(job_state, JobState);
const char* job_result_to_string(JobResult t) _const_;
JobResult job_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(job_result, JobResult);
const char* job_type_to_access_method(JobType t);

View File

@ -40,11 +40,9 @@ typedef enum KillWhom {
void kill_context_init(KillContext *c);
void kill_context_dump(KillContext *c, FILE *f, const char *prefix);
const char* kill_mode_to_string(KillMode k) _const_;
KillMode kill_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(kill_mode, KillMode);
const char* kill_whom_to_string(KillWhom k) _const_;
KillWhom kill_whom_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom);
static inline int restart_kill_signal(const KillContext *c) {
if (c->restart_kill_signal != 0)

View File

@ -625,14 +625,11 @@ void manager_restore_original_log_target(Manager *m);
const char* manager_get_confirm_spawn(Manager *m);
void manager_disable_confirm_spawn(void);
const char* manager_state_to_string(ManagerState m) _const_;
ManagerState manager_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(manager_state, ManagerState);
const char* manager_objective_to_string(ManagerObjective m) _const_;
ManagerObjective manager_objective_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(manager_objective, ManagerObjective);
const char* manager_timestamp_to_string(ManagerTimestamp m) _const_;
ManagerTimestamp manager_timestamp_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(manager_timestamp, ManagerTimestamp);
ManagerTimestamp manager_timestamp_initrd_mangle(ManagerTimestamp s);
usec_t manager_get_watchdog(Manager *m, WatchdogType t);

View File

@ -99,10 +99,8 @@ char* mount_get_what_escaped(const Mount *m);
char* mount_get_options_escaped(const Mount *m);
const char* mount_get_fstype(const Mount *m);
const char* mount_exec_command_to_string(MountExecCommand i) _const_;
MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand);
const char* mount_result_to_string(MountResult i) _const_;
MountResult mount_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(mount_result, MountResult);
DEFINE_CAST(MOUNT, Mount);

View File

@ -221,35 +221,25 @@ int setup_tmp_dirs(
int setup_shareable_ns(int ns_storage_socket[static 2], unsigned long nsflag);
int open_shareable_ns_path(int netns_storage_socket[static 2], const char *path, unsigned long nsflag);
const char* protect_home_to_string(ProtectHome p) _const_;
ProtectHome protect_home_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_home, ProtectHome);
const char* protect_hostname_to_string(ProtectHostname p) _const_;
ProtectHostname protect_hostname_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_hostname, ProtectHostname);
const char* protect_system_to_string(ProtectSystem p) _const_;
ProtectSystem protect_system_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_system, ProtectSystem);
const char* protect_proc_to_string(ProtectProc i) _const_;
ProtectProc protect_proc_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_proc, ProtectProc);
const char* proc_subset_to_string(ProcSubset i) _const_;
ProcSubset proc_subset_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(proc_subset, ProcSubset);
const char* private_bpf_to_string(PrivateBPF i) _const_;
PrivateBPF private_bpf_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(private_bpf, PrivateBPF);
const char* bpf_delegate_cmd_to_string(uint64_t u) _const_;
uint64_t bpf_delegate_cmd_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_cmd, uint64_t);
const char* bpf_delegate_map_type_to_string(uint64_t u) _const_;
uint64_t bpf_delegate_map_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_map_type, uint64_t);
const char* bpf_delegate_prog_type_to_string(uint64_t u) _const_;
uint64_t bpf_delegate_prog_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_prog_type, uint64_t);
const char* bpf_delegate_attach_type_to_string(uint64_t u) _const_;
uint64_t bpf_delegate_attach_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(bpf_delegate_attach_type, uint64_t);
char* bpf_delegate_to_string(uint64_t u, const char * (*parser)(uint64_t) _const_);
int bpf_delegate_from_string(const char *s, uint64_t *ret, uint64_t (*parser)(const char *));
@ -286,17 +276,13 @@ static inline char * bpf_delegate_attachments_to_string(uint64_t u) {
return bpf_delegate_to_string(u, bpf_delegate_attach_type_to_string);
}
const char* private_tmp_to_string(PrivateTmp i) _const_;
PrivateTmp private_tmp_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(private_tmp, PrivateTmp);
const char* private_users_to_string(PrivateUsers i) _const_;
PrivateUsers private_users_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(private_users, PrivateUsers);
const char* protect_control_groups_to_string(ProtectControlGroups i) _const_;
ProtectControlGroups protect_control_groups_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(protect_control_groups, ProtectControlGroups);
const char* private_pids_to_string(PrivatePIDs i) _const_;
PrivatePIDs private_pids_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(private_pids, PrivatePIDs);
void bind_mount_free_many(BindMount *b, size_t n);
int bind_mount_add(BindMount **b, size_t *n, const BindMount *item);

View File

@ -76,11 +76,9 @@ void path_free_specs(Path *p);
extern const UnitVTable path_vtable;
extern const ActivationDetailsVTable activation_details_path_vtable;
const char* path_type_to_string(PathType i) _const_;
PathType path_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(path_type, PathType);
const char* path_result_to_string(PathResult i) _const_;
PathResult path_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(path_result, PathResult);
DEFINE_CAST(PATH, Path);
DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_PATH, ActivationDetailsPath, PATH);

View File

@ -46,7 +46,6 @@ extern const UnitVTable scope_vtable;
int scope_abandon(Scope *s);
const char* scope_result_to_string(ScopeResult i) _const_;
ScopeResult scope_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(scope_result, ScopeResult);
DEFINE_CAST(SCOPE, Scope);

View File

@ -270,32 +270,23 @@ usec_t service_restart_usec_next(const Service *s) _pure_;
int service_determine_exec_selinux_label(Service *s, char **ret);
const char* service_restart_to_string(ServiceRestart i) _const_;
ServiceRestart service_restart_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_restart, ServiceRestart);
const char* service_restart_mode_to_string(ServiceRestartMode i) _const_;
ServiceRestartMode service_restart_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_restart_mode, ServiceRestartMode);
const char* service_type_to_string(ServiceType i) _const_;
ServiceType service_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_type, ServiceType);
const char* service_exit_type_to_string(ServiceExitType i) _const_;
ServiceExitType service_exit_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_exit_type, ServiceExitType);
const char* service_exec_command_to_string(ServiceExecCommand i) _const_;
ServiceExecCommand service_exec_command_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_exec_command, ServiceExecCommand);
const char* service_exec_ex_command_to_string(ServiceExecCommand i) _const_;
ServiceExecCommand service_exec_ex_command_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_exec_ex_command, ServiceExecCommand);
const char* notify_state_to_string(NotifyState i) _const_;
NotifyState notify_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(notify_state, NotifyState);
const char* service_result_to_string(ServiceResult i) _const_;
ServiceResult service_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_result, ServiceResult);
const char* service_timeout_failure_mode_to_string(ServiceTimeoutFailureMode i) _const_;
ServiceTimeoutFailureMode service_timeout_failure_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(service_timeout_failure_mode, ServiceTimeoutFailureMode);
DEFINE_CAST(SERVICE, Service);

View File

@ -31,12 +31,10 @@ typedef enum StatusUnitFormat {
static inline bool show_status_on(ShowStatus s) {
return IN_SET(s, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
}
ShowStatus show_status_from_string(const char *s) _const_;
const char* show_status_to_string(ShowStatus s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(show_status, ShowStatus);
int parse_show_status(const char *s, ShowStatus *ret);
StatusUnitFormat status_unit_format_from_string(const char *s) _const_;
const char* status_unit_format_to_string(StatusUnitFormat s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(status_unit_format, StatusUnitFormat);
int status_vprintf(const char *status, ShowStatusFlags flags, const char *format, va_list ap) _printf_(3,0);
int status_printf(const char *status, ShowStatusFlags flags, const char *format, ...) _printf_(3,4);

View File

@ -204,20 +204,16 @@ const char* socket_fdname(Socket *s);
extern const UnitVTable socket_vtable;
const char* socket_exec_command_to_string(SocketExecCommand i) _const_;
SocketExecCommand socket_exec_command_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_exec_command, SocketExecCommand);
const char* socket_result_to_string(SocketResult i) _const_;
SocketResult socket_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_result, SocketResult);
const char* socket_port_type_to_string(SocketPort *p) _pure_;
SocketType socket_port_type_from_string(const char *s) _pure_;
const char* socket_timestamping_to_string(SocketTimestamping p) _const_;
SocketTimestamping socket_timestamping_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_timestamping, SocketTimestamping);
SocketTimestamping socket_timestamping_from_string_harder(const char *s) _pure_;
const char* socket_defer_trigger_to_string(SocketDeferTrigger i) _const_;
SocketDeferTrigger socket_defer_trigger_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(socket_defer_trigger, SocketDeferTrigger);
DEFINE_CAST(SOCKET, Socket);

View File

@ -94,10 +94,8 @@ int swap_process_device_remove(Manager *m, sd_device *dev);
int swap_get_priority(const Swap *s);
const char* swap_get_options(const Swap *s);
const char* swap_exec_command_to_string(SwapExecCommand i) _const_;
SwapExecCommand swap_exec_command_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(swap_exec_command, SwapExecCommand);
const char* swap_result_to_string(SwapResult i) _const_;
SwapResult swap_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(swap_result, SwapResult);
DEFINE_CAST(SWAP, Swap);

View File

@ -78,13 +78,11 @@ void timer_free_values(Timer *t);
extern const UnitVTable timer_vtable;
extern const ActivationDetailsVTable activation_details_timer_vtable;
const char* timer_base_to_string(TimerBase i) _const_;
TimerBase timer_base_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(timer_base, TimerBase);
char* timer_base_to_usec_string(TimerBase i);
const char* timer_result_to_string(TimerResult i) _const_;
TimerResult timer_result_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(timer_result, TimerResult);
DEFINE_CAST(TIMER, Timer);
DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_TIMER, ActivationDetailsTimer, TIMER);

View File

@ -1087,12 +1087,10 @@ int unit_compare_priority(Unit *a, Unit *b);
const char* unit_log_field(const Unit *u);
const char* unit_invocation_log_field(const Unit *u);
UnitMountDependencyType unit_mount_dependency_type_from_string(const char *s) _const_;
const char* unit_mount_dependency_type_to_string(UnitMountDependencyType t) _const_;
DECLARE_STRING_TABLE_LOOKUP(unit_mount_dependency_type, UnitMountDependencyType);
UnitDependency unit_mount_dependency_type_to_dependency_type(UnitMountDependencyType t) _pure_;
const char* oom_policy_to_string(OOMPolicy i) _const_;
OOMPolicy oom_policy_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(oom_policy, OOMPolicy);
/* Macros which append UNIT= or USER_UNIT= to the message */
@ -1168,8 +1166,7 @@ OOMPolicy oom_policy_from_string(const char *s) _pure_;
#define LOG_UNIT_ID(unit) LOG_ITEM("%s%s", unit_log_field((unit)), (unit)->id)
#define LOG_UNIT_INVOCATION_ID(unit) LOG_ITEM("%s%s", unit_invocation_log_field((unit)), (unit)->invocation_id_string)
const char* collect_mode_to_string(CollectMode m) _const_;
CollectMode collect_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(collect_mode, CollectMode);
typedef struct UnitForEachDependencyData {
/* Stores state for the FOREACH macro below for iterating through all deps that have any of the

View File

@ -30,8 +30,5 @@ typedef enum WipeScope {
_WIPE_SCOPE_INVALID = -EINVAL,
} WipeScope;
const char* enroll_type_to_string(EnrollType t);
EnrollType enroll_type_from_string(const char *s);
const char* luks2_token_type_to_string(EnrollType t);
EnrollType luks2_token_type_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(enroll_type, EnrollType);
DECLARE_STRING_TABLE_LOOKUP(luks2_token_type, EnrollType);

View File

@ -0,0 +1,21 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "macro-fundamental.h"
#define DECLARE_STRING_TABLE_LOOKUP_TO_STRING(name, type) \
const char* name##_to_string(type i) _const_
#define DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(name, type) \
type name##_from_string(const char *s) _pure_
#define DECLARE_STRING_TABLE_LOOKUP(name, type) \
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(name, type); \
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(name, type)
#define DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(name, type) \
int name##_to_string_alloc(type i, char **ret)
#define DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name, type) \
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(name, type); \
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(name, type)

View File

@ -230,5 +230,4 @@ bool home_shall_rebalance(Home *h);
bool home_is_busy(Home *h);
const char* home_state_to_string(HomeState state);
HomeState home_state_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(home_state, HomeState);

View File

@ -48,8 +48,7 @@ typedef struct Operation {
} Operation;
Operation *operation_new(OperationType type, sd_bus_message *m);
Operation *operation_ref(Operation *operation);
Operation *operation_unref(Operation *operation);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Operation, operation);
DEFINE_TRIVIAL_CLEANUP_FUNC(Operation*, operation_unref);

View File

@ -51,5 +51,4 @@ int import_compress_init(ImportCompress *c, ImportCompressType t);
int import_compress(ImportCompress *c, const void *data, size_t size, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
const char* import_compress_type_to_string(ImportCompressType t) _const_;
ImportCompressType import_compress_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(import_compress_type, ImportCompressType);

View File

@ -20,8 +20,7 @@ typedef struct Writer {
} Writer;
int writer_new(RemoteServer *server, Writer **ret);
Writer* writer_ref(Writer *w);
Writer* writer_unref(Writer *w);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Writer, writer);
DEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref);

View File

@ -99,11 +99,9 @@ int manager_dispatch_reload_signal(sd_event_source *s, const struct signalfd_sig
/* Defined in generated journald-gperf.c */
const struct ConfigPerfItem* journald_gperf_lookup(const char *str, GPERF_LEN_TYPE length);
const char* storage_to_string(Storage s) _const_;
Storage storage_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(storage, Storage);
const char* split_mode_to_string(SplitMode s) _const_;
SplitMode split_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(split_mode, SplitMode);
CONFIG_PARSER_PROTOTYPE(config_parse_storage);
CONFIG_PARSER_PROTOTYPE(config_parse_line_max);

View File

@ -20,7 +20,7 @@ typedef enum DHCPState {
_DHCP_STATE_INVALID = -EINVAL,
} DHCPState;
const char* dhcp_state_to_string(DHCPState s) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_state, DHCPState);
typedef struct sd_dhcp_client sd_dhcp_client;

View File

@ -76,7 +76,7 @@ static inline bool duid_data_size_is_valid(size_t size) {
return size >= MIN_DUID_DATA_LEN && size <= MAX_DUID_DATA_LEN;
}
const char* duid_type_to_string(DUIDType t) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(duid_type, DUIDType);
int dhcp_duid_to_string_internal(uint16_t type, const void *data, size_t data_size, char **ret);
int dhcp_identifier_set_iaid(

View File

@ -150,9 +150,7 @@ typedef enum DHCP6FQDNFlag {
DHCP6_FQDN_FLAG_N = 1 << 2,
} DHCP6FQDNFlag;
const char* dhcp6_state_to_string(DHCP6State s) _const_;
const char* dhcp6_message_type_to_string(DHCP6MessageType s) _const_;
DHCP6MessageType dhcp6_message_type_from_string(const char *s) _pure_;
const char* dhcp6_message_status_to_string(DHCP6Status s) _const_;
DHCP6Status dhcp6_message_status_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp6_state, DHCP6State);
DECLARE_STRING_TABLE_LOOKUP(dhcp6_message_type, DHCP6MessageType);
DECLARE_STRING_TABLE_LOOKUP(dhcp6_message_status, DHCP6Status);
int dhcp6_message_status_to_errno(DHCP6Status s);

View File

@ -33,8 +33,7 @@ struct sd_lldp_rx {
struct ether_addr filter_address;
};
const char* lldp_rx_event_to_string(sd_lldp_rx_event_t e) _const_;
sd_lldp_rx_event_t lldp_rx_event_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(lldp_rx_event, sd_lldp_rx_event_t);
int lldp_rx_build_neighbors_json(sd_lldp_rx *lldp_rx, sd_json_variant **ret);

View File

@ -42,8 +42,7 @@ typedef struct sd_ndisc {
void *userdata;
} sd_ndisc;
const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(ndisc_event, sd_ndisc_event_t);
#define log_ndisc_errno(ndisc, error, fmt, ...) \
log_interface_prefix_full_errno( \

View File

@ -34,4 +34,4 @@ sd_ndisc_router* ndisc_router_new(ICMP6Packet *packet);
int ndisc_router_parse(sd_ndisc *nd, sd_ndisc_router *rt);
int ndisc_router_flags_to_string(uint64_t flags, char **ret);
const char* ndisc_router_preference_to_string(int s) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(ndisc_router_preference, int);

View File

@ -72,5 +72,4 @@ static inline int device_read_db(sd_device *device) {
int device_read_uevent_file(sd_device *device);
int device_set_action(sd_device *device, sd_device_action_t a);
sd_device_action_t device_action_from_string(const char *s) _pure_;
const char* device_action_to_string(sd_device_action_t a) _const_;
DECLARE_STRING_TABLE_LOOKUP(device_action, sd_device_action_t);

View File

@ -5,8 +5,7 @@
#include "sd-forward.h"
const char* audit_type_to_string(int type);
int audit_type_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(audit_type, int);
/* This is inspired by DNS TYPEnnn formatting */
#define audit_type_name_alloca(type) \

View File

@ -335,7 +335,7 @@ uint64_t journal_file_hash_data(JournalFile *f, const void *data, size_t sz);
bool journal_field_valid(const char *p, size_t l, bool allow_protected);
const char* journal_object_type_to_string(ObjectType type) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(journal_object_type, ObjectType);
static inline Compression COMPRESSION_FROM_OBJECT(const Object *o) {
assert(o);

View File

@ -29,8 +29,7 @@ static inline MMapCacheCategory type_to_category(ObjectType type) {
}
MMapCache* mmap_cache_new(void);
MMapCache* mmap_cache_ref(MMapCache *m);
MMapCache* mmap_cache_unref(MMapCache *m);
DECLARE_TRIVIAL_REF_UNREF_FUNC(MMapCache, mmap_cache);
DEFINE_TRIVIAL_CLEANUP_FUNC(MMapCache*, mmap_cache_unref);
int mmap_cache_fd_get(

View File

@ -73,20 +73,15 @@ typedef enum LinkOnlineState {
_LINK_ONLINE_STATE_INVALID = -EINVAL,
} LinkOnlineState;
const char* link_operstate_to_string(LinkOperationalState s) _const_;
LinkOperationalState link_operstate_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(link_operstate, LinkOperationalState);
const char* link_carrier_state_to_string(LinkCarrierState s) _const_;
LinkCarrierState link_carrier_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(link_carrier_state, LinkCarrierState);
const char* link_required_address_family_to_string(AddressFamily s) _const_;
AddressFamily link_required_address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(link_required_address_family, AddressFamily);
const char* link_address_state_to_string(LinkAddressState s) _const_;
LinkAddressState link_address_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(link_address_state, LinkAddressState);
const char* link_online_state_to_string(LinkOnlineState s) _const_;
LinkOnlineState link_online_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(link_online_state, LinkOnlineState);
typedef struct LinkOperationalStateRange {
LinkOperationalState min;

View File

@ -77,10 +77,8 @@ int manager_handle_action(
bool is_edge,
const char *action_seat);
const char* handle_action_verb_to_string(HandleAction h) _const_;
const char* handle_action_to_string(HandleAction h) _const_;
HandleAction handle_action_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(handle_action_verb, HandleAction);
DECLARE_STRING_TABLE_LOOKUP(handle_action, HandleAction);
const HandleActionData* handle_action_lookup(HandleAction action);

View File

@ -87,5 +87,4 @@ static inline bool inhibit_what_is_valid(InhibitWhat w) {
const char* inhibit_what_to_string(InhibitWhat w);
int inhibit_what_from_string(const char *s);
const char* inhibit_mode_to_string(InhibitMode k);
InhibitMode inhibit_mode_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(inhibit_mode, InhibitMode);

View File

@ -196,20 +196,15 @@ int session_kill(Session *s, KillWhom whom, int signo, sd_bus_error *error);
SessionState session_get_state(Session *s);
const char* session_state_to_string(SessionState t) _const_;
SessionState session_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(session_state, SessionState);
const char* session_type_to_string(SessionType t) _const_;
SessionType session_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(session_type, SessionType);
const char* session_class_to_string(SessionClass t) _const_;
SessionClass session_class_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(session_class, SessionClass);
const char* kill_whom_to_string(KillWhom k) _const_;
KillWhom kill_whom_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom);
const char* tty_validity_to_string(TTYValidity t) _const_;
TTYValidity tty_validity_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(tty_validity, TTYValidity);
void session_leave_vt(Session *s);

View File

@ -83,10 +83,8 @@ int user_check_linger_file(const User *u);
void user_elect_display(User *u);
void user_update_last_session_timer(User *u);
const char* user_state_to_string(UserState s) _const_;
UserState user_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(user_state, UserState);
const char* user_gc_mode_to_string(UserGCMode m) _const_;
UserGCMode user_gc_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(user_gc_mode, UserGCMode);
CONFIG_PARSER_PROTOTYPE(config_parse_compat_user_tasks_max);

View File

@ -10,8 +10,7 @@ typedef enum ImageCleanPoolMode {
_IMAGE_CLEAN_POOL_INVALID = -EINVAL,
} ImageCleanPoolMode;
ImageCleanPoolMode image_clean_pool_mode_from_string(const char *s) _pure_;
const char* image_clean_pool_mode_to_string(ImageCleanPoolMode mode) _const_;
DECLARE_STRING_TABLE_LOOKUP(image_clean_pool_mode, ImageCleanPoolMode);
int image_clean_pool_operation(Manager *manager, ImageCleanPoolMode mode, Operation **ret_operation);
int clean_pool_read_first_entry(FILE *file, int child_error, sd_bus_error *error);

View File

@ -107,14 +107,11 @@ void machine_release_unit(Machine *m);
MachineState machine_get_state(Machine *m);
const char* machine_class_to_string(MachineClass t) _const_;
MachineClass machine_class_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(machine_class, MachineClass);
const char* machine_state_to_string(MachineState t) _const_;
MachineState machine_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(machine_state, MachineState);
const char* kill_whom_to_string(KillWhom k) _const_;
KillWhom kill_whom_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(kill_whom, KillWhom);
int machine_openpt(Machine *m, int flags, char **ret_peer);
int machine_start_getty(Machine *m, const char *ptmx_name, sd_bus_error *error);
@ -149,8 +146,7 @@ typedef enum AcquireMetadata {
_ACQUIRE_METADATA_INVALID = -EINVAL,
} AcquireMetadata;
AcquireMetadata acquire_metadata_from_string(const char *s) _pure_;
const char* acquire_metadata_to_string(AcquireMetadata am) _const_;
DECLARE_STRING_TABLE_LOOKUP(acquire_metadata, AcquireMetadata);
inline static bool should_acquire_metadata(AcquireMetadata am) {
return am == ACQUIRE_METADATA_YES || am == ACQUIRE_METADATA_GRACEFUL;
}

View File

@ -2,8 +2,8 @@
* Copyright © 2020 VMware, Inc. */
#pragma once
#include "shared-forward.h"
#include "netdev.h"
#include "shared-forward.h"
typedef enum BareUDPProtocol {
BARE_UDP_PROTOCOL_IPV4 = ETH_P_IP,
@ -25,7 +25,6 @@ typedef struct BareUDP {
DEFINE_NETDEV_CAST(BAREUDP, BareUDP);
extern const NetDevVTable bare_udp_vtable;
const char* bare_udp_protocol_to_string(BareUDPProtocol d) _const_;
BareUDPProtocol bare_udp_protocol_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(bare_udp_protocol, BareUDPProtocol);
CONFIG_PARSER_PROTOTYPE(config_parse_bare_udp_iftype);

View File

@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "netdev.h"
#include "shared-forward.h"
#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128U
#define LINK_BRIDGE_PORT_PRIORITY_MAX 63U
@ -41,8 +41,7 @@ typedef enum MulticastRouter {
DEFINE_NETDEV_CAST(BRIDGE, Bridge);
extern const NetDevVTable bridge_vtable;
const char* multicast_router_to_string(MulticastRouter i) _const_;
MulticastRouter multicast_router_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(multicast_router, MulticastRouter);
CONFIG_PARSER_PROTOTYPE(config_parse_multicast_router);
CONFIG_PARSER_PROTOTYPE(config_parse_bridge_igmp_version);

View File

@ -4,8 +4,8 @@
#include <linux/fou.h>
#include "in-addr-util.h"
#include "shared-forward.h"
#include "netdev.h"
#include "shared-forward.h"
typedef enum FooOverUDPEncapType {
NETDEV_FOO_OVER_UDP_ENCAP_UNSPEC = FOU_ENCAP_UNSPEC,
@ -34,8 +34,7 @@ typedef struct FouTunnel {
DEFINE_NETDEV_CAST(FOU, FouTunnel);
extern const NetDevVTable foutnl_vtable;
const char* fou_encap_type_to_string(FooOverUDPEncapType d) _const_;
FooOverUDPEncapType fou_encap_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(fou_encap_type, FooOverUDPEncapType);
CONFIG_PARSER_PROTOTYPE(config_parse_fou_encap_type);
CONFIG_PARSER_PROTOTYPE(config_parse_fou_tunnel_address);

View File

@ -3,9 +3,9 @@
#include <linux/if_link.h>
#include "shared-forward.h"
#include "in-addr-util.h"
#include "netdev.h"
#include "shared-forward.h"
#define GENEVE_VID_MAX (1u << 24) - 1
@ -44,8 +44,7 @@ typedef struct Geneve {
DEFINE_NETDEV_CAST(GENEVE, Geneve);
extern const NetDevVTable geneve_vtable;
const char* geneve_df_to_string(GeneveDF d) _const_;
GeneveDF geneve_df_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(geneve_df, GeneveDF);
CONFIG_PARSER_PROTOTYPE(config_parse_geneve_vni);
CONFIG_PARSER_PROTOTYPE(config_parse_geneve_address);

View File

@ -23,6 +23,6 @@ typedef struct Hsr {
DEFINE_NETDEV_CAST(HSR, Hsr);
extern const NetDevVTable hsr_vtable;
HsrProtocol hsr_protocol_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(hsr_protocol, HsrProtocol);
CONFIG_PARSER_PROTOTYPE(config_parse_hsr_protocol);

View File

@ -14,8 +14,7 @@ typedef enum NetDevLocalAddressType {
_NETDEV_LOCAL_ADDRESS_TYPE_INVALID = -EINVAL,
} NetDevLocalAddressType;
const char* netdev_local_address_type_to_string(NetDevLocalAddressType t) _const_;
NetDevLocalAddressType netdev_local_address_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(netdev_local_address_type, NetDevLocalAddressType);
int link_get_local_address(
Link *link,

View File

@ -227,8 +227,7 @@ void netdev_drop(NetDev *netdev);
void netdev_enter_failed(NetDev *netdev);
int netdev_enter_ready(NetDev *netdev);
NetDev* netdev_unref(NetDev *netdev);
NetDev* netdev_ref(NetDev *netdev);
DECLARE_TRIVIAL_REF_UNREF_FUNC(NetDev, netdev);
DEFINE_TRIVIAL_DESTRUCTOR(netdev_destroy_callback, NetDev, netdev_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
@ -242,8 +241,7 @@ int netdev_generate_hw_addr(NetDev *netdev, Link *parent, const char *name,
bool netdev_needs_reconfigure(NetDev *netdev, NetDevLocalAddressType type);
int link_request_stacked_netdev(Link *link, NetDev *netdev);
const char* netdev_kind_to_string(NetDevKind d) _const_;
NetDevKind netdev_kind_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(netdev_kind, NetDevKind);
static inline NetDevCreateType netdev_get_create_type(NetDev *netdev) {
assert(netdev);

View File

@ -1,10 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "fou-tunnel.h"
#include "netdev.h"
#include "networkd-link.h"
#include "shared-forward.h"
/* For IFLA_IPTUN_PROTO attribute */
typedef enum TunnelMode {
@ -122,8 +122,7 @@ extern const NetDevVTable ip6gretap_vtable;
extern const NetDevVTable ip6tnl_vtable;
extern const NetDevVTable erspan_vtable;
const char* tunnel_mode_to_string(TunnelMode d) _const_;
TunnelMode tunnel_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(tunnel_mode, TunnelMode);
CONFIG_PARSER_PROTOTYPE(config_parse_tunnel_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_tunnel_local_address);

View File

@ -65,8 +65,7 @@ typedef struct VxLan {
DEFINE_NETDEV_CAST(VXLAN, VxLan);
extern const NetDevVTable vxlan_vtable;
const char* df_to_string(VxLanDF d) _const_;
VxLanDF df_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(df, VxLanDF);
CONFIG_PARSER_PROTOTYPE(config_parse_vxlan_address);
CONFIG_PARSER_PROTOTYPE(config_parse_port_range);

View File

@ -3,8 +3,7 @@
#include "networkd-forward.h"
IPv6Token* ipv6_token_ref(IPv6Token *token);
IPv6Token* ipv6_token_unref(IPv6Token *token);
DECLARE_TRIVIAL_REF_UNREF_FUNC(IPv6Token, ipv6_token);
int dhcp_pd_generate_addresses(Link *link, const struct in6_addr *prefix, Hashmap **ret);
int ndisc_generate_addresses(Link *link, const struct in6_addr *prefix, uint8_t prefixlen, Hashmap **ret);

View File

@ -87,8 +87,7 @@ extern const struct hash_ops address_hash_ops;
bool address_can_update(const Address *existing, const Address *requesting);
Address* address_ref(Address *address);
Address* address_unref(Address *address);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Address, address);
int address_new(Address **ret);
int address_new_static(Network *network, const char *filename, unsigned section_line, Address **ret);

View File

@ -73,8 +73,7 @@ static inline bool in6_prefix_is_filtered(const struct in6_addr *prefix, uint8_t
int link_get_captive_portal(Link *link, const char **ret);
const char* dhcp_option_data_type_to_string(DHCPOptionDataType d) _const_;
DHCPOptionDataType dhcp_option_data_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(dhcp_option_data_type, DHCPOptionDataType);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_metric);

View File

@ -26,5 +26,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_pd_prefix_hint);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_client_start_mode);
const char* dhcp6_client_start_mode_to_string(DHCP6ClientStartMode i) _const_;
DHCP6ClientStartMode dhcp6_client_start_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(dhcp6_client_start_mode, DHCP6ClientStartMode);

View File

@ -16,8 +16,7 @@ UseDomains link_get_use_domains(Link *link, NetworkConfigSource proto);
bool link_get_use_dns(Link *link, NetworkConfigSource proto);
bool link_get_use_dnr(Link *link, NetworkConfigSource proto);
const char* use_domains_to_string(UseDomains p) _const_;
UseDomains use_domains_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(use_domains, UseDomains);
CONFIG_PARSER_PROTOTYPE(config_parse_domains);
CONFIG_PARSER_PROTOTYPE(config_parse_dns);

View File

@ -24,7 +24,6 @@ int link_update_ipv6ll_addrgen_mode(Link *link, sd_netlink_message *message);
int link_set_ipv6ll_stable_secret(Link *link);
int link_set_ipv6ll_addrgen_mode(Link *link, IPv6LinkLocalAddressGenMode mode);
const char* ipv6_link_local_address_gen_mode_to_string(IPv6LinkLocalAddressGenMode s) _const_;
IPv6LinkLocalAddressGenMode ipv6_link_local_address_gen_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(ipv6_link_local_address_gen_mode, IPv6LinkLocalAddressGenMode);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode);

View File

@ -207,8 +207,7 @@ bool link_is_ready_to_configure_by_name(Manager *manager, const char *name, bool
void link_ntp_settings_clear(Link *link);
void link_dns_settings_clear(Link *link);
Link* link_unref(Link *link);
Link* link_ref(Link *link);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Link, link);
DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref);
@ -236,8 +235,7 @@ bool link_has_ipv6_connectivity(Link *link);
int link_stop_engines(Link *link, bool may_keep_dynamic);
const char* link_state_to_string(LinkState s) _const_;
LinkState link_state_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(link_state, LinkState);
int link_request_stacked_netdevs(Link *link, NetDevLocalAddressType type);
@ -252,8 +250,8 @@ int link_check_initialized(Link *link);
int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t action);
int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
int link_flags_to_string_alloc(uint32_t flags, char **ret);
const char* kernel_operstate_to_string(int t) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(link_flags, uint32_t);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(kernel_operstate, int);
void link_required_operstate_for_online(Link *link, LinkOperationalStateRange *ret);
AddressFamily link_required_family_for_online(Link *link);

View File

@ -13,7 +13,6 @@ typedef enum LLDPMode {
int link_lldp_rx_configure(Link *link);
const char* lldp_mode_to_string(LLDPMode m) _const_;
LLDPMode lldp_mode_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(lldp_mode, LLDPMode);
CONFIG_PARSER_PROTOTYPE(config_parse_lldp_mode);

View File

@ -19,8 +19,7 @@ typedef struct Neighbor {
struct hw_addr_data ll_addr;
} Neighbor;
Neighbor* neighbor_ref(Neighbor *neighbor);
Neighbor* neighbor_unref(Neighbor *neighbor);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Neighbor, neighbor);
int neighbor_get(Link *link, const Neighbor *in, Neighbor **ret);
int neighbor_remove(Neighbor *neighbor, Link *link);

View File

@ -416,8 +416,7 @@ typedef struct Network {
char **ntp;
} Network;
Network *network_ref(Network *network);
Network *network_unref(Network *network);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Network, network);
DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
int network_load(Manager *manager, OrderedHashmap **ret);
@ -443,8 +442,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ignore_carrier_loss);
const struct ConfigPerfItem* network_network_gperf_lookup(const char *str, GPERF_LEN_TYPE length);
const char* keep_configuration_to_string(KeepConfiguration i) _const_;
KeepConfiguration keep_configuration_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(keep_configuration, KeepConfiguration);
const char* activation_policy_to_string(ActivationPolicy i) _const_;
ActivationPolicy activation_policy_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(activation_policy, ActivationPolicy);

View File

@ -83,8 +83,7 @@ typedef struct Request {
bool waiting_reply;
} Request;
Request *request_ref(Request *req);
Request *request_unref(Request *req);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Request, request);
DEFINE_TRIVIAL_CLEANUP_FUNC(Request*, request_unref);
void request_detach(Request *req);
@ -151,7 +150,7 @@ static inline int link_queue_request(
int manager_process_requests(Manager *manager);
int request_call_netlink_async(sd_netlink *nl, sd_netlink_message *m, Request *req);
const char* request_type_to_string(RequestType t) _const_;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(request_type, RequestType);
typedef struct RemoveRequest RemoveRequest;
typedef int (*remove_request_netlink_handler_t)(sd_netlink *nl, sd_netlink_message *m, RemoveRequest *req);

View File

@ -56,8 +56,7 @@ int radv_add_prefix(Link *link, const struct in6_addr *prefix, uint8_t prefix_le
int link_request_radv(Link *link);
int link_drop_radv_config(Link *link, Network *network);
const char* radv_prefix_delegation_to_string(RADVPrefixDelegation i) _const_;
RADVPrefixDelegation radv_prefix_delegation_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(radv_prefix_delegation, RADVPrefixDelegation);
CONFIG_PARSER_PROTOTYPE(config_parse_router_prefix_delegation);
CONFIG_PARSER_PROTOTYPE(config_parse_router_lifetime);

View File

@ -31,18 +31,17 @@ int manager_address_is_reachable(
const union in_addr_union *prefsrc, /* optional */
Address **ret);
int route_type_from_string(const char *s) _pure_;
const char* route_type_to_string(int t) _const_;
DECLARE_STRING_TABLE_LOOKUP(route_type, int);
int route_scope_from_string(const char *s);
int route_scope_to_string_alloc(int t, char **ret);
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_scope, int);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_scope, int);
int route_protocol_from_string(const char *s);
int route_protocol_to_string_alloc(int t, char **ret);
int route_protocol_full_from_string(const char *s);
int route_protocol_full_to_string_alloc(int t, char **ret);
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol, int);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_protocol, int);
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol_full, int);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_protocol_full, int);
int route_flags_to_string_alloc(uint32_t flags, char **ret);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_flags, uint32_t);
int manager_get_route_table_from_string(const Manager *m, const char *s, uint32_t *ret);
int manager_get_route_table_to_string(const Manager *m, uint32_t table, bool append_num, char **ret);

View File

@ -74,8 +74,7 @@ void log_route_debug(const Route *route, const char *str, Manager *manager);
extern const struct hash_ops route_hash_ops;
extern const struct hash_ops route_hash_ops_unref;
Route* route_ref(Route *route);
Route* route_unref(Route *route);
DECLARE_TRIVIAL_REF_UNREF_FUNC(Route, route);
DEFINE_SECTION_CLEANUP_FUNCTIONS(Route, route_unref);
void route_detach(Route *route);

View File

@ -46,11 +46,9 @@ typedef struct RoutingPolicyRule {
struct fib_rule_port_range dport; /* FRA_DPORT_RANGE */
} RoutingPolicyRule;
int fr_act_type_from_string(const char *s) _pure_;
const char* fr_act_type_to_string(int t) _const_;
DECLARE_STRING_TABLE_LOOKUP(fr_act_type, int);
RoutingPolicyRule* routing_policy_rule_ref(RoutingPolicyRule *rule);
RoutingPolicyRule* routing_policy_rule_unref(RoutingPolicyRule *rule);
DECLARE_TRIVIAL_REF_UNREF_FUNC(RoutingPolicyRule, routing_policy_rule);
void network_drop_invalid_routing_policy_rules(Network *network);

View File

@ -39,11 +39,9 @@ int link_set_sysctl(Link *link);
int link_set_ipv6_mtu(Link *link, int log_level);
int link_set_ipv6_mtu_async(Link *link);
const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(ipv6_privacy_extensions, IPv6PrivacyExtensions);
const char* ip_reverse_path_filter_to_string(IPReversePathFilter i) _const_;
IPReversePathFilter ip_reverse_path_filter_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(ip_reverse_path_filter, IPReversePathFilter);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_reverse_path_filter);
@ -59,7 +57,6 @@ typedef enum IPv4ForceIgmpVersion {
_IPV4_FORCE_IGMP_VERSION_INVALID = -EINVAL,
} IPv4ForceIgmpVersion;
const char* ipv4_force_igmp_version_to_string(IPv4ForceIgmpVersion i) _const_;
IPv4ForceIgmpVersion ipv4_force_igmp_version_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(ipv4_force_igmp_version, IPv4ForceIgmpVersion);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4_force_igmp_version);

View File

@ -47,10 +47,9 @@ CONFIG_PARSER_PROTOTYPE(config_parse_link_local_address_family);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_masquerade);
CONFIG_PARSER_PROTOTYPE(config_parse_mud_url);
const char* network_config_source_to_string(NetworkConfigSource s) _const_;
NetworkConfigSource network_config_source_from_string(const char* s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(network_config_source, NetworkConfigSource);
int network_config_state_to_string_alloc(NetworkConfigState s, char **ret);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(network_config_state, NetworkConfigState);
#define DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(type, name) \
static inline void name##_update_state( \
@ -124,24 +123,19 @@ int network_config_state_to_string_alloc(NetworkConfigState s, char **ret);
0); \
}
const char* address_family_to_string(AddressFamily b) _const_;
AddressFamily address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(address_family, AddressFamily);
AddressFamily link_local_address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(link_local_address_family, AddressFamily);
const char* routing_policy_rule_address_family_to_string(AddressFamily b) _const_;
AddressFamily routing_policy_rule_address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(routing_policy_rule_address_family, AddressFamily);
const char* nexthop_address_family_to_string(AddressFamily b) _const_;
AddressFamily nexthop_address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(nexthop_address_family, AddressFamily);
const char* duplicate_address_detection_address_family_to_string(AddressFamily b) _const_;
AddressFamily duplicate_address_detection_address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(duplicate_address_detection_address_family, AddressFamily);
AddressFamily dhcp_deprecated_address_family_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_deprecated_address_family, AddressFamily);
const char* dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type_t t) _const_;
sd_dhcp_lease_server_type_t dhcp_lease_server_type_from_string(const char *s) _pure_;
DECLARE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type_t);
bool link_should_mark_config(Link *link, bool only_static, NetworkConfigSource source, uint8_t protocol);

View File

@ -74,8 +74,7 @@ extern const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX];
DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(QDisc, qdisc);
QDisc* qdisc_ref(QDisc *qdisc);
QDisc* qdisc_unref(QDisc *qdisc);
DECLARE_TRIVIAL_REF_UNREF_FUNC(QDisc, qdisc);
int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, unsigned section_line, QDisc **ret);
void qdisc_mark_recursive(QDisc *qdisc);

Some files were not shown because too many files have changed in this diff Show More