4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2016 Nexenta Systems, Inc.
28 #ifndef _DISKS_PRIVATE_H
29 #define _DISKS_PRIVATE_H
35 #include <libdevinfo.h>
39 #define DM_DEBUG "DM_LIBDISKMGT_DEBUG"
42 #define NVATTRS NV_UNIQUE_NAME | NV_UNIQUE_NAME_TYPE
43 #define NVATTRS_STAT 0x0
45 typedef struct slice_info
{
48 struct slice_info
*next
;
51 typedef struct alias_info
{
60 struct alias_info
*next
;
69 struct controller_info
*controller
;
73 typedef struct bus_info
{
79 struct controller_info
**controllers
;
80 struct bus_info
*next
;
83 typedef struct controller_info
{
91 struct controller_info
*next
;
97 char *device_id
; /* string encoded device id */
98 ddi_devid_t devid
; /* decoded device id */
99 char *kernel_name
; /* handles drives w/ no devlinks */
102 controller_t
**controllers
;
115 typedef struct descriptor
{
119 controller_t
*controller
;
124 char *secondary_name
;
125 struct descriptor
*next
;
126 struct descriptor
*prev
;
133 controller_t
*controller_listp
;
135 di_devlink_handle_t handle
;
148 /* private internal functions */
149 descriptor_t
**alias_get_descriptors(int filter
[], int *errp
);
150 descriptor_t
**alias_get_assoc_descriptors(descriptor_t
*desc
,
151 dm_desc_type_t type
, int *errp
);
152 descriptor_t
*alias_get_descriptor_by_name(char *name
, int *errp
);
153 char *alias_get_name(descriptor_t
*desc
);
154 nvlist_t
*alias_get_attributes(descriptor_t
*desc
, int *errp
);
155 nvlist_t
*alias_get_stats(descriptor_t
*desc
, int stat_type
, int *errp
);
156 int alias_make_descriptors();
158 descriptor_t
**bus_get_descriptors(int filter
[], int *errp
);
159 descriptor_t
**bus_get_assoc_descriptors(descriptor_t
*desc
,
160 dm_desc_type_t type
, int *errp
);
161 descriptor_t
*bus_get_descriptor_by_name(char *name
, int *errp
);
162 char *bus_get_name(descriptor_t
*desc
);
163 nvlist_t
*bus_get_attributes(descriptor_t
*desc
, int *errp
);
164 nvlist_t
*bus_get_stats(descriptor_t
*desc
, int stat_type
,
166 int bus_make_descriptors();
168 descriptor_t
**controller_get_descriptors(int filter
[], int *errp
);
169 descriptor_t
**controller_get_assoc_descriptors(descriptor_t
*desc
,
170 dm_desc_type_t type
, int *errp
);
171 descriptor_t
*controller_get_descriptor_by_name(char *name
, int *errp
);
172 char *controller_get_name(descriptor_t
*desc
);
173 nvlist_t
*controller_get_attributes(descriptor_t
*desc
, int *errp
);
174 nvlist_t
*controller_get_stats(descriptor_t
*desc
, int stat_type
,
176 int controller_make_descriptors();
178 descriptor_t
**drive_get_descriptors(int filter
[], int *errp
);
179 descriptor_t
**drive_get_assoc_descriptors(descriptor_t
*desc
,
180 dm_desc_type_t type
, int *errp
);
181 descriptor_t
**drive_get_assocs(descriptor_t
*desc
, int *errp
);
182 descriptor_t
*drive_get_descriptor_by_name(char *name
, int *errp
);
183 char *drive_get_name(descriptor_t
*desc
);
184 nvlist_t
*drive_get_attributes(descriptor_t
*desc
, int *errp
);
185 nvlist_t
*drive_get_stats(descriptor_t
*desc
, int stat_type
, int *errp
);
186 int drive_make_descriptors();
187 int drive_open_disk(disk_t
*diskp
, char *opath
, int len
);
189 descriptor_t
**media_get_descriptors(int filter
[], int *errp
);
190 descriptor_t
**media_get_assoc_descriptors(descriptor_t
*desc
,
191 dm_desc_type_t type
, int *errp
);
192 descriptor_t
**media_get_assocs(descriptor_t
*desc
, int *errp
);
193 descriptor_t
*media_get_descriptor_by_name(char *name
, int *errp
);
194 char *media_get_name(descriptor_t
*desc
);
195 nvlist_t
*media_get_attributes(descriptor_t
*desc
, int *errp
);
196 nvlist_t
*media_get_stats(descriptor_t
*desc
, int stat_type
, int *errp
);
197 int media_make_descriptors();
198 int media_read_info(int fd
, struct dk_minfo
*minfo
);
199 int media_read_name(disk_t
*dp
, char *mname
, int size
);
201 descriptor_t
**path_get_descriptors(int filter
[], int *errp
);
202 descriptor_t
**path_get_assoc_descriptors(descriptor_t
*desc
,
203 dm_desc_type_t type
, int *errp
);
204 descriptor_t
*path_get_descriptor_by_name(char *name
, int *errp
);
205 char *path_get_name(descriptor_t
*desc
);
206 nvlist_t
*path_get_attributes(descriptor_t
*desc
, int *errp
);
207 nvlist_t
*path_get_stats(descriptor_t
*desc
, int stat_type
, int *errp
);
208 int path_make_descriptors();
210 descriptor_t
**slice_get_descriptors(int filter
[], int *errp
);
211 descriptor_t
**slice_get_assoc_descriptors(descriptor_t
*desc
,
212 dm_desc_type_t type
, int *errp
);
213 descriptor_t
**slice_get_assocs(descriptor_t
*desc
, int *errp
);
214 descriptor_t
*slice_get_descriptor_by_name(char *name
, int *errp
);
215 char *slice_get_name(descriptor_t
*desc
);
216 nvlist_t
*slice_get_attributes(descriptor_t
*desc
, int *errp
);
217 nvlist_t
*slice_get_stats(descriptor_t
*desc
, int stat_type
, int *errp
);
218 int slice_make_descriptors();
219 void slice_rdsk2dsk(char *rdsk
, char *dsk
, int size
);
222 void cache_free_alias(alias_t
*aliasp
);
223 void cache_free_bus(bus_t
*bp
);
224 void cache_free_controller(controller_t
*cp
);
225 void cache_free_descriptor(descriptor_t
*desc
);
226 void cache_free_descriptors(descriptor_t
**desc_list
);
227 void cache_free_disk(disk_t
*dp
);
228 void cache_free_path(path_t
*pp
);
229 bus_t
*cache_get_buslist();
230 controller_t
*cache_get_controllerlist();
231 descriptor_t
*cache_get_desc(int type
, void *gp
, char *name
,
232 char *secondary_name
, int *errp
);
233 descriptor_t
**cache_get_descriptors(int type
, int *errp
);
234 disk_t
*cache_get_disklist();
235 int cache_is_valid_desc(descriptor_t
*d
);
236 void cache_load_desc(int type
, void *gp
, char *name
,
237 char *secondary_name
, int *errp
);
240 void cache_update(dm_event_type_t ev_type
, char *devname
);
244 void findevs(struct search_args
*args
);
247 int events_start_event_watcher();
248 void events_new_event(char *name
, int dtype
, char *etype
);
249 void events_new_slice_event(char *dev
, char *type
);
252 void libdiskmgt_add_str(nvlist_t
*attrs
, char *name
, char *val
,
254 descriptor_t
**libdiskmgt_empty_desc_array(int *errp
);
255 void libdiskmgt_init_debug();
256 int libdiskmgt_str_eq(char *nm1
, char *nm2
);
258 /* in-use detectors */
259 int inuse_mnt(char *slice
, nvlist_t
*attrs
, int *errp
);
260 int inuse_lu(char *slice
, nvlist_t
*attrs
, int *errp
);
261 int inuse_active_zpool(char *slice
, nvlist_t
*attrs
, int *errp
);
262 int inuse_exported_zpool(char *slice
, nvlist_t
*attrs
, int *errp
);
263 int inuse_dump(char *slice
, nvlist_t
*attrs
, int *errp
);
264 int inuse_vxvm(char *slice
, nvlist_t
*attrs
, int *errp
);
265 int inuse_fs(char *slice
, nvlist_t
*attrs
, int *errp
);
271 #endif /* _DISKS_PRIVATE_H */