17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 599653d4eSeschrock * Common Development and Distribution License (the "License"). 699653d4eSeschrock * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*e373b6e4SYuri Pankov 227c478bd9Sstevel@tonic-gate /* 232174cb7bSVirginia Wray * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 259bb41d3cSBill Pijewski * Copyright (c) 2012, Joyent, Inc. All rights reserved. 26*e373b6e4SYuri Pankov * Copyright 2016 Nexenta Systems, Inc. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _LIBDISKMGT_H 307c478bd9Sstevel@tonic-gate #define _LIBDISKMGT_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <libnvpair.h> 37181c2f42Smmusante #include <sys/swap.h> 3882d71480Ssjelinek 3982d71480Ssjelinek 403e1bd7a2Ssjelinek /* 419bb41d3cSBill Pijewski * Disk Management Library 429bb41d3cSBill Pijewski * 439bb41d3cSBill Pijewski * This library provides a common way to gather information about a system's 449bb41d3cSBill Pijewski * disks, controllers, and related components. 459bb41d3cSBill Pijewski * 469bb41d3cSBill Pijewski * 479bb41d3cSBill Pijewski * THREADS 489bb41d3cSBill Pijewski * ------- 499bb41d3cSBill Pijewski * 509bb41d3cSBill Pijewski * In general all of the functions are thread safe, however there are some 519bb41d3cSBill Pijewski * specific considerations for getting events. The dm_get_event function may 529bb41d3cSBill Pijewski * block the calling thread if no event is currently available. If another 539bb41d3cSBill Pijewski * thread calls dm_get_event while a thread is already blocked in this function, 549bb41d3cSBill Pijewski * the second thread will also block. When an event arrives and multiple 559bb41d3cSBill Pijewski * threads are waiting for events, it is undefined which thread will be 569bb41d3cSBill Pijewski * unblocked and receive the event. If a callback is used for handling events, 579bb41d3cSBill Pijewski * this is equivalent to the dm_get_event function, so mixing callbacks and 589bb41d3cSBill Pijewski * dm_get_event is also nondeterministic. 599bb41d3cSBill Pijewski * 609bb41d3cSBill Pijewski * 619bb41d3cSBill Pijewski * ERRORS 629bb41d3cSBill Pijewski * ------ 639bb41d3cSBill Pijewski * 649bb41d3cSBill Pijewski * In general all of the functions take an errno pointer. This is an integer 659bb41d3cSBill Pijewski * that will contain 0 if the function succeeded or contains an errno (see 669bb41d3cSBill Pijewski * errno.h) if there was an error. If the function returns some data, that 679bb41d3cSBill Pijewski * return data will generally be null if an error occured (see the API comment 689bb41d3cSBill Pijewski * for the specific function for details). Many of the functions take a 699bb41d3cSBill Pijewski * descriptor and provide more information for that descriptor. These functions 709bb41d3cSBill Pijewski * may return an error if the object was removed between the call which obtained 719bb41d3cSBill Pijewski * the descriptor and the call to get more information about the object (errno 729bb41d3cSBill Pijewski * will be ENODEV). Only a few of the possible errno values will be returned; 739bb41d3cSBill Pijewski * typically: 749bb41d3cSBill Pijewski * EPERM not super-user 759bb41d3cSBill Pijewski * ENOMEM not enough memory 769bb41d3cSBill Pijewski * ENODEV no such device 779bb41d3cSBill Pijewski * EINVAL invalid argument 789bb41d3cSBill Pijewski * ENOENT no event queue has been created 799bb41d3cSBill Pijewski * 809bb41d3cSBill Pijewski * Many of the functions require the application to be running as root in order 819bb41d3cSBill Pijewski * to get complete information. EPERM will be returned if the application is 829bb41d3cSBill Pijewski * not running as root. However, not all of the functions have this requirement 839bb41d3cSBill Pijewski * (i.e. event handling). 849bb41d3cSBill Pijewski * 859bb41d3cSBill Pijewski * It is possible for the system to run out of memory while receiving events. 869bb41d3cSBill Pijewski * Since event receipt is asyncronous from the dm_get_event call there may not 879bb41d3cSBill Pijewski * be a thread waiting when the event occurs and ENOMEM is detected. In this 889bb41d3cSBill Pijewski * case the event will be lost. The first call to dm_get_event following this 899bb41d3cSBill Pijewski * condition will immediately return ENOMEM, even if events are queued. 909bb41d3cSBill Pijewski * Subsequent calls can return events. The dm_get_event call will clear the 919bb41d3cSBill Pijewski * pending ENOMEM condition. There is no way to know how many events were lost 929bb41d3cSBill Pijewski * when this situation occurs. If a thread is waiting when the event arrives 939bb41d3cSBill Pijewski * and the ENOMEM condition occurs, the call will also return with ENOMEM. 949bb41d3cSBill Pijewski * There is no way to determine if the system ran out of memory before the 959bb41d3cSBill Pijewski * dm_get_event call or while the thread was blocked in the dm_get_event call 969bb41d3cSBill Pijewski * since both conditions cause dm_get_event to return ENOMEM. 979bb41d3cSBill Pijewski * 989bb41d3cSBill Pijewski * 999bb41d3cSBill Pijewski * MEMORY MANAGEMENT 1009bb41d3cSBill Pijewski * ----------------- 1019bb41d3cSBill Pijewski * 1029bb41d3cSBill Pijewski * Most of the functions that return data are returning memory that has been 1039bb41d3cSBill Pijewski * allocated and must be freed by the application when no longer needed. The 1049bb41d3cSBill Pijewski * application should call the proper free function to free the memory. Most of 1059bb41d3cSBill Pijewski * the functions return either a nvlist or an array of descriptors. The normal 1069bb41d3cSBill Pijewski * nvlist function (nvlist_free; see libnvpair(3LIB)) can be used to free the 1079bb41d3cSBill Pijewski * simple nvlists. Other functions are provided to free the more complex data 1089bb41d3cSBill Pijewski * structures. 1099bb41d3cSBill Pijewski * 1109bb41d3cSBill Pijewski * The following list shows the functions that return allocated memory and the 1119bb41d3cSBill Pijewski * corresponding function to free the memory: 1129bb41d3cSBill Pijewski * dm_get_descriptors dm_free_descriptors 1139bb41d3cSBill Pijewski * dm_get_associated_descriptors dm_free_descriptors 1149bb41d3cSBill Pijewski * dm_get_descriptor_by_name dm_free_descriptor 1159bb41d3cSBill Pijewski * dm_get_name dm_free_name 1169bb41d3cSBill Pijewski * dm_get_attributes nvlist_free 1179bb41d3cSBill Pijewski * dm_get_stats nvlist_free 1189bb41d3cSBill Pijewski * dm_get_event nvlist_free 1199bb41d3cSBill Pijewski * 1209bb41d3cSBill Pijewski * 1219bb41d3cSBill Pijewski * EVENTS 1229bb41d3cSBill Pijewski * ------ 1239bb41d3cSBill Pijewski * 1249bb41d3cSBill Pijewski * Event information is returned as a nvlist. It may be possible to return more 1259bb41d3cSBill Pijewski * information about events over time, especially information about what has 1269bb41d3cSBill Pijewski * changed. However, that may not always be the case, so by using an nvlist we 1279bb41d3cSBill Pijewski * have a very generic event indication. At a minimum the event will return the 1289bb41d3cSBill Pijewski * name of the device, the type of device (see dm_desc_type_t) and the type of 1299bb41d3cSBill Pijewski * event. The event type is a string which can currently be; add, remove, 1309bb41d3cSBill Pijewski * change. 1319bb41d3cSBill Pijewski * 1329bb41d3cSBill Pijewski * If a drive goes up or down this could be returned as event type "change". 1339bb41d3cSBill Pijewski * The application could get the drive information to see that the "status" 1349bb41d3cSBill Pijewski * attribute has changed value (ideally the event would include an attribute 1359bb41d3cSBill Pijewski * with the name of the changed attribute as the value). Although the API can 1369bb41d3cSBill Pijewski * return events for all drive related changes, events will not necessarily be 1379bb41d3cSBill Pijewski * delivered for all changes unless the system generates those events. 1389bb41d3cSBill Pijewski * 1399bb41d3cSBill Pijewski * 1409bb41d3cSBill Pijewski * Controller/HBAs 1419bb41d3cSBill Pijewski * --------------- 1429bb41d3cSBill Pijewski * 1439bb41d3cSBill Pijewski * In general the API means "the parent node of the drive in the device tree" 1449bb41d3cSBill Pijewski * where the word "controller" is used. This can actually be either the HBA or 1459bb41d3cSBill Pijewski * the drive controller depending on the type of the drive. 1469bb41d3cSBill Pijewski * 1479bb41d3cSBill Pijewski * Drives can be connected to their controller(s) in three different ways: 1489bb41d3cSBill Pijewski * single controller 1499bb41d3cSBill Pijewski * multiple controllers 1509bb41d3cSBill Pijewski * multiple controllers with mpxio 1519bb41d3cSBill Pijewski * These cases will lead to different information being available for the 1529bb41d3cSBill Pijewski * configuration. The two interesting cases are multi-path with and without 1539bb41d3cSBill Pijewski * mpxio. With mpxio the drive will have a unique name and a single controller 1549bb41d3cSBill Pijewski * (scsi_vhci). The physical controllers, the paths to the drive, can be 1559bb41d3cSBill Pijewski * obtained by calling dm_get_associated_descriptors with a drive descriptor and 1569bb41d3cSBill Pijewski * a type of DM_PATH. This will only return these physical paths when MPXIO, or 1579bb41d3cSBill Pijewski * possibly some future similar feature, is controlling the drive. 1589bb41d3cSBill Pijewski * 1599bb41d3cSBill Pijewski * Without mpxio the drive does not have a unique public name (in all cases the 1609bb41d3cSBill Pijewski * alias(es) of the drive can be determined by calling 1619bb41d3cSBill Pijewski * dm_get_associated_descriptors to get the DM_ALIAS descriptors. There will be 1629bb41d3cSBill Pijewski * more than one controller returned from dm_get_associated_descriptors when 1639bb41d3cSBill Pijewski * called with a type of DM_CONTROLLER. The controllers for each of the aliases 1649bb41d3cSBill Pijewski * will be returned in the same order as the aliases descriptors. For example, 1659bb41d3cSBill Pijewski * a drive with two paths has the aliases c5t3d2 and c7t1d0. There will be two 1669bb41d3cSBill Pijewski * controllers returned; the first corresponds to c5 and the second corresponds 1679bb41d3cSBill Pijewski * to c7. 1689bb41d3cSBill Pijewski * 1699bb41d3cSBill Pijewski * In the multi-path, non-mpxio case the drive has more than one alias. 1709bb41d3cSBill Pijewski * Although most of the drive attributes are represented on the drive (see 1719bb41d3cSBill Pijewski * dm_get_attributes) there can be some different attributes for the different 1729bb41d3cSBill Pijewski * aliases for the drive. Use dm_get_associated_descriptors to get the DM_ALIAS 1739bb41d3cSBill Pijewski * descriptors which can then be used to obtain these attributes. Use of this 1749bb41d3cSBill Pijewski * algorithm is not restricted to the multi-path, non-mpxio case. For example, 1759bb41d3cSBill Pijewski * it can be used to get the target/lun for a SCSI drive with a single path. 1769bb41d3cSBill Pijewski */ 1779bb41d3cSBill Pijewski 1789bb41d3cSBill Pijewski /* 1793e1bd7a2Ssjelinek * Holds all the data regarding the device. 1803e1bd7a2Ssjelinek * Private to libdiskmgt. Must use dm_xxx functions to set/get data. 1813e1bd7a2Ssjelinek */ 1827c478bd9Sstevel@tonic-gate typedef uint64_t dm_descriptor_t; 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate typedef enum { 1853e1bd7a2Ssjelinek DM_WHO_MKFS = 0, 1863e1bd7a2Ssjelinek DM_WHO_ZPOOL, 18746a2abf2Seschrock DM_WHO_ZPOOL_FORCE, 1883e1bd7a2Ssjelinek DM_WHO_FORMAT, 1893e1bd7a2Ssjelinek DM_WHO_SWAP, 19046657f8dSmmusante DM_WHO_DUMP, 19146657f8dSmmusante DM_WHO_ZPOOL_SPARE 1923e1bd7a2Ssjelinek } dm_who_type_t; 1933e1bd7a2Ssjelinek 1949bb41d3cSBill Pijewski /* 1959bb41d3cSBill Pijewski * The API uses a "descriptor" to identify the managed objects such as drives, 1969bb41d3cSBill Pijewski * controllers, media, slices, partitions, paths and buses. The descriptors are 1979bb41d3cSBill Pijewski * opaque and are only returned or used as parameters to the other functions in 1989bb41d3cSBill Pijewski * the API. The descriptor definition is a typedef to dm_descriptor_t. 1999bb41d3cSBill Pijewski * 2009bb41d3cSBill Pijewski * Applications call either the dm_get_descriptors or 2019bb41d3cSBill Pijewski * dm_get_associated_descriptors function to obtain a list of descriptors of a 2029bb41d3cSBill Pijewski * specific type. The application specifies the desired type from the following 2039bb41d3cSBill Pijewski * enumeration: 2049bb41d3cSBill Pijewski */ 2053e1bd7a2Ssjelinek typedef enum { 2067c478bd9Sstevel@tonic-gate DM_DRIVE = 0, 2077c478bd9Sstevel@tonic-gate DM_CONTROLLER, 2087c478bd9Sstevel@tonic-gate DM_MEDIA, 2097c478bd9Sstevel@tonic-gate DM_SLICE, 2107c478bd9Sstevel@tonic-gate DM_PARTITION, 2117c478bd9Sstevel@tonic-gate DM_PATH, 2127c478bd9Sstevel@tonic-gate DM_ALIAS, 2137c478bd9Sstevel@tonic-gate DM_BUS 2147c478bd9Sstevel@tonic-gate } dm_desc_type_t; 2157c478bd9Sstevel@tonic-gate 2169bb41d3cSBill Pijewski /* 2179bb41d3cSBill Pijewski * These descriptors are associated with each other in the following way: 2189bb41d3cSBill Pijewski * 2199bb41d3cSBill Pijewski * alias partition 2209bb41d3cSBill Pijewski * _ \ / | 2219bb41d3cSBill Pijewski * / \ \ / | 2229bb41d3cSBill Pijewski * \ / \ / | 2239bb41d3cSBill Pijewski * bus --- controller --- drive --- media | 2249bb41d3cSBill Pijewski * | / \ | 2259bb41d3cSBill Pijewski * | / \ | 2269bb41d3cSBill Pijewski * | / \ | 2279bb41d3cSBill Pijewski * path slice 2289bb41d3cSBill Pijewski * 2299bb41d3cSBill Pijewski * The dm_get_associated_descriptors function can be used get the descriptors 2309bb41d3cSBill Pijewski * associated with a given descriptor. The dm_get_associated_types function can 2319bb41d3cSBill Pijewski * be used to find the types that can be associated with a given type. 2329bb41d3cSBill Pijewski * 2339bb41d3cSBill Pijewski * The attributes and values for these objects are described using a list of 2349bb41d3cSBill Pijewski * name/value pairs (see libnvpair(3LIB) and the specific comments for each 2359bb41d3cSBill Pijewski * function in the API section of this document). 2369bb41d3cSBill Pijewski * 2379bb41d3cSBill Pijewski * Drives and media have a type which are defined as the following enumerations. 2389bb41d3cSBill Pijewski * There could be additional types added to these enumerations as new drive and 2399bb41d3cSBill Pijewski * media types are supported by the system. 2409bb41d3cSBill Pijewski */ 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate typedef enum { 2437c478bd9Sstevel@tonic-gate DM_DT_UNKNOWN = 0, 2447c478bd9Sstevel@tonic-gate DM_DT_FIXED, 2457c478bd9Sstevel@tonic-gate DM_DT_ZIP, 2467c478bd9Sstevel@tonic-gate DM_DT_JAZ, 2477c478bd9Sstevel@tonic-gate DM_DT_FLOPPY, 2487c478bd9Sstevel@tonic-gate DM_DT_MO_ERASABLE, 2497c478bd9Sstevel@tonic-gate DM_DT_MO_WRITEONCE, 2507c478bd9Sstevel@tonic-gate DM_DT_AS_MO, 2517c478bd9Sstevel@tonic-gate DM_DT_CDROM, 2527c478bd9Sstevel@tonic-gate DM_DT_CDR, 2537c478bd9Sstevel@tonic-gate DM_DT_CDRW, 2547c478bd9Sstevel@tonic-gate DM_DT_DVDROM, 2557c478bd9Sstevel@tonic-gate DM_DT_DVDR, 2567c478bd9Sstevel@tonic-gate DM_DT_DVDRAM, 2577c478bd9Sstevel@tonic-gate DM_DT_DVDRW, 2587c478bd9Sstevel@tonic-gate DM_DT_DDCDROM, 2597c478bd9Sstevel@tonic-gate DM_DT_DDCDR, 2607c478bd9Sstevel@tonic-gate DM_DT_DDCDRW 2617c478bd9Sstevel@tonic-gate } dm_drive_type_t; 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate typedef enum { 2647c478bd9Sstevel@tonic-gate DM_MT_UNKNOWN = 0, 2657c478bd9Sstevel@tonic-gate DM_MT_FIXED, 2667c478bd9Sstevel@tonic-gate DM_MT_FLOPPY, 2677c478bd9Sstevel@tonic-gate DM_MT_CDROM, 2687c478bd9Sstevel@tonic-gate DM_MT_ZIP, 2697c478bd9Sstevel@tonic-gate DM_MT_JAZ, 2707c478bd9Sstevel@tonic-gate DM_MT_CDR, 2717c478bd9Sstevel@tonic-gate DM_MT_CDRW, 2727c478bd9Sstevel@tonic-gate DM_MT_DVDROM, 2737c478bd9Sstevel@tonic-gate DM_MT_DVDR, 2747c478bd9Sstevel@tonic-gate DM_MT_DVDRAM, 2757c478bd9Sstevel@tonic-gate DM_MT_MO_ERASABLE, 2767c478bd9Sstevel@tonic-gate DM_MT_MO_WRITEONCE, 2777c478bd9Sstevel@tonic-gate DM_MT_AS_MO 2787c478bd9Sstevel@tonic-gate } dm_media_type_t; 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate #define DM_FILTER_END -1 2817c478bd9Sstevel@tonic-gate 2829bb41d3cSBill Pijewski /* 2839bb41d3cSBill Pijewski * The dm_get_stats function takes a stat_type argument for the specific sample 2849bb41d3cSBill Pijewski * to get for the descriptor. The following enums specify the drive and slice 2859bb41d3cSBill Pijewski * stat types. 2869bb41d3cSBill Pijewski */ 2877c478bd9Sstevel@tonic-gate /* drive stat name */ 2887c478bd9Sstevel@tonic-gate typedef enum { 2897c478bd9Sstevel@tonic-gate DM_DRV_STAT_PERFORMANCE = 0, 2907c478bd9Sstevel@tonic-gate DM_DRV_STAT_DIAGNOSTIC, 2917c478bd9Sstevel@tonic-gate DM_DRV_STAT_TEMPERATURE 2927c478bd9Sstevel@tonic-gate } dm_drive_stat_t; 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate /* slice stat name */ 2957c478bd9Sstevel@tonic-gate typedef enum { 2967c478bd9Sstevel@tonic-gate DM_SLICE_STAT_USE = 0 2977c478bd9Sstevel@tonic-gate } dm_slice_stat_t; 2987c478bd9Sstevel@tonic-gate 2992174cb7bSVirginia Wray /* partition type */ 3002174cb7bSVirginia Wray typedef enum { 3012174cb7bSVirginia Wray DM_PRIMARY = 0, 3022174cb7bSVirginia Wray DM_EXTENDED, 3032174cb7bSVirginia Wray DM_LOGICAL 3042174cb7bSVirginia Wray } dm_partition_type_t; 3052174cb7bSVirginia Wray 3067c478bd9Sstevel@tonic-gate /* attribute definitions */ 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate /* drive */ 3097c478bd9Sstevel@tonic-gate #define DM_DISK_UP 1 3107c478bd9Sstevel@tonic-gate #define DM_DISK_DOWN 0 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate #define DM_CLUSTERED "clustered" 3137c478bd9Sstevel@tonic-gate #define DM_DRVTYPE "drvtype" 3147c478bd9Sstevel@tonic-gate #define DM_FAILING "failing" 3157c478bd9Sstevel@tonic-gate #define DM_LOADED "loaded" /* also in media */ 3167c478bd9Sstevel@tonic-gate #define DM_NDNRERRS "ndevice_not_ready_errors" 3177c478bd9Sstevel@tonic-gate #define DM_NBYTESREAD "nbytes_read" 3187c478bd9Sstevel@tonic-gate #define DM_NBYTESWRITTEN "nbytes_written" 3197c478bd9Sstevel@tonic-gate #define DM_NHARDERRS "nhard_errors" 3207c478bd9Sstevel@tonic-gate #define DM_NILLREQERRS "nillegal_req_errors" 3217c478bd9Sstevel@tonic-gate #define DM_NMEDIAERRS "nmedia_errors" 3227c478bd9Sstevel@tonic-gate #define DM_NNODEVERRS "nno_dev_errors" 3237c478bd9Sstevel@tonic-gate #define DM_NREADOPS "nread_ops" 3247c478bd9Sstevel@tonic-gate #define DM_NRECOVERRS "nrecoverable_errors" 3257c478bd9Sstevel@tonic-gate #define DM_NSOFTERRS "nsoft_errors" 3267c478bd9Sstevel@tonic-gate #define DM_NTRANSERRS "ntransport_errors" 3277c478bd9Sstevel@tonic-gate #define DM_NWRITEOPS "nwrite_ops" 3287c478bd9Sstevel@tonic-gate #define DM_OPATH "opath" 3297c478bd9Sstevel@tonic-gate #define DM_PRODUCT_ID "product_id" 3307c478bd9Sstevel@tonic-gate #define DM_REMOVABLE "removable" /* also in media */ 3317c478bd9Sstevel@tonic-gate #define DM_RPM "rpm" 33259d8f100SGarrett D'Amore #define DM_SOLIDSTATE "solid_state" 3337c478bd9Sstevel@tonic-gate #define DM_STATUS "status" 3347c478bd9Sstevel@tonic-gate #define DM_SYNC_SPEED "sync_speed" 3357c478bd9Sstevel@tonic-gate #define DM_TEMPERATURE "temperature" 3367c478bd9Sstevel@tonic-gate #define DM_VENDOR_ID "vendor_id" 3377c478bd9Sstevel@tonic-gate #define DM_WIDE "wide" /* also on controller */ 3387c478bd9Sstevel@tonic-gate #define DM_WWN "wwn" 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate /* bus */ 3417c478bd9Sstevel@tonic-gate #define DM_BTYPE "btype" 3427c478bd9Sstevel@tonic-gate #define DM_CLOCK "clock" /* also on controller */ 3437c478bd9Sstevel@tonic-gate #define DM_PNAME "pname" 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate /* controller */ 3467c478bd9Sstevel@tonic-gate #define DM_FAST "fast" 3477c478bd9Sstevel@tonic-gate #define DM_FAST20 "fast20" 3487c478bd9Sstevel@tonic-gate #define DM_FAST40 "fast40" 3497c478bd9Sstevel@tonic-gate #define DM_FAST80 "fast80" 3507c478bd9Sstevel@tonic-gate #define DM_MULTIPLEX "multiplex" 3517c478bd9Sstevel@tonic-gate #define DM_PATH_STATE "path_state" 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate #define DM_CTYPE_ATA "ata" 3547c478bd9Sstevel@tonic-gate #define DM_CTYPE_SCSI "scsi" 3557c478bd9Sstevel@tonic-gate #define DM_CTYPE_FIBRE "fibre channel" 3567c478bd9Sstevel@tonic-gate #define DM_CTYPE_USB "usb" 3577c478bd9Sstevel@tonic-gate #define DM_CTYPE_UNKNOWN "unknown" 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate /* media */ 3607c478bd9Sstevel@tonic-gate #define DM_BLOCKSIZE "blocksize" 3617c478bd9Sstevel@tonic-gate #define DM_FDISK "fdisk" 3627c478bd9Sstevel@tonic-gate #define DM_MTYPE "mtype" 3637c478bd9Sstevel@tonic-gate #define DM_NACTUALCYLINDERS "nactual_cylinders" 3647c478bd9Sstevel@tonic-gate #define DM_NALTCYLINDERS "nalt_cylinders" 3657c478bd9Sstevel@tonic-gate #define DM_NCYLINDERS "ncylinders" 3667c478bd9Sstevel@tonic-gate #define DM_NHEADS "nheads" 3677c478bd9Sstevel@tonic-gate #define DM_NPHYSCYLINDERS "nphys_cylinders" 3687c478bd9Sstevel@tonic-gate #define DM_NSECTORS "nsectors" /* also in partition */ 3697c478bd9Sstevel@tonic-gate #define DM_SIZE "size" /* also in slice */ 3707c478bd9Sstevel@tonic-gate #define DM_NACCESSIBLE "naccessible" 3717c478bd9Sstevel@tonic-gate #define DM_LABEL "label" 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate /* partition */ 3747c478bd9Sstevel@tonic-gate #define DM_BCYL "bcyl" 3757c478bd9Sstevel@tonic-gate #define DM_BHEAD "bhead" 3767c478bd9Sstevel@tonic-gate #define DM_BOOTID "bootid" 3777c478bd9Sstevel@tonic-gate #define DM_BSECT "bsect" 3787c478bd9Sstevel@tonic-gate #define DM_ECYL "ecyl" 3797c478bd9Sstevel@tonic-gate #define DM_EHEAD "ehead" 3807c478bd9Sstevel@tonic-gate #define DM_ESECT "esect" 3812174cb7bSVirginia Wray #define DM_PTYPE "ptype" /* this references the partition id */ 3822174cb7bSVirginia Wray #define DM_PARTITION_TYPE "part_type" /* primary, extended, logical */ 3837c478bd9Sstevel@tonic-gate #define DM_RELSECT "relsect" 3847c478bd9Sstevel@tonic-gate 3857c478bd9Sstevel@tonic-gate /* slice */ 3867c478bd9Sstevel@tonic-gate #define DM_DEVICEID "deviceid" 3877c478bd9Sstevel@tonic-gate #define DM_DEVT "devt" 3887c478bd9Sstevel@tonic-gate #define DM_INDEX "index" 3897c478bd9Sstevel@tonic-gate #define DM_EFI_NAME "name" 3907c478bd9Sstevel@tonic-gate #define DM_MOUNTPOINT "mountpoint" 3917c478bd9Sstevel@tonic-gate #define DM_LOCALNAME "localname" 3927c478bd9Sstevel@tonic-gate #define DM_START "start" 3937c478bd9Sstevel@tonic-gate #define DM_TAG "tag" 3947c478bd9Sstevel@tonic-gate #define DM_FLAG "flag" 3957c478bd9Sstevel@tonic-gate #define DM_EFI "efi" /* also on media */ 3967c478bd9Sstevel@tonic-gate #define DM_USED_BY "used_by" 3977c478bd9Sstevel@tonic-gate #define DM_USED_NAME "used_name" 3987c478bd9Sstevel@tonic-gate #define DM_USE_MOUNT "mount" 3997c478bd9Sstevel@tonic-gate #define DM_USE_LU "lu" 4007c478bd9Sstevel@tonic-gate #define DM_USE_DUMP "dump" 4017c478bd9Sstevel@tonic-gate #define DM_USE_VXVM "vxvm" 4027c478bd9Sstevel@tonic-gate #define DM_USE_FS "fs" 4037c478bd9Sstevel@tonic-gate #define DM_USE_VFSTAB "vfstab" 40446a2abf2Seschrock #define DM_USE_EXPORTED_ZPOOL "exported_zpool" 40546a2abf2Seschrock #define DM_USE_ACTIVE_ZPOOL "active_zpool" 40699653d4eSeschrock #define DM_USE_SPARE_ZPOOL "spare_zpool" 407fa94a07fSbrendan #define DM_USE_L2CACHE_ZPOOL "l2cache_zpool" 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate /* event */ 4107c478bd9Sstevel@tonic-gate #define DM_EV_NAME "name" 4117c478bd9Sstevel@tonic-gate #define DM_EV_DTYPE "edtype" 4127c478bd9Sstevel@tonic-gate #define DM_EV_TYPE "evtype" 4137c478bd9Sstevel@tonic-gate #define DM_EV_TADD "add" 4147c478bd9Sstevel@tonic-gate #define DM_EV_TREMOVE "remove" 4157c478bd9Sstevel@tonic-gate #define DM_EV_TCHANGE "change" 4167c478bd9Sstevel@tonic-gate 4177c478bd9Sstevel@tonic-gate /* findisks */ 4187c478bd9Sstevel@tonic-gate #define DM_CTYPE "ctype" 4197c478bd9Sstevel@tonic-gate #define DM_LUN "lun" 4207c478bd9Sstevel@tonic-gate #define DM_TARGET "target" 4217c478bd9Sstevel@tonic-gate 42282d71480Ssjelinek #define NOINUSE_SET getenv("NOINUSE_CHECK") != NULL 42382d71480Ssjelinek 4247c478bd9Sstevel@tonic-gate void dm_free_descriptors(dm_descriptor_t *desc_list); 4257c478bd9Sstevel@tonic-gate void dm_free_descriptor(dm_descriptor_t desc); 4267c478bd9Sstevel@tonic-gate void dm_free_name(char *name); 427181c2f42Smmusante void dm_free_swapentries(swaptbl_t *); 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate dm_descriptor_t *dm_get_descriptors(dm_desc_type_t type, int filter[], 4307c478bd9Sstevel@tonic-gate int *errp); 4317c478bd9Sstevel@tonic-gate dm_descriptor_t *dm_get_associated_descriptors(dm_descriptor_t desc, 4327c478bd9Sstevel@tonic-gate dm_desc_type_t type, int *errp); 4337c478bd9Sstevel@tonic-gate dm_desc_type_t *dm_get_associated_types(dm_desc_type_t type); 4347c478bd9Sstevel@tonic-gate dm_descriptor_t dm_get_descriptor_by_name(dm_desc_type_t desc_type, 4357c478bd9Sstevel@tonic-gate char *name, int *errp); 4367c478bd9Sstevel@tonic-gate char *dm_get_name(dm_descriptor_t desc, int *errp); 4377c478bd9Sstevel@tonic-gate dm_desc_type_t dm_get_type(dm_descriptor_t desc); 4387c478bd9Sstevel@tonic-gate nvlist_t *dm_get_attributes(dm_descriptor_t desc, int *errp); 4397c478bd9Sstevel@tonic-gate nvlist_t *dm_get_stats(dm_descriptor_t desc, int stat_type, 4407c478bd9Sstevel@tonic-gate int *errp); 4417c478bd9Sstevel@tonic-gate void dm_init_event_queue(void(*callback)(nvlist_t *, int), 4427c478bd9Sstevel@tonic-gate int *errp); 4437c478bd9Sstevel@tonic-gate nvlist_t *dm_get_event(int *errp); 4443e1bd7a2Ssjelinek void dm_get_slices(char *drive, dm_descriptor_t **slices, 4453e1bd7a2Ssjelinek int *errp); 4463e1bd7a2Ssjelinek void dm_get_slice_stats(char *slice, nvlist_t **dev_stats, 4473e1bd7a2Ssjelinek int *errp); 448181c2f42Smmusante int dm_get_swapentries(swaptbl_t **, int *); 4493e1bd7a2Ssjelinek void dm_get_usage_string(char *who, char *data, char **msg); 4503e1bd7a2Ssjelinek int dm_inuse(char *dev_name, char **msg, dm_who_type_t who, 4513e1bd7a2Ssjelinek int *errp); 452181c2f42Smmusante int dm_inuse_swap(const char *dev_name, int *errp); 45346a2abf2Seschrock int dm_isoverlapping(char *dev_name, char **msg, int *errp); 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4567c478bd9Sstevel@tonic-gate } 4577c478bd9Sstevel@tonic-gate #endif 4587c478bd9Sstevel@tonic-gate 4597c478bd9Sstevel@tonic-gate #endif /* _LIBDISKMGT_H */ 460