1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _LIBDISKMGT_H 28 #define _LIBDISKMGT_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <libnvpair.h> 37 38 /* 39 * Holds all the data regarding the device. 40 * Private to libdiskmgt. Must use dm_xxx functions to set/get data. 41 */ 42 typedef uint64_t dm_descriptor_t; 43 44 typedef enum { 45 DM_WHO_MKFS = 0, 46 DM_WHO_ZPOOL, 47 DM_WHO_FORMAT, 48 DM_WHO_SWAP, 49 DM_WHO_DUMP 50 } dm_who_type_t; 51 52 typedef enum { 53 DM_DRIVE = 0, 54 DM_CONTROLLER, 55 DM_MEDIA, 56 DM_SLICE, 57 DM_PARTITION, 58 DM_PATH, 59 DM_ALIAS, 60 DM_BUS 61 } dm_desc_type_t; 62 63 64 typedef enum { 65 DM_DT_UNKNOWN = 0, 66 DM_DT_FIXED, 67 DM_DT_ZIP, 68 DM_DT_JAZ, 69 DM_DT_FLOPPY, 70 DM_DT_MO_ERASABLE, 71 DM_DT_MO_WRITEONCE, 72 DM_DT_AS_MO, 73 DM_DT_CDROM, 74 DM_DT_CDR, 75 DM_DT_CDRW, 76 DM_DT_DVDROM, 77 DM_DT_DVDR, 78 DM_DT_DVDRAM, 79 DM_DT_DVDRW, 80 DM_DT_DDCDROM, 81 DM_DT_DDCDR, 82 DM_DT_DDCDRW 83 } dm_drive_type_t; 84 85 typedef enum { 86 DM_MT_UNKNOWN = 0, 87 DM_MT_FIXED, 88 DM_MT_FLOPPY, 89 DM_MT_CDROM, 90 DM_MT_ZIP, 91 DM_MT_JAZ, 92 DM_MT_CDR, 93 DM_MT_CDRW, 94 DM_MT_DVDROM, 95 DM_MT_DVDR, 96 DM_MT_DVDRAM, 97 DM_MT_MO_ERASABLE, 98 DM_MT_MO_WRITEONCE, 99 DM_MT_AS_MO 100 } dm_media_type_t; 101 102 #define DM_FILTER_END -1 103 104 /* drive stat name */ 105 typedef enum { 106 DM_DRV_STAT_PERFORMANCE = 0, 107 DM_DRV_STAT_DIAGNOSTIC, 108 DM_DRV_STAT_TEMPERATURE 109 } dm_drive_stat_t; 110 111 /* slice stat name */ 112 typedef enum { 113 DM_SLICE_STAT_USE = 0 114 } dm_slice_stat_t; 115 116 /* attribute definitions */ 117 118 /* drive */ 119 #define DM_DISK_UP 1 120 #define DM_DISK_DOWN 0 121 122 #define DM_CLUSTERED "clustered" 123 #define DM_DRVTYPE "drvtype" 124 #define DM_FAILING "failing" 125 #define DM_LOADED "loaded" /* also in media */ 126 #define DM_NDNRERRS "ndevice_not_ready_errors" 127 #define DM_NBYTESREAD "nbytes_read" 128 #define DM_NBYTESWRITTEN "nbytes_written" 129 #define DM_NHARDERRS "nhard_errors" 130 #define DM_NILLREQERRS "nillegal_req_errors" 131 #define DM_NMEDIAERRS "nmedia_errors" 132 #define DM_NNODEVERRS "nno_dev_errors" 133 #define DM_NREADOPS "nread_ops" 134 #define DM_NRECOVERRS "nrecoverable_errors" 135 #define DM_NSOFTERRS "nsoft_errors" 136 #define DM_NTRANSERRS "ntransport_errors" 137 #define DM_NWRITEOPS "nwrite_ops" 138 #define DM_OPATH "opath" 139 #define DM_PRODUCT_ID "product_id" 140 #define DM_REMOVABLE "removable" /* also in media */ 141 #define DM_RPM "rpm" 142 #define DM_STATUS "status" 143 #define DM_SYNC_SPEED "sync_speed" 144 #define DM_TEMPERATURE "temperature" 145 #define DM_VENDOR_ID "vendor_id" 146 #define DM_WIDE "wide" /* also on controller */ 147 #define DM_WWN "wwn" 148 149 /* bus */ 150 #define DM_BTYPE "btype" 151 #define DM_CLOCK "clock" /* also on controller */ 152 #define DM_PNAME "pname" 153 154 /* controller */ 155 #define DM_FAST "fast" 156 #define DM_FAST20 "fast20" 157 #define DM_FAST40 "fast40" 158 #define DM_FAST80 "fast80" 159 #define DM_MULTIPLEX "multiplex" 160 #define DM_PATH_STATE "path_state" 161 162 #define DM_CTYPE_ATA "ata" 163 #define DM_CTYPE_SCSI "scsi" 164 #define DM_CTYPE_FIBRE "fibre channel" 165 #define DM_CTYPE_USB "usb" 166 #define DM_CTYPE_UNKNOWN "unknown" 167 168 /* media */ 169 #define DM_BLOCKSIZE "blocksize" 170 #define DM_FDISK "fdisk" 171 #define DM_MTYPE "mtype" 172 #define DM_NACTUALCYLINDERS "nactual_cylinders" 173 #define DM_NALTCYLINDERS "nalt_cylinders" 174 #define DM_NCYLINDERS "ncylinders" 175 #define DM_NHEADS "nheads" 176 #define DM_NPHYSCYLINDERS "nphys_cylinders" 177 #define DM_NSECTORS "nsectors" /* also in partition */ 178 #define DM_SIZE "size" /* also in slice */ 179 #define DM_NACCESSIBLE "naccessible" 180 #define DM_LABEL "label" 181 182 /* partition */ 183 #define DM_BCYL "bcyl" 184 #define DM_BHEAD "bhead" 185 #define DM_BOOTID "bootid" 186 #define DM_BSECT "bsect" 187 #define DM_ECYL "ecyl" 188 #define DM_EHEAD "ehead" 189 #define DM_ESECT "esect" 190 #define DM_PTYPE "ptype" 191 #define DM_RELSECT "relsect" 192 193 /* slice */ 194 #define DM_DEVICEID "deviceid" 195 #define DM_DEVT "devt" 196 #define DM_INDEX "index" 197 #define DM_EFI_NAME "name" 198 #define DM_MOUNTPOINT "mountpoint" 199 #define DM_LOCALNAME "localname" 200 #define DM_START "start" 201 #define DM_TAG "tag" 202 #define DM_FLAG "flag" 203 #define DM_EFI "efi" /* also on media */ 204 #define DM_USED_BY "used_by" 205 #define DM_USED_NAME "used_name" 206 #define DM_USE_MOUNT "mount" 207 #define DM_USE_SVM "svm" 208 #define DM_USE_LU "lu" 209 #define DM_USE_DUMP "dump" 210 #define DM_USE_VXVM "vxvm" 211 #define DM_USE_FS "fs" 212 #define DM_USE_VFSTAB "vfstab" 213 #define DM_USE_ZPOOL "zpool" 214 215 /* event */ 216 #define DM_EV_NAME "name" 217 #define DM_EV_DTYPE "edtype" 218 #define DM_EV_TYPE "evtype" 219 #define DM_EV_TADD "add" 220 #define DM_EV_TREMOVE "remove" 221 #define DM_EV_TCHANGE "change" 222 223 /* findisks */ 224 #define DM_CTYPE "ctype" 225 #define DM_LUN "lun" 226 #define DM_TARGET "target" 227 228 void dm_free_descriptors(dm_descriptor_t *desc_list); 229 void dm_free_descriptor(dm_descriptor_t desc); 230 void dm_free_name(char *name); 231 232 dm_descriptor_t *dm_get_descriptors(dm_desc_type_t type, int filter[], 233 int *errp); 234 dm_descriptor_t *dm_get_associated_descriptors(dm_descriptor_t desc, 235 dm_desc_type_t type, int *errp); 236 dm_desc_type_t *dm_get_associated_types(dm_desc_type_t type); 237 dm_descriptor_t dm_get_descriptor_by_name(dm_desc_type_t desc_type, 238 char *name, int *errp); 239 char *dm_get_name(dm_descriptor_t desc, int *errp); 240 dm_desc_type_t dm_get_type(dm_descriptor_t desc); 241 nvlist_t *dm_get_attributes(dm_descriptor_t desc, int *errp); 242 nvlist_t *dm_get_stats(dm_descriptor_t desc, int stat_type, 243 int *errp); 244 void dm_init_event_queue(void(*callback)(nvlist_t *, int), 245 int *errp); 246 nvlist_t *dm_get_event(int *errp); 247 void dm_get_slices(char *drive, dm_descriptor_t **slices, 248 int *errp); 249 void dm_get_slice_stats(char *slice, nvlist_t **dev_stats, 250 int *errp); 251 void dm_get_usage_string(char *who, char *data, char **msg); 252 int dm_inuse(char *dev_name, char **msg, dm_who_type_t who, 253 int *errp); 254 255 #ifdef __cplusplus 256 } 257 #endif 258 259 #endif /* _LIBDISKMGT_H */ 260