1 /**************************************************************************
2 *
3 * Linux Kernel uevent handler
4 *
5 * Copyright (C) 2015 Sebastian Reichel <sre@ring0.de>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2
9 * or any later version as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 **************************************************************************/
19 
20 #ifndef UEVENT_H
21 #define UEVENT_H
22 
23 #include <glib.h>
24 
25 enum uevent_action {
26     UEVENT_UNKNOWN = 0x01,
27     UEVENT_ADD = 0x02,
28     UEVENT_REMOVE = 0x04,
29     UEVENT_CHANGE = 0x08,
30 };
31 
32 struct uevent_parameter {
33     char *key;
34     char *val;
35 };
36 
37 struct uevent {
38     char *path;
39     enum uevent_action action;
40     int sequence;
41     char *subsystem;
42     GList *params;
43 };
44 
45 struct uevent_notify {
46     int action;      /* bitfield */
47     char *subsystem; /* NULL => any */
48     void *userdata;
49 
50     void (*cb)(struct uevent *e, void *userdata);
51 };
52 
53 extern int uevent_fd;
54 
55 #if ENABLE_UEVENT
56 int uevent_init();
57 void uevent_cleanup();
58 void uevent_handler();
59 
60 void uevent_register_notifier(struct uevent_notify *nb);
61 void uevent_unregister_notifier(struct uevent_notify *nb);
62 #else
uevent_init()63 static inline int uevent_init()
64 {
65     return -1;
66 }
67 
uevent_cleanup()68 static inline void uevent_cleanup()
69 {
70 }
71 
uevent_handler()72 static inline void uevent_handler()
73 {
74 }
75 
uevent_register_notifier(struct uevent_notify * nb)76 static inline void uevent_register_notifier(struct uevent_notify *nb)
77 {
78 }
79 
uevent_unregister_notifier(struct uevent_notify * nb)80 static inline void uevent_unregister_notifier(struct uevent_notify *nb)
81 {
82 }
83 #endif
84 
85 #endif
86