chiark / gitweb /
volume_id: remove s390 dasd handling, it is dasd_id now
[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 PAIRS_MAX               5
31 #define RULEFILE_SUFFIX         ".rules"
32
33 enum key_operation {
34         KEY_OP_UNSET,
35         KEY_OP_MATCH,
36         KEY_OP_NOMATCH,
37         KEY_OP_ADD,
38         KEY_OP_ASSIGN,
39         KEY_OP_ASSIGN_FINAL,
40 };
41
42 struct key {
43         enum key_operation operation;
44         size_t val_off;
45 };
46
47 struct key_pair {
48         struct key key;
49         size_t key_name_off;
50 };
51
52 struct key_pairs {
53         int count;
54         struct key_pair keys[PAIRS_MAX];
55 };
56
57 enum import_type {
58         IMPORT_UNSET,
59         IMPORT_PROGRAM,
60         IMPORT_FILE,
61         IMPORT_PARENT,
62 };
63
64 struct udev_rule {
65         struct key kernel_name;
66         struct key subsystem;
67         struct key action;
68         struct key devpath;
69         struct key bus;
70         struct key id;
71         struct key driver;
72         struct key program;
73         struct key result;
74         struct key modalias;
75         struct key import;
76         enum import_type import_type;
77         struct key wait_for_sysfs;
78         struct key_pairs sysfs;
79         struct key_pairs env;
80
81         struct key name;
82         struct key symlink;
83         struct key run;
84         struct key owner;
85         struct key group;
86         enum key_operation mode_operation;
87         mode_t mode;
88
89         unsigned int partitions;
90         unsigned int last_rule:1,
91                      ignore_device:1,
92                      ignore_remove:1;
93
94         size_t bufsize;
95         char buf[];
96 };
97
98 struct udev_rules {
99         char *buf;
100         size_t bufsize;
101         size_t current;
102         int mapped;
103         int resolve_names;
104 };
105
106 extern int udev_rules_init(struct udev_rules *rules, int resolve_names);
107 extern void udev_rules_close(struct udev_rules *rules);
108
109 extern void udev_rules_iter_init(struct udev_rules *rules);
110 extern struct udev_rule *udev_rules_iter_next(struct udev_rules *rules);
111
112 extern int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev, struct sysfs_class_device *class_dev);
113 extern int udev_rules_get_run(struct udev_rules *rules, struct udevice *udev, struct sysfs_device *sysfs_device);
114
115 #endif