chiark / gitweb /
[PATCH] support =, ==, !=, += for the key match and assignment
[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 NAMEDEV_H
24 #define NAMEDEV_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_BUS                 "BUS"
34 #define KEY_SYSFS               "SYSFS"
35 #define KEY_ID                  "ID"
36 #define KEY_PROGRAM             "PROGRAM"
37 #define KEY_RESULT              "RESULT"
38 #define KEY_DRIVER              "DRIVER"
39 #define KEY_NAME                "NAME"
40 #define KEY_SYMLINK             "SYMLINK"
41 #define KEY_OWNER               "OWNER"
42 #define KEY_GROUP               "GROUP"
43 #define KEY_MODE                "MODE"
44 #define KEY_OPTIONS             "OPTIONS"
45
46 #define OPTION_LAST_RULE        "last_rule"
47 #define OPTION_IGNORE_DEVICE    "ignore_device"
48 #define OPTION_IGNORE_REMOVE    "ignore_remove"
49 #define OPTION_PARTITIONS       "all_partitions"
50
51 #define MAX_SYSFS_PAIRS         5
52
53 #define RULEFILE_SUFFIX         ".rules"
54
55 enum key_operation {
56         KEY_OP_UNKNOWN,
57         KEY_OP_MATCH,
58         KEY_OP_NOMATCH,
59         KEY_OP_ADD,
60         KEY_OP_ASSIGN,
61 };
62
63 struct sysfs_pair {
64         char file[PATH_SIZE];
65         char value[VALUE_SIZE];
66         enum key_operation operation;
67 };
68
69 struct udev_rule {
70         struct list_head node;
71
72         char kernel[NAME_SIZE];
73         enum key_operation kernel_operation;
74         char subsystem[NAME_SIZE];
75         enum key_operation subsystem_operation;
76         char bus[NAME_SIZE];
77         enum key_operation bus_operation;
78         char id[NAME_SIZE];
79         enum key_operation id_operation;
80         char driver[NAME_SIZE];
81         enum key_operation driver_operation;
82         char program[PATH_SIZE];
83         enum key_operation program_operation;
84         char result[PATH_SIZE];
85         enum key_operation result_operation;
86         struct sysfs_pair sysfs_pair[MAX_SYSFS_PAIRS];
87
88         char name[PATH_SIZE];
89         char symlink[PATH_SIZE];
90         char owner[USER_SIZE];
91         char group[USER_SIZE];
92         mode_t mode;
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 struct list_head udev_rule_list;
104
105 extern int udev_rules_init(void);
106 extern int udev_rules_get_name(struct udevice *udev, struct sysfs_class_device *class_dev);
107 extern void udev_rules_close(void);
108
109 extern void udev_rule_dump(struct udev_rule *rule);
110 extern void udev_rule_list_dump(void);
111
112 #endif