1/*****************************************************************************\
2*  _  _       _          _              ___                                   *
3* | || | ___ | |_  _ __ | | _  _  __ _ |_  )                                  *
4* | __ |/ _ \|  _|| '_ \| || || |/ _` | / /                                   *
5* |_||_|\___/ \__|| .__/|_| \_,_|\__, |/___|                                  *
6*                 |_|            |___/                                        *
7\*****************************************************************************/
8
9
10#ifndef HOTPLUG2_H
11#define HOTPLUG2_H 1
12
13/*
14 * Various compatibility definitions.
15 */
16#ifndef SO_RCVBUFFORCE
17#if defined(__alpha__) || defined(__hppa__) || defined(__sparc__) || \
18	defined(__sparc_v9__)
19#define SO_RCVBUFFORCE 			0x100b
20#else
21#define SO_RCVBUFFORCE			33
22#endif
23#endif
24
25#ifndef SO_SNDBUFFORCE
26#if defined(__alpha__) || defined(__hppa__) || defined(__sparc__) || \
27	defined(__sparc_v9__)
28#define SO_SNDBUFFORCE 			0x100a
29#else
30#define SO_SNDBUFFORCE			32
31#endif
32#endif
33
34#ifndef NETLINK_KOBJECT_UEVENT
35#define NETLINK_KOBJECT_UEVENT		15
36#endif
37
38#ifndef O_NOATIME
39#define O_NOATIME					01000000
40#endif
41
42#define ERROR(action, fmt, arg...)	fprintf(stderr, "[%s]: " fmt"\n", action, ##arg);
43#define INFO(action, fmt, arg...)	fprintf(stdout, "[%s]: " fmt"\n", action, ##arg);
44#ifdef DEBUG
45#define DBG(action, fmt, arg...)	fprintf(stdout, "[%s]: " fmt"\n", action, ##arg);
46#else
47#define DBG(action, fmt, arg...)
48#endif
49
50#define UEVENT_BUFFER_SIZE		2048
51#define HOTPLUG2_POLL_INTERVAL		20000
52#define HOTPLUG2_THROTTLE_INTERVAL		10000
53#define HOTPLUG2_RULE_PATH		"/etc/hotplug2.rules"
54
55#define ACTION_ADD			0
56#define ACTION_REMOVE			1
57#define ACTION_UNKNOWN			-1
58
59#define UDEVTRIGGER_COMMAND		"/sbin/udevtrigger", "/sbin/udevtrigger"
60
61#define FORK_CHILD			0
62#define FORK_ERROR			-1
63#define FORK_FINISHED			-2
64
65#define event_seqnum_t			unsigned long long
66
67#define sysfs_seqnum_path		"/sys/kernel/uevent_seqnum"
68
69struct env_var_t {
70	char *key;
71	char *value;
72};
73
74struct hotplug2_event_t {
75	int action;
76	event_seqnum_t seqnum;
77	struct env_var_t *env_vars;
78	int env_vars_c;
79	char *plain;
80	int plain_s;
81};
82
83struct options_t {
84	char *name;
85	int *value;
86};
87
88char *get_hotplug2_value_by_key(struct hotplug2_event_t *, char *);
89
90#endif /* ifndef HOTPLUG2_H */
91