chiark / gitweb /
run_directory: fix typo in "make install"
[elogind.git] / udev_rules.h
1 /*
2  * udev_rules.h
3  *
4  * Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
5  * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
6  *
7  *      This program is free software; you can redistribute it and/or modify it
8  *      under the terms of the GNU General Public License as published by the
9  *      Free Software Foundation version 2 of the License.
10  * 
11  *      This program is distributed in the hope that it will be useful, but
12  *      WITHOUT ANY WARRANTY; without even the implied warranty of
13  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *      General Public License for more details.
15  * 
16  *      You should have received a copy of the GNU General Public License along
17  *      with this program; if not, write to the Free Software Foundation, Inc.,
18  *      675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */
21
22 #ifndef UDEV_RULES_H
23 #define UDEV_RULES_H
24
25 #include "libsysfs/sysfs/libsysfs.h"
26 #include "udev.h"
27 #include "list.h"
28
29 #define PAIRS_MAX               5
30 #define RULEFILE_SUFFIX         ".rules"
31
32 enum key_operation {
33         KEY_OP_UNSET,
34         KEY_OP_MATCH,
35         KEY_OP_NOMATCH,
36         KEY_OP_ADD,
37         KEY_OP_ASSIGN,
38         KEY_OP_ASSIGN_FINAL,
39 };
40
41 struct key {
42         enum key_operation operation;
43         size_t val_off;
44 };
45
46 struct key_pair {
47         struct key key;
48         size_t key_name_off;
49 };
50
51 struct key_pairs {
52         int count;
53         struct key_pair keys[PAIRS_MAX];
54 };
55
56 enum import_type {
57         IMPORT_UNSET,
58         IMPORT_PROGRAM,
59         IMPORT_FILE,
60         IMPORT_PARENT,
61 };
62
63 struct udev_rule {
64         struct key label;
65         struct key goto_label;
66         struct key kernel_name;
67         struct key subsystem;
68         struct key action;
69         struct key devpath;
70         struct key bus;
71         struct key id;
72         struct key driver;
73         struct key program;
74         struct key result;
75         struct key modalias;
76         struct key import;
77         enum import_type import_type;
78         struct key wait_for_sysfs;
79         struct key_pairs sysfs;
80         struct key_pairs env;
81
82         struct key name;
83         struct key symlink;
84         struct key run;
85         struct key owner;
86         struct key group;
87         enum key_operation mode_operation;
88         mode_t mode;
89
90         unsigned int partitions;
91         unsigned int last_rule:1,
92                      ignore_device:1,
93                      ignore_remove:1;
94
95         size_t bufsize;
96         char buf[];
97 };
98
99 struct udev_rules {
100         char *buf;
101         size_t bufsize;
102         size_t current;
103         int mapped;
104         int resolve_names;
105 };
106
107 extern int udev_rules_init(struct udev_rules *rules, int read_compiled, int resolve_names);
108 extern void udev_rules_close(struct udev_rules *rules);
109
110 extern void udev_apply_format(struct udevice *udev, char *string, size_t maxsize,
111                               struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device);
112
113 extern void udev_rules_iter_init(struct udev_rules *rules);
114 extern struct udev_rule *udev_rules_iter_next(struct udev_rules *rules);
115 extern struct udev_rule *udev_rules_iter_label(struct udev_rules *rules, const char *label);
116
117 extern int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev,
118                                struct sysfs_class_device *class_dev);
119 extern int udev_rules_get_run(struct udev_rules *rules, struct udevice *udev,
120                               struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_dev);
121
122 #endif