chiark / gitweb /
[PATCH] major database cleanups
[elogind.git] / udev.h
1 /*
2  * udev.h
3  *
4  * Userspace devfs
5  *
6  * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
7  *
8  *      This program is free software; you can redistribute it and/or modify it
9  *      under the terms of the GNU General Public License as published by the
10  *      Free Software Foundation version 2 of the License.
11  * 
12  *      This program is distributed in the hope that it will be useful, but
13  *      WITHOUT ANY WARRANTY; without even the implied warranty of
14  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *      General Public License for more details.
16  * 
17  *      You should have received a copy of the GNU General Public License along
18  *      with this program; if not, write to the Free Software Foundation, Inc.,
19  *      675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #ifndef UDEV_H
24 #define UDEV_H
25
26 #include "libsysfs/libsysfs.h"
27
28 #ifdef DEBUG
29 #include <syslog.h>
30 #define dbg(format, arg...)                                                             \
31         do {                                                                            \
32                 log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg);        \
33         } while (0)
34 #else
35         #define dbg(format, arg...) do { } while (0)
36 #endif
37
38 /* Parser needs it's own debugging statement, we usually don't care about this at all */
39 #ifdef DEBUG_PARSER
40 #define dbg_parse(format, arg...)                                                       \
41         do {                                                                            \
42                 log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg);        \
43         } while (0)
44 #else
45         #define dbg_parse(format, arg...) do { } while (0)
46 #endif
47
48
49 extern int log_message (int level, const char *format, ...)
50         __attribute__ ((format (printf, 2, 3)));
51
52
53 /* Lots of constants that should be in a config file sometime */
54
55 #define NAME_SIZE       100
56 #define OWNER_SIZE      30
57 #define GROUP_SIZE      30
58
59 struct device_attr {
60         char name[NAME_SIZE];
61         char owner[OWNER_SIZE];
62         char group[GROUP_SIZE];
63         mode_t mode;
64 };
65
66 struct udevice {
67         char name[NAME_SIZE];
68         char owner[OWNER_SIZE];
69         char group[GROUP_SIZE];
70         char type;
71         int major;
72         int minor;
73         mode_t mode;
74 };
75
76 extern int udev_add_device(char *path, char *subsystem);
77 extern int udev_remove_device(char *path, char *subsystem);
78
79 extern char **main_argv;
80 extern char **main_envp;
81 #endif
82