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 2003 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _LAYOUT_DLIST_UTIL_H 28 #define _LAYOUT_DLIST_UTIL_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * A collection of utility functions for manipulating and traversing 38 * dlist_t linked lists. 39 */ 40 41 /* 42 * FUNCTION: compare_strings(void *str1, void *str2) 43 * 44 * INPUT: str1 - opaque pointer to a char * 45 * str2 - opaque pointer to a char * 46 * 47 * RETURNS: int - <0 - if str1 < str2 48 * 0 - if str1 == str2 49 * >0 - if str1 > str2 50 * 51 * PURPOSE: dlist_t helper which compares the two input strings. 52 * 53 * Comparison is done with string_compare() 54 */ 55 extern int compare_strings(void *str1, void *str2); 56 57 /* 58 * FUNCTION: compare_device_names( 59 * void *str1, void *str2) 60 * 61 * INPUT: str1 - opaque pointer 62 * str2 - opaque pointer 63 * 64 * RETURNS: int - <0 - if str1 < str2 65 * 0 - if str1 == str2 66 * >0 - if str1 > str2 67 * 68 * PURPOSE: dlist_t helper which compares two device name strings. 69 * 70 * Both names are assumed to be in CTD form. 71 * 72 * Either name may be fully qualified by an absolute 73 * path. If only one name is fully qualified, the 74 * leading path with be stripped off prior to the 75 * comparison. 76 * 77 * Uses string_compare() to compare the names. 78 */ 79 extern int compare_device_names(void *str1, void *str2); 80 81 /* 82 * FUNCTION: compare_devconfig_sizes(void *devconf1, void *devconf2) 83 * 84 * INPUT: devconf1 - opaque pointer 85 * devconf2 - opaque pointer 86 * 87 * RETURNS: int - <0 - if devconf1.size_in_blks < devconf2.size_in_blks 88 * 0 - if devconf1.size_in_blks == devconf2.size_in_blks 89 * >0 - if devconf1.size_in_blks > devconf2.size_in_blks 90 * 91 * PURPOSE: dlist_t helper which compares the sizes of two devconfig_t 92 * structs. 93 * 94 * Both input objects are assumed to be devconfig_t pointers. 95 */ 96 extern int compare_devconfig_sizes(void *devconf1, void *devconf2); 97 98 /* 99 * FUNCTION: compare_slice_sizes(void *desc1, void *desc2) 100 * 101 * INPUT: desc1 - opaque pointer to a dm_descriptor_t slice handle 102 * desc2 - opaque pointer to a dm_descriptor_t slice handle 103 * 104 * RETURNS: int - <0 - if desc1.slicesize < desc2.slicesize 105 * 0 - if desc1.slicesize == desc2.slicesize 106 * >0 - if desc1.slicesize > desc2.slicesize 107 * 108 * PURPOSE: dlist_t helper which compares the sizes of two slices 109 * represented as dm_descriptor_t handles. 110 */ 111 extern int compare_slice_sizes(void *obj1, void *obj2); 112 113 /* 114 * FUNCTION: compare_descriptors( 115 * void *desc1, void *desc2) 116 * 117 * INPUT: desc1 - opaque pointer 118 * desc2 - opaque pointer 119 * 120 * RETURNS: int - <0 - if desc1 < desc2 121 * 0 - if desc1 == desc2 122 * >0 - if desc1 > desc2 123 * 124 * PURPOSE: dlist_t helper which compares two dm_descriptor_t handles. 125 */ 126 extern int compare_descriptors(void *desc1, void *desc2); 127 128 /* 129 * FUNCTION: compare_descriptor_names( 130 * void *desc1, void *desc2) 131 * 132 * INPUT: desc1 - opaque pointer 133 * desc2 - opaque pointer 134 * 135 * RETURNS: int - <0 - if desc1.name < desc2.name 136 * 0 - if desc1.name == desc2.name 137 * >0 - if desc1.name > desc2.name 138 * 139 * PURPOSE: dlist_t helper which compares the names associated 140 * with the input dm_descriptor_t handles. 141 * 142 * Retrieves the names associated with both descriptors 143 * and compares them using string_compare. 144 */ 145 extern int compare_descriptor_names(void *desc1, void *desc2); 146 147 /* 148 * FUNCTION: compare_devconfig_and_descriptor_names(void *devconf, 149 * void *desc) 150 * 151 * INPUT: devconf - opaque pointer to a devconfig_t 152 * desc - opaque pointer to a dm_descriptor_t 153 * 154 * RETURNS: int - <0 - if devconf name is "less than" descr name 155 * 0 - if devconf name is "equal to" descr name 156 * >0 - if devconf name is "greater than" desc name 157 * 158 * PURPOSE: dlist_t helper which compares the name of a devconfig_t 159 * struct to the name for a dm_descriptor_t. 160 * 161 * Note that the order of the arguments is important. 162 * This function is intended to be passed into the various 163 * dlist_* functions which take a comparison function. 164 */ 165 extern int compare_devconfig_and_descriptor_names(void *devconf, void *desc); 166 167 /* 168 * FUNCTION: compare_string_to_devconfig_name(void *str, void *devconf) 169 * INPUT: str - opaque pointer to a char *str 170 * devconf - opaque pointer to a devconfig_t 171 * 172 * RETURNS: int - <0 - if devconf name is "less than" str 173 * 0 - if devconf name is "equal to" str 174 * >0 - if devconf name is "greater than" str 175 * 176 * PURPOSE: dlist_t helper which compares a string to the name of 177 * a devconfig_t struct. 178 */ 179 extern int compare_string_to_devconfig_name(void *str, void *devconf); 180 181 /* 182 * FUNCTION: compare_slices_on_same_hba( 183 * void *slice1, void *slice2) 184 * 185 * INPUT: slice1 - opaque pointer 186 * slice2 - opaque pointer 187 * 188 * RETURNS: int - 0 - if slice1 is on the same hba as slice2 189 * !0 - otherwise 190 * 191 * PURPOSE: dlist_t helper which checks whether slice1 is on the 192 * same hba as slice2 193 */ 194 extern int compare_slices_on_same_hba(void *slice1, void *slice2); 195 196 /* 197 * FUNCTION: free_devconfig_object(void *obj) 198 * 199 * INPUT: obj - an opaque pointer 200 * 201 * RETURNS: void 202 * 203 * PURPOSE: helper which decomposes a devconfig_t struct after a 204 * failed layout attempt. 205 * 206 * reclaims allocated space. 207 * releases reserved volume/HSP names 208 * undoes slicing 209 */ 210 extern void free_devconfig_object(void *obj); 211 212 #ifdef __cplusplus 213 } 214 #endif 215 216 #endif /* _LAYOUT_DLIST_UTIL_H */ 217