chiark / gitweb /
fb77509cce541e32f1b1a0b10d24aae45cdc0740
[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 #define KEY_SYSFS_PAIRS_MAX     5
31 #define KEY_ENV_PAIRS_MAX       5
32
33 #define RULEFILE_SUFFIX         ".rules"
34
35 enum key_operation {
36         KEY_OP_UNSET,
37         KEY_OP_MATCH,
38         KEY_OP_NOMATCH,
39         KEY_OP_ADD,
40         KEY_OP_ASSIGN,
41         KEY_OP_ASSIGN_FINAL,
42 };
43
44 struct key_pair {
45         char name[NAME_SIZE];
46         char value[VALUE_SIZE];
47         enum key_operation operation;
48 };
49
50 struct udev_rule {
51         struct list_head node;
52
53         char kernel_name[NAME_SIZE];
54         enum key_operation kernel_operation;
55         char subsystem[NAME_SIZE];
56         enum key_operation subsystem_operation;
57         char action[NAME_SIZE];
58         enum key_operation action_operation;
59         char devpath[PATH_SIZE];
60         enum key_operation devpath_operation;
61         char bus[NAME_SIZE];
62         enum key_operation bus_operation;
63         char id[NAME_SIZE];
64         enum key_operation id_operation;
65         char driver[NAME_SIZE];
66         enum key_operation driver_operation;
67         char program[PATH_SIZE];
68         enum key_operation program_operation;
69         char result[PATH_SIZE];
70         enum key_operation result_operation;
71         struct key_pair sysfs_pair[KEY_SYSFS_PAIRS_MAX];
72         int sysfs_pair_count;
73         struct key_pair env_pair[KEY_ENV_PAIRS_MAX];
74         int env_pair_count;
75         char modalias[NAME_SIZE];
76         enum key_operation modalias_operation;
77         char import[PATH_SIZE];
78         enum key_operation import_operation;
79         int import_exec;
80
81         char name[PATH_SIZE];
82         enum key_operation name_operation;
83         char symlink[PATH_SIZE];
84         enum key_operation symlink_operation;
85         char owner[USER_SIZE];
86         enum key_operation owner_operation;
87         char group[USER_SIZE];
88         enum key_operation group_operation;
89         mode_t mode;
90         enum key_operation mode_operation;
91         char run[PATH_SIZE];
92         enum key_operation run_operation;
93
94         int last_rule;
95         int ignore_device;
96         int ignore_remove;
97         int partitions;
98
99         char config_file[PATH_SIZE];
100         int config_line;
101 };
102
103 extern int udev_rules_init(void);
104 extern void udev_rules_close(void);
105
106 extern int udev_rules_iter_init(void);
107 extern struct udev_rule *udev_rules_iter_next(void);
108
109 extern int udev_rules_get_name(struct udevice *udev, struct sysfs_class_device *class_dev);
110 extern int udev_rules_get_run(struct udevice *udev, struct sysfs_device *sysfs_device);
111
112 #endif