]> git.ipfire.org Git - thirdparty/systemd.git/blame - udev/udev.h
udevadm: rename source files
[thirdparty/systemd.git] / udev / udev.h
CommitLineData
f0083e3d 1/*
f0083e3d 2 * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
27b77df4 3 * Copyright (C) 2003-2006 Kay Sievers <kay.sievers@vrfy.org>
f0083e3d
GKH
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
27b77df4 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
f0083e3d
GKH
17 *
18 */
19
c81b35c0
KS
20#ifndef _UDEV_H_
21#define _UDEV_H_
f0083e3d 22
c1ab0461 23#include <sys/types.h>
c076a2bd 24#include <sys/param.h>
1aa1e248 25
9ed47a9f 26#include "list.h"
1aa1e248 27#include "logging.h"
dbd16d26 28#include "udev_sysdeps.h"
f0083e3d 29
03b24b71 30#define COMMENT_CHARACTER '#'
03b24b71 31#define LINE_SIZE 512
989e0811 32#define PATH_SIZE 512
05610c08 33#define NAME_SIZE 256
03b24b71 34#define VALUE_SIZE 128
e964c2c0 35
c1987051 36#define ALLOWED_CHARS "#+-.:=@_"
2f2c4fa4 37#define ALLOWED_CHARS_FILE ALLOWED_CHARS "/"
c1987051 38#define ALLOWED_CHARS_INPUT ALLOWED_CHARS_FILE " $%?,"
2f2c4fa4 39
03b24b71 40#define DEFAULT_PARTITIONS_COUNT 15
bf50425b 41#define UDEV_EVENT_TIMEOUT 180
6d564166 42
1aa1e248
KS
43#define UDEV_MAX(a,b) ((a) > (b) ? (a) : (b))
44
45/* pipes */
03b24b71
KS
46#define READ_END 0
47#define WRITE_END 1
1aa1e248 48
e8d569b4
KS
49struct udev_rules;
50
1aa1e248 51struct sysfs_device {
03b24b71 52 struct list_head node; /* for device cache */
34f55103 53 struct sysfs_device *parent; /* already cached parent*/
1aa1e248 54 char devpath[PATH_SIZE];
95776dc6
KS
55 char subsystem[NAME_SIZE]; /* $class, $bus, drivers, module */
56 char kernel[NAME_SIZE]; /* device instance name */
1aa1e248 57 char kernel_number[NAME_SIZE];
03b24b71 58 char driver[NAME_SIZE]; /* device driver name */
5ef42682
KS
59};
60
5840bc63 61struct udevice {
1aa1e248 62 /* device event */
03b24b71 63 struct sysfs_device *dev; /* points to dev_local by default */
1aa1e248 64 struct sysfs_device dev_local;
03b24b71 65 struct sysfs_device *dev_parent; /* current parent device used for matching */
821d0ec8 66 char action[NAME_SIZE];
a2f2270e 67 char *devpath_old;
2af003fe 68
1aa1e248 69 /* node */
63f61c5c 70 char name[PATH_SIZE];
e48fc108 71 struct list_head symlink_list;
c974742b 72 int symlink_final;
989e0811 73 char owner[NAME_SIZE];
c974742b 74 int owner_final;
989e0811 75 char group[NAME_SIZE];
c974742b 76 int group_final;
2af003fe 77 mode_t mode;
c974742b 78 int mode_final;
7e720bd4 79 dev_t devt;
1aa1e248
KS
80
81 /* event processing */
821d0ec8 82 struct list_head run_list;
c974742b 83 int run_final;
b8476286 84 struct list_head env_list;
63f61c5c 85 char tmp_node[PATH_SIZE];
50e5de03 86 int partitions;
821d0ec8 87 int ignore_device;
7efa217d 88 int ignore_remove;
63f61c5c 89 char program_result[PATH_SIZE];
2dbb47f8 90 int link_priority;
bf50425b 91 int event_timeout;
7a947ce5 92 int test_run;
5840bc63
GKH
93};
94
1aa1e248
KS
95/* udev_config.c */
96extern char udev_root[PATH_SIZE];
97extern char udev_config_filename[PATH_SIZE];
9dd0c257 98extern char udev_rules_dir[PATH_SIZE];
1aa1e248
KS
99extern int udev_log_priority;
100extern int udev_run;
101extern void udev_config_init(void);
102
103/* udev_device.c */
44aff4cd 104extern struct udevice *udev_device_init(void);
1aa1e248 105extern void udev_device_cleanup(struct udevice *udev);
1aa1e248
KS
106extern dev_t udev_device_get_devt(struct udevice *udev);
107
d46f37fd
KS
108/* udev_device_event.c */
109extern int udev_device_event(struct udev_rules *rules, struct udevice *udev);
110
1aa1e248
KS
111/* udev_sysfs.c */
112extern char sysfs_path[PATH_SIZE];
113extern int sysfs_init(void);
114extern void sysfs_cleanup(void);
254efc14
KS
115extern void sysfs_device_set_values(struct sysfs_device *dev, const char *devpath,
116 const char *subsystem, const char *driver);
1aa1e248
KS
117extern struct sysfs_device *sysfs_device_get(const char *devpath);
118extern struct sysfs_device *sysfs_device_get_parent(struct sysfs_device *dev);
6ecd4d1e 119extern struct sysfs_device *sysfs_device_get_parent_with_subsystem(struct sysfs_device *dev, const char *subsystem);
1aa1e248 120extern char *sysfs_attr_get_value(const char *devpath, const char *attr_name);
82c60ce5 121extern int sysfs_resolve_link(char *path, size_t size);
953249a3 122extern int sysfs_lookup_devpath_by_subsys_id(char *devpath, size_t len, const char *subsystem, const char *id);
1aa1e248 123
a4d5ca64
KS
124/* udev_node.c */
125extern int udev_node_mknod(struct udevice *udev, const char *file, dev_t devt, mode_t mode, uid_t uid, gid_t gid);
24f0605c
KS
126extern void udev_node_update_symlinks(struct udevice *udev, struct udevice *udev_old);
127extern int udev_node_add(struct udevice *udev);
a4d5ca64 128extern int udev_node_remove(struct udevice *udev);
a507a015 129
1aa1e248 130/* udev_db.c */
fc55cf68
KS
131extern int udev_db_add_device(struct udevice *dev);
132extern int udev_db_delete_device(struct udevice *dev);
a2f2270e 133extern int udev_db_rename(const char *devpath_old, const char *devpath);
fc55cf68 134extern int udev_db_get_device(struct udevice *udev, const char *devpath);
31de3a2b 135extern int udev_db_get_devices_by_name(const char *name, struct list_head *name_list);
fc55cf68
KS
136extern int udev_db_get_all_entries(struct list_head *name_list);
137
1aa1e248
KS
138/* udev_utils.c */
139struct name_entry {
140 struct list_head node;
141 char name[PATH_SIZE];
4110664d 142 unsigned int ignore_error:1;
1aa1e248 143};
4110664d 144
1aa1e248 145extern int log_priority(const char *priority);
4110664d
KS
146extern struct name_entry *name_list_add(struct list_head *name_list, const char *name, int sort);
147extern struct name_entry *name_list_key_add(struct list_head *name_list, const char *key, const char *value);
db6e59df 148extern int name_list_key_remove(struct list_head *name_list, const char *key);
1aa1e248
KS
149extern void name_list_cleanup(struct list_head *name_list);
150extern int add_matching_files(struct list_head *name_list, const char *dirname, const char *suffix);
3a020a85
KS
151extern uid_t lookup_user(const char *user);
152extern gid_t lookup_group(const char *group);
1aa1e248
KS
153
154/* udev_utils_string.c */
1aa1e248
KS
155extern int string_is_true(const char *str);
156extern void remove_trailing_chars(char *path, char c);
9c6ad9fb
KS
157extern size_t path_encode(char *s, size_t len);
158extern size_t path_decode(char *s);
1aa1e248 159extern int utf8_encoded_valid_unichar(const char *str);
2f2c4fa4 160extern int replace_chars(char *str, const char *white);
1aa1e248
KS
161
162/* udev_utils_file.c */
163extern int create_path(const char *path);
164extern int delete_path(const char *path);
165extern int file_map(const char *filename, char **buf, size_t *bufsize);
166extern void file_unmap(void *buf, size_t bufsize);
167extern int unlink_secure(const char *filename);
168extern size_t buf_get_line(const char *buf, size_t buflen, size_t cur);
169
225cb03b 170/* udev commands */
59345311
AJ
171extern int udevmonitor(int argc, char *argv[]);
172extern int udevinfo(int argc, char *argv[]);
173extern int udevcontrol(int argc, char *argv[]);
174extern int udevtrigger(int argc, char *argv[]);
175extern int udevsettle(int argc, char *argv[]);
176extern int udevtest(int argc, char *argv[]);
225cb03b 177
f0083e3d 178#endif