]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/udev.h
pkgconfig: define variables relative to ${prefix}/${rootprefix}/${sysconfdir}
[thirdparty/systemd.git] / src / udev / udev.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 #pragma once
3
4 /*
5 * Copyright © 2003 Greg Kroah-Hartman <greg@kroah.com>
6 */
7
8 #include <sys/param.h>
9 #include <sys/sysmacros.h>
10 #include <sys/types.h>
11
12 #include "sd-device.h"
13 #include "sd-netlink.h"
14
15 #include "hashmap.h"
16 #include "label.h"
17 #include "libudev-private.h"
18 #include "macro.h"
19 #include "strv.h"
20 #include "util.h"
21 #include "udev-util.h"
22
23 struct udev_event {
24 sd_device *dev;
25 sd_device *dev_parent;
26 sd_device *dev_db_clone;
27 char *name;
28 char *program_result;
29 mode_t mode;
30 uid_t uid;
31 gid_t gid;
32 Hashmap *seclabel_list;
33 Hashmap *run_list;
34 usec_t exec_delay_usec;
35 usec_t birth_usec;
36 sd_netlink *rtnl;
37 unsigned builtin_run;
38 unsigned builtin_ret;
39 bool inotify_watch;
40 bool inotify_watch_final;
41 bool group_set;
42 bool group_final;
43 bool owner_set;
44 bool owner_final;
45 bool mode_set;
46 bool mode_final;
47 bool name_final;
48 bool devlink_final;
49 bool run_final;
50 };
51
52 /* udev-rules.c */
53 struct udev_rules;
54 struct udev_rules *udev_rules_new(ResolveNameTiming resolve_name_timing);
55 struct udev_rules *udev_rules_unref(struct udev_rules *rules);
56 bool udev_rules_check_timestamp(struct udev_rules *rules);
57 int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event,
58 usec_t timeout_usec,
59 Hashmap *properties_list);
60 int udev_rules_apply_static_dev_perms(struct udev_rules *rules);
61
62 static inline usec_t udev_warn_timeout(usec_t timeout_usec) {
63 return DIV_ROUND_UP(timeout_usec, 3);
64 }
65
66 /* udev-event.c */
67 struct udev_event *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_netlink *rtnl);
68 struct udev_event *udev_event_free(struct udev_event *event);
69 ssize_t udev_event_apply_format(struct udev_event *event,
70 const char *src, char *dest, size_t size,
71 bool replace_whitespace);
72 int udev_event_spawn(struct udev_event *event,
73 usec_t timeout_usec,
74 bool accept_failure,
75 const char *cmd, char *result, size_t ressize);
76 int udev_event_execute_rules(struct udev_event *event,
77 usec_t timeout_usec,
78 Hashmap *properties_list,
79 struct udev_rules *rules);
80 void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec);
81
82 /* Cleanup functions */
83 DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_event*, udev_event_free);
84 DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_rules*, udev_rules_unref);