]>
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 YW |
6 | #include "sd-device.h" |
7 | ||
25de7aa7 | 8 | typedef enum { |
07a26e42 YW |
9 | #if HAVE_BLKID |
10 | UDEV_BUILTIN_BLKID, | |
11 | #endif | |
12 | UDEV_BUILTIN_BTRFS, | |
13 | UDEV_BUILTIN_HWDB, | |
14 | UDEV_BUILTIN_INPUT_ID, | |
15 | UDEV_BUILTIN_KEYBOARD, | |
16 | #if HAVE_KMOD | |
17 | UDEV_BUILTIN_KMOD, | |
18 | #endif | |
19 | UDEV_BUILTIN_NET_ID, | |
20 | UDEV_BUILTIN_NET_LINK, | |
21 | UDEV_BUILTIN_PATH_ID, | |
22 | UDEV_BUILTIN_USB_ID, | |
23 | #if HAVE_ACL | |
24 | UDEV_BUILTIN_UACCESS, | |
25 | #endif | |
c45b369d | 26 | _UDEV_BUILTIN_MAX, |
2d93c20e | 27 | _UDEV_BUILTIN_INVALID = -EINVAL, |
25de7aa7 | 28 | } UdevBuiltinCommand; |
07a26e42 | 29 | |
25de7aa7 | 30 | typedef struct UdevBuiltin { |
07a26e42 | 31 | const char *name; |
3fc2e9a2 | 32 | int (*cmd)(sd_device *dev, int argc, char *argv[], bool test); |
07a26e42 YW |
33 | const char *help; |
34 | int (*init)(void); | |
35 | void (*exit)(void); | |
36 | bool (*validate)(void); | |
37 | bool run_once; | |
25de7aa7 YW |
38 | } UdevBuiltin; |
39 | ||
71c163c9 ZJS |
40 | #define UDEV_BUILTIN_CMD_TO_PTR(u) \ |
41 | ({ \ | |
42 | UdevBuiltinCommand _u = (u); \ | |
43 | _u < 0 ? NULL : (void*)(intptr_t) (_u + 1); \ | |
44 | }) | |
45 | ||
46 | #define PTR_TO_UDEV_BUILTIN_CMD(p) \ | |
47 | ({ \ | |
48 | void *_p = (p); \ | |
49 | _p && (intptr_t)(_p) <= _UDEV_BUILTIN_MAX ? \ | |
50 | (UdevBuiltinCommand)((intptr_t)_p - 1) : _UDEV_BUILTIN_INVALID; \ | |
51 | }) | |
07a26e42 YW |
52 | |
53 | #if HAVE_BLKID | |
25de7aa7 | 54 | extern const UdevBuiltin udev_builtin_blkid; |
07a26e42 | 55 | #endif |
25de7aa7 YW |
56 | extern const UdevBuiltin udev_builtin_btrfs; |
57 | extern const UdevBuiltin udev_builtin_hwdb; | |
58 | extern const UdevBuiltin udev_builtin_input_id; | |
59 | extern const UdevBuiltin udev_builtin_keyboard; | |
07a26e42 | 60 | #if HAVE_KMOD |
25de7aa7 | 61 | extern const UdevBuiltin udev_builtin_kmod; |
07a26e42 | 62 | #endif |
25de7aa7 YW |
63 | extern const UdevBuiltin udev_builtin_net_id; |
64 | extern const UdevBuiltin udev_builtin_net_setup_link; | |
65 | extern const UdevBuiltin udev_builtin_path_id; | |
66 | extern const UdevBuiltin udev_builtin_usb_id; | |
07a26e42 | 67 | #if HAVE_ACL |
25de7aa7 | 68 | extern const UdevBuiltin udev_builtin_uaccess; |
07a26e42 YW |
69 | #endif |
70 | ||
71 | void udev_builtin_init(void); | |
72 | void udev_builtin_exit(void); | |
25de7aa7 YW |
73 | UdevBuiltinCommand udev_builtin_lookup(const char *command); |
74 | const char *udev_builtin_name(UdevBuiltinCommand cmd); | |
75 | bool udev_builtin_run_once(UdevBuiltinCommand cmd); | |
76 | int udev_builtin_run(sd_device *dev, UdevBuiltinCommand cmd, const char *command, bool test); | |
07a26e42 YW |
77 | void udev_builtin_list(void); |
78 | bool udev_builtin_validate(void); | |
0c9c0634 | 79 | int udev_builtin_add_property(sd_device *dev, bool test, const char *key, const char *val); |
bfc38d8f | 80 | int udev_builtin_hwdb_lookup(sd_device *dev, const char *prefix, const char *modalias, |
07a26e42 | 81 | const char *filter, bool test); |