]>
Commit | Line | Data |
---|---|---|
f13467ec | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
07a26e42 YW |
2 | #pragma once |
3 | ||
4 | #include <stdbool.h> | |
5 | ||
3fc2e9a2 | 6 | #include "sd-device.h" |
92232230 | 7 | #include "sd-netlink.h" |
3fc2e9a2 | 8 | |
85737dd3 | 9 | #include "macro.h" |
5668f3a7 | 10 | #include "udev-event.h" |
85737dd3 | 11 | |
23ebdf4f | 12 | typedef enum UdevBuiltinCommand { |
07a26e42 YW |
13 | #if HAVE_BLKID |
14 | UDEV_BUILTIN_BLKID, | |
15 | #endif | |
16 | UDEV_BUILTIN_BTRFS, | |
17 | UDEV_BUILTIN_HWDB, | |
18 | UDEV_BUILTIN_INPUT_ID, | |
19 | UDEV_BUILTIN_KEYBOARD, | |
20 | #if HAVE_KMOD | |
21 | UDEV_BUILTIN_KMOD, | |
22 | #endif | |
2b5b25f1 | 23 | UDEV_BUILTIN_NET_DRIVER, |
07a26e42 YW |
24 | UDEV_BUILTIN_NET_ID, |
25 | UDEV_BUILTIN_NET_LINK, | |
26 | UDEV_BUILTIN_PATH_ID, | |
27 | UDEV_BUILTIN_USB_ID, | |
28 | #if HAVE_ACL | |
29 | UDEV_BUILTIN_UACCESS, | |
30 | #endif | |
c45b369d | 31 | _UDEV_BUILTIN_MAX, |
2d93c20e | 32 | _UDEV_BUILTIN_INVALID = -EINVAL, |
25de7aa7 | 33 | } UdevBuiltinCommand; |
07a26e42 | 34 | |
25de7aa7 | 35 | typedef struct UdevBuiltin { |
07a26e42 | 36 | const char *name; |
089bef66 | 37 | int (*cmd)(UdevEvent *event, int argc, char *argv[]); |
07a26e42 YW |
38 | const char *help; |
39 | int (*init)(void); | |
40 | void (*exit)(void); | |
f9b3b990 | 41 | bool (*should_reload)(void); |
07a26e42 | 42 | bool run_once; |
25de7aa7 YW |
43 | } UdevBuiltin; |
44 | ||
71c163c9 ZJS |
45 | #define UDEV_BUILTIN_CMD_TO_PTR(u) \ |
46 | ({ \ | |
47 | UdevBuiltinCommand _u = (u); \ | |
48 | _u < 0 ? NULL : (void*)(intptr_t) (_u + 1); \ | |
49 | }) | |
50 | ||
51 | #define PTR_TO_UDEV_BUILTIN_CMD(p) \ | |
52 | ({ \ | |
53 | void *_p = (p); \ | |
54 | _p && (intptr_t)(_p) <= _UDEV_BUILTIN_MAX ? \ | |
55 | (UdevBuiltinCommand)((intptr_t)_p - 1) : _UDEV_BUILTIN_INVALID; \ | |
56 | }) | |
07a26e42 YW |
57 | |
58 | #if HAVE_BLKID | |
25de7aa7 | 59 | extern const UdevBuiltin udev_builtin_blkid; |
07a26e42 | 60 | #endif |
25de7aa7 YW |
61 | extern const UdevBuiltin udev_builtin_btrfs; |
62 | extern const UdevBuiltin udev_builtin_hwdb; | |
63 | extern const UdevBuiltin udev_builtin_input_id; | |
64 | extern const UdevBuiltin udev_builtin_keyboard; | |
07a26e42 | 65 | #if HAVE_KMOD |
25de7aa7 | 66 | extern const UdevBuiltin udev_builtin_kmod; |
07a26e42 | 67 | #endif |
2b5b25f1 | 68 | extern const UdevBuiltin udev_builtin_net_driver; |
25de7aa7 YW |
69 | extern const UdevBuiltin udev_builtin_net_id; |
70 | extern const UdevBuiltin udev_builtin_net_setup_link; | |
71 | extern const UdevBuiltin udev_builtin_path_id; | |
72 | extern const UdevBuiltin udev_builtin_usb_id; | |
07a26e42 | 73 | #if HAVE_ACL |
25de7aa7 | 74 | extern const UdevBuiltin udev_builtin_uaccess; |
07a26e42 YW |
75 | #endif |
76 | ||
77 | void udev_builtin_init(void); | |
78 | void udev_builtin_exit(void); | |
25de7aa7 YW |
79 | UdevBuiltinCommand udev_builtin_lookup(const char *command); |
80 | const char *udev_builtin_name(UdevBuiltinCommand cmd); | |
81 | bool udev_builtin_run_once(UdevBuiltinCommand cmd); | |
089bef66 | 82 | int udev_builtin_run(UdevEvent *event, UdevBuiltinCommand cmd, const char *command); |
07a26e42 | 83 | void udev_builtin_list(void); |
f9b3b990 | 84 | bool udev_builtin_should_reload(void); |
089bef66 YW |
85 | int udev_builtin_add_property(sd_device *dev, EventMode mode, const char *key, const char *val); |
86 | int udev_builtin_add_propertyf(sd_device *dev, EventMode mode, const char *key, const char *valf, ...) _printf_(4, 5); | |
87 | int udev_builtin_import_property(sd_device *dev, sd_device *src, EventMode mode, const char *key); | |
bfc38d8f | 88 | int udev_builtin_hwdb_lookup(sd_device *dev, const char *prefix, const char *modalias, |
089bef66 | 89 | const char *filter, EventMode mode); |