1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _DEVFSADM_H
#define _DEVFSADM_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <libdevinfo.h>
#include <sys/devinfo_impl.h>
#include <regex.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DEVFSADM_SUCCESS 0
#define DEVFSADM_FAILURE -1
#define DEVFSADM_MULTIPLE -2
#define DEVFSADM_TRUE 0
#define DEVFSADM_FALSE -1
#define ILEVEL_0 0
#define ILEVEL_1 1
#define ILEVEL_2 2
#define ILEVEL_3 3
#define ILEVEL_4 4
#define ILEVEL_5 5
#define ILEVEL_6 6
#define ILEVEL_7 7
#define ILEVEL_8 8
#define ILEVEL_9 9
#define DEVFSADM_V0 0
#define DEVFSADM_V1 1
#define DEVFSADM_CONTINUE 0
#define DEVFSADM_TERMINATE 1
#define INTEGER 0
#define CHARACTER 1
#define RM_HOT 0x01
#define RM_PRE 0x02
#define RM_POST 0x04
#define RM_ALWAYS 0x08
#define RM_NOINTERPOSE 0x10
#define TYPE_EXACT 0x01
#define TYPE_RE 0x02
#define TYPE_PARTIAL 0x04
#define TYPE_MASK 0x07
#define DRV_EXACT 0x10
#define DRV_RE 0x20
#define DRV_MASK 0x30
#define CREATE_DEFER 0x100
#define CREATE_MASK 0x100
/* command to start daemon */
#define DEVFSADMD_START_PATH "/usr/lib/devfsadm/devfsadmd"
#define DEVFSADMD_START "devfsadmd"
/* devfsadm event service door */
#define DEVFSADM_SERVICE_DOOR "/etc/sysevent/devfsadm_event_channel"
#define DEVNAME_LOOKUP_DOOR ".devname_lookup_door"
/* /dev device name binding rule locations */
#define DEVNAME_MASTER_MAP "/etc/dev/devname_master"
/* flags for devfsadm_mklink */
#define DEV_SYNC 0x02 /* synchronous mklink */
#define INFO_MID NULL /* always prints */
#define VERBOSE_MID "verbose" /* prints with -v */
#define CHATTY_MID "chatty" /* prints with -V chatty */
typedef struct devfsadm_create {
char *device_class; /* eg "disk", "tape", "display" */
char *node_type; /* eg DDI_NT_TAPE, DDI_NT_BLOCK, etc */
char *drv_name; /* eg sd, ssd */
int flags; /* TYPE_{EXACT,RE,PARTIAL}, DRV_{EXACT,RE} */
int interpose_lvl; /* eg ILEVEL_0.. ILEVEL_10 */
int (*callback_fcn)(di_minor_t minor, di_node_t node);
} devfsadm_create_t;
typedef struct devfsadm_remove {
char *device_class; /* eg "disk", "tape", "display" */
char *dev_dirs_re; /* dev dirs regex selector */
int flags; /* eg POST, PRE, HOT, ALWAYS */
int interpose_lvl; /* eg ILEVEL_0 .. ILEVEL_10 */
void (*callback_fcn)(char *);
} devfsadm_remove_t;
typedef struct devfsadm_remove_V1 {
char *device_class; /* eg "disk", "tape", "display" */
char *dev_dirs_re; /* dev dirs regex selector */
int flags; /* eg POST, PRE, HOT, ALWAYS */
int interpose_lvl; /* eg ILEVEL_0 .. ILEVEL_10 */
int (*callback_fcn)(char *);
} devfsadm_remove_V1_t;
typedef struct _devfsadm_create_reg {
uint_t version;
uint_t count; /* number of node type registration */
/* structures */
devfsadm_create_t *tblp;
} _devfsadm_create_reg_t;
typedef struct _devfsadm_remove_reg {
uint_t version;
uint_t count; /* number of node type registration */
/* structures */
devfsadm_remove_t *tblp;
} _devfsadm_remove_reg_t;
typedef struct _devfsadm_remove_reg_V1 {
uint_t version;
uint_t count; /* number of node type registration */
/* structures */
devfsadm_remove_V1_t *tblp;
} _devfsadm_remove_reg_V1_t;
/*
* "flags" in the devfs_enumerate structure can take the following values.
* These values specify the substring of devfs path to be used for
* enumeration. Components (see MATCH_ADDR/MATCH_MINOR) may be specified
* by using the "match_arg" member in the devfsadm_enumerate structure.
*/
#define MATCH_ALL 0x001 /* Match entire devfs path */
#define MATCH_PARENT 0x002 /* Match upto last '/' in devfs path */
#define MATCH_ADDR 0x004 /* Match upto nth component of last address */
#define MATCH_MINOR 0x008 /* Match upto nth component of minor name */
#define MATCH_CALLBACK 0x010 /* Use callback to derive match string */
/*
* The following flags are private to devfsadm and the disks module.
* NOT to be used by other modules.
*/
#define MATCH_NODE 0x020
#define MATCH_MASK 0x03F
#define MATCH_UNCACHED 0x040 /* retry flags for disks module */
typedef struct devfsadm_enumerate {
char *re;
int subexp;
uint_t flags;
char *match_arg;
char *(*sel_fcn)(const char *path, void *cb_arg);
void *cb_arg;
} devfsadm_enumerate_t;
#define DEVFSADM_CREATE_INIT_V0(tbl) \
_devfsadm_create_reg_t _devfsadm_create_reg = { \
DEVFSADM_V0, \
(sizeof (tbl) / sizeof (devfsadm_create_t)), \
((devfsadm_create_t *)(tbl)) }
#define DEVFSADM_REMOVE_INIT_V0(tbl)\
_devfsadm_remove_reg_t _devfsadm_remove_reg = {\
DEVFSADM_V0, \
(sizeof (tbl) / sizeof (devfsadm_remove_t)), \
((devfsadm_remove_t *)(tbl)) }
#define DEVFSADM_REMOVE_INIT_V1(tbl)\
_devfsadm_remove_reg_V1_t _devfsadm_remove_reg = {\
DEVFSADM_V1, \
(sizeof (tbl) / sizeof (devfsadm_remove_V1_t)), \
((devfsadm_remove_V1_t *)(tbl)) }
int devfsadm_noupdate(void);
const char *devfsadm_root_path(void);
int devfsadm_link_valid(char *link);
int devfsadm_mklink(char *link, di_node_t node, di_minor_t minor, int flags);
int devfsadm_secondary_link(char *link, char *primary_link, int flags);
void devfsadm_rm_link(char *file);
void devfsadm_rm_all(char *file);
void devfsadm_rm_stale_links(char *dir_re, char *valid_link, di_node_t node,
di_minor_t minor);
void devfsadm_errprint(char *message, ...);
void devfsadm_print(char *mid, char *message, ...);
int devfsadm_enumerate_int(char *devfs_path, int index, char **buf,
devfsadm_enumerate_t rules[], int nrules);
int devfsadm_enumerate_char(char *devfs_path, int index, char **buf,
devfsadm_enumerate_t rules[], int nrules);
char **devfsadm_lookup_dev_names(char *phys_path, char *re, int *lenp);
void devfsadm_free_dev_names(char **dev_names, int len);
/*
* Private enumerate interface for disks and sgen modules
*/
int disk_enumerate_int(char *devfs_path, int index, char **buf,
devfsadm_enumerate_t rules[], int nrules);
/*
* Private interfaces for ports module (port_link.c).
*/
int devfsadm_enumerate_char_start(char *devfs_path, int index,
char **buf, devfsadm_enumerate_t rules[], int nrules, char *start);
int devfsadm_read_link(char *link, char **devfs_path);
char *s_strdup(const char *ptr);
#ifdef __cplusplus
}
#endif
#endif /* _DEVFSADM_H */
|