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
|
/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* WARNING:
* The interfaces defined in this header file are for Sun private use only.
* The contents of this file are subject to change without notice in
* future releases.
*/
#ifndef _DEVICE_INFO_H
#define _DEVICE_INFO_H
#ifdef __cplusplus
extern "C" {
#endif
/* error return values */
#define DEVFS_ERR -1 /* operation not successful */
#define DEVFS_INVAL -2 /* invalid argument */
#define DEVFS_NOMEM -3 /* out of memory */
#define DEVFS_PERM -4 /* permission denied - not root */
#define DEVFS_NOTSUP -5 /* operation not supported */
#define DEVFS_LIMIT -6 /* exceeded maximum size of property value */
#define DEVFS_NOTFOUND -7 /* request not found */
/*
* for devfs_set_boot_dev()
* default behavior is to translate the input logical device name
* to most compact prom name(i.e. a prom alias, if one exists)
* as possible. And to prepend the new entry to the existing
* list.
*/
/* perform no translation on the input device path */
#define BOOTDEV_LITERAL 0x1
/* convert the input device path only a prom device path; not an alias */
#define BOOTDEV_PROMDEV 0x2
/* overwrite the existing entry in boot-device - default is to prepend */
#define BOOTDEV_OVERWRITE 0x4
/*
* for devfs_get_prom_names()
* returns a list of prom names for a given logical device name.
* the list is sorted first in order of exact aliases, inexact alias
* matches (where an option override was needed), and finally the
* equivalent prom device path. Each sublist is sorted in collating
* order.
*/
#define BOOTDEV_NO_PROM_PATH 0x1
#define BOOTDEV_NO_INEXACT_ALIAS 0x2
#define BOOTDEV_NO_EXACT_ALIAS 0x4
/* for devfs_get_boot_dev() */
struct boot_dev {
char *bootdev_element; /* an entry from the boot-device variable */
char **bootdev_trans; /* 0 or more logical dev translations */
};
/* for devfs_get_all_prom_names() */
struct devfs_prom_path {
char *obp_path;
char **alias_list;
struct devfs_prom_path *next;
};
/* prototypes */
/* return the driver for a given device path */
extern int devfs_path_to_drv(char *devfs_path, char *drv_buf);
/* convert a logical or physical device name to the equivalent prom path */
extern int devfs_dev_to_prom_name(char *, char *);
/* return the driver name after resolving any aliases */
extern char *devfs_resolve_aliases(char *drv);
/* set the boot-device configuration variable */
extern int devfs_bootdev_set_list(const char *, const uint_t);
/* is the boot-device variable modifiable on this platform? */
extern int devfs_bootdev_modifiable(void);
/*
* retrieve the boot-device config variable and corresponding logical
* device names
*/
extern int devfs_bootdev_get_list(const char *, struct boot_dev ***);
/*
* free a list of bootdev structs
*/
extern void devfs_bootdev_free_list(struct boot_dev **);
/*
* given a logical device name, return a list of equivalent
* prom names (aliases and device paths)
*/
extern int devfs_get_prom_names(const char *, uint_t, char ***);
/*
* like devfs_get_prom_names(), but deals with 1 to many mappings
* introduced by mpxio devices
*/
extern int devfs_get_all_prom_names(const char *, uint_t,
struct devfs_prom_path **);
/*
* free a list of devfs_prom_path structures
*/
extern void devfs_free_all_prom_names(struct devfs_prom_path *);
/*
* Interpret a /dev link to its /devices path (does not require path to
* still exist, as long as the links exist)
*/
extern int devfs_resolve_link(char *, char **);
/*
* map a device name from install OS environment to target OS environment or
* vice-versa.
*/
extern int devfs_target2install(const char *, const char *, char *, size_t);
extern int devfs_install2target(const char *, const char *, char *, size_t);
/*
* Minor perm parsing library support for devfsadm, add_drv etc.
*/
#define MINOR_PERM_FILE "/etc/minor_perm"
#define MAX_MINOR_PERM_LINE 256
#define DEFAULT_DEV_USER "root"
#define DEFAULT_DEV_GROUP "sys"
/*
* Possible errors the callers of devfs_read_minor_perm() need
* to be prepared to deal with via callback.
*/
typedef enum {
MP_FOPEN_ERR,
MP_FCLOSE_ERR,
MP_IGNORING_LINE_ERR,
MP_ALLOC_ERR,
MP_NVLIST_ERR,
MP_CANT_FIND_USER_ERR,
MP_CANT_FIND_GROUP_ERR
} minorperm_err_t;
/*
* Create/free mperm list of minor perm entries
*/
extern struct mperm *devfs_read_minor_perm(void (*)(minorperm_err_t, int));
extern void devfs_free_minor_perm(struct mperm *);
/*
* Load all minor perm entries, and add/remove minor perm entry
*/
extern int devfs_load_minor_perm(struct mperm *,
void (*)(minorperm_err_t, int));
extern int devfs_add_minor_perm(char *, void (*)(minorperm_err_t, int));
extern int devfs_rm_minor_perm(char *, void (*)(minorperm_err_t, int));
/* devfsadm dca_flags values: some are used by libdevinfo devlink_create() */
#define DCA_CREATE_LINK 0x000000001
#define DCA_FREE_LIST 0x000000002
#define DCA_LOAD_DRV 0x000000004
#define DCA_CHECK_TYPE 0x000000010
/* UNUSED was DCA_NOTIFY_RCM 0x000000020 (can be recycled) */
#define DCA_FLUSH_PATHINST 0x000000040
#define DCA_HOT_PLUG 0x000000080
#define DCA_DEVLINK_SYNC 0x000000100
#define DCA_DEVLINK_CACHE 0x000000200
#ifdef __cplusplus
}
#endif
#endif /* _DEVICE_INFO_H */
|