chiark / gitweb /
Fix ChangeLog titles
[elogind.git] / udev_rules.h
1 /*
2  * udev_rules.h
3  *
4  * Userspace devfs
5  *
6  * Copyright (C) 2003,2004 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_RULES_H
24 #define UDEV_RULES_H
25
26 #include "libsysfs/sysfs/libsysfs.h"
27 #include "udev.h"
28 #include "list.h"
29
30
31 #define KEY_KERNEL              "KERNEL"
32 #define KEY_SUBSYSTEM           "SUBSYSTEM"
33 #define KEY_ACTION              "ACTION"
34 #define KEY_DEVPATH             "DEVPATH"
35 #define KEY_BUS                 "BUS"
36 #define KEY_ID                  "ID"
37 #define KEY_PROGRAM             "PROGRAM"
38 #define KEY_RESULT              "RESULT"
39 #define KEY_DRIVER              "DRIVER"
40 #define KEY_SYSFS               "SYSFS"
41 #define KEY_ENV                 "ENV"
42 #define KEY_MODALIAS            "MODALIAS"
43 #define KEY_IMPORT              "IMPORT"
44 #define KEY_NAME                "NAME"
45 #define KEY_SYMLINK             "SYMLINK"
46 #define KEY_OWNER               "OWNER"
47 #define KEY_GROUP               "GROUP"
48 #define KEY_MODE                "MODE"
49 #define KEY_RUN                 "RUN"
50 #define KEY_OPTIONS             "OPTIONS"
51
52 #define OPTION_LAST_RULE        "last_rule"
53 #define OPTION_IGNORE_DEVICE    "ignore_device"
54 #define OPTION_IGNORE_REMOVE    "ignore_remove"
55 #define OPTION_PARTITIONS       "all_partitions"
56
57 #define KEY_SYSFS_PAIRS_MAX     5
58 #define KEY_ENV_PAIRS_MAX       5
59
60 #define RULEFILE_SUFFIX         ".rules"
61
62 enum key_operation {
63         KEY_OP_UNSET,
64         KEY_OP_MATCH,
65         KEY_OP_NOMATCH,
66         KEY_OP_ADD,
67         KEY_OP_ASSIGN,
68         KEY_OP_ASSIGN_FINAL,
69 };
70
71 struct key_pair {
72         char name[NAME_SIZE];
73         char value[VALUE_SIZE];
74         enum key_operation operation;
75 };
76
77 struct udev_rule {
78         struct list_head node;
79
80         char kernel[NAME_SIZE];
81         enum key_operation kernel_operation;
82         char subsystem[NAME_SIZE];
83         enum key_operation subsystem_operation;
84         char action[NAME_SIZE];
85         enum key_operation action_operation;
86         char devpath[PATH_SIZE];
87         enum key_operation devpath_operation;
88         char bus[NAME_SIZE];
89         enum key_operation bus_operation;
90         char id[NAME_SIZE];
91         enum key_operation id_operation;
92         char driver[NAME_SIZE];
93         enum key_operation driver_operation;
94         char program[PATH_SIZE];
95         enum key_operation program_operation;
96         char result[PATH_SIZE];
97         enum key_operation result_operation;
98         struct key_pair sysfs_pair[KEY_SYSFS_PAIRS_MAX];
99         int sysfs_pair_count;
100         struct key_pair env_pair[KEY_ENV_PAIRS_MAX];
101         int env_pair_count;
102         char modalias[NAME_SIZE];
103         enum key_operation modalias_operation;
104         char import[PATH_SIZE];
105         enum key_operation import_operation;
106         int import_exec;
107
108         char name[PATH_SIZE];
109         enum key_operation name_operation;
110         char symlink[PATH_SIZE];
111         enum key_operation symlink_operation;
112         char owner[USER_SIZE];
113         enum key_operation owner_operation;
114         char group[USER_SIZE];
115         enum key_operation group_operation;
116         mode_t mode;
117         enum key_operation mode_operation;
118         char run[PATH_SIZE];
119         enum key_operation run_operation;
120
121         int last_rule;
122         int ignore_device;
123         int ignore_remove;
124         int partitions;
125
126         char config_file[PATH_SIZE];
127         int config_line;
128 };
129
130 extern int udev_rules_init(void);
131 extern void udev_rules_close(void);
132
133 extern int udev_rules_iter_init(void);
134 extern struct udev_rule *udev_rules_iter_next(void);
135
136 extern int udev_rules_get_name(struct udevice *udev, struct sysfs_class_device *class_dev);
137 extern int udev_rules_get_run(struct udevice *udev, struct sysfs_device *sysfs_device);
138
139 #endif