1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1993, by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #ifndef _VOLMGT_H 27*7c478bd9Sstevel@tonic-gate #define _VOLMGT_H 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 32*7c478bd9Sstevel@tonic-gate extern "C" { 33*7c478bd9Sstevel@tonic-gate #endif 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate /* 38*7c478bd9Sstevel@tonic-gate * volmgt_check: 39*7c478bd9Sstevel@tonic-gate * have volume management look at its devices to check 40*7c478bd9Sstevel@tonic-gate * for media having arrived. Since volume management can't 41*7c478bd9Sstevel@tonic-gate * automatically check all types of devices, this function is provided 42*7c478bd9Sstevel@tonic-gate * to allow applications to cause the check to happen automatically. 43*7c478bd9Sstevel@tonic-gate * 44*7c478bd9Sstevel@tonic-gate * arguments: 45*7c478bd9Sstevel@tonic-gate * path - the name of the device in /dev. For example, 46*7c478bd9Sstevel@tonic-gate * /dev/rdiskette. If path is NULL, all "checkable" devices are 47*7c478bd9Sstevel@tonic-gate * checked. 48*7c478bd9Sstevel@tonic-gate * 49*7c478bd9Sstevel@tonic-gate * return value(s): 50*7c478bd9Sstevel@tonic-gate * TRUE if media was found in the device, FALSE if not. 51*7c478bd9Sstevel@tonic-gate */ 52*7c478bd9Sstevel@tonic-gate int volmgt_check(char *path); 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * volmgt_inuse: 56*7c478bd9Sstevel@tonic-gate * check to see if volume management is currently 57*7c478bd9Sstevel@tonic-gate * managing a particular device. 58*7c478bd9Sstevel@tonic-gate * 59*7c478bd9Sstevel@tonic-gate * arguments: 60*7c478bd9Sstevel@tonic-gate * path - the name of the device in /dev. For example, 61*7c478bd9Sstevel@tonic-gate * "/dev/rdiskette". 62*7c478bd9Sstevel@tonic-gate * 63*7c478bd9Sstevel@tonic-gate * return value(s): 64*7c478bd9Sstevel@tonic-gate * TRUE if volume management is managing the device, FALSE if not. 65*7c478bd9Sstevel@tonic-gate */ 66*7c478bd9Sstevel@tonic-gate int volmgt_inuse(char *path); 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * volmgt_running: 70*7c478bd9Sstevel@tonic-gate * check to see if volume management is running. 71*7c478bd9Sstevel@tonic-gate * 72*7c478bd9Sstevel@tonic-gate * arguments: 73*7c478bd9Sstevel@tonic-gate * none. 74*7c478bd9Sstevel@tonic-gate * 75*7c478bd9Sstevel@tonic-gate * return value(s): 76*7c478bd9Sstevel@tonic-gate * TRUE if volume management is running, FALSE if not. 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate int volmgt_running(void); 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate /* 81*7c478bd9Sstevel@tonic-gate * volmgt_symname: 82*7c478bd9Sstevel@tonic-gate * Returns the volume management symbolic name 83*7c478bd9Sstevel@tonic-gate * for a given device. If an application wants to determine 84*7c478bd9Sstevel@tonic-gate * what the symbolic name (e.g. "floppy0") for the /dev/rdiskette 85*7c478bd9Sstevel@tonic-gate * device would be, this is the function to use. 86*7c478bd9Sstevel@tonic-gate * 87*7c478bd9Sstevel@tonic-gate * arguments: 88*7c478bd9Sstevel@tonic-gate * path - a string containing the /dev device name. For example, 89*7c478bd9Sstevel@tonic-gate * "/dev/diskette" or "/dev/rdiskette". 90*7c478bd9Sstevel@tonic-gate * 91*7c478bd9Sstevel@tonic-gate * return value(s): 92*7c478bd9Sstevel@tonic-gate * pointer to a string containing the symbolic name. 93*7c478bd9Sstevel@tonic-gate * 94*7c478bd9Sstevel@tonic-gate * NULL indicates that volume management isn't managing that device. 95*7c478bd9Sstevel@tonic-gate * 96*7c478bd9Sstevel@tonic-gate * The string must be free(3)'d. 97*7c478bd9Sstevel@tonic-gate */ 98*7c478bd9Sstevel@tonic-gate char *volmgt_symname(char *path); 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate /* 101*7c478bd9Sstevel@tonic-gate * volmgt_symdev: 102*7c478bd9Sstevel@tonic-gate * Returns the device given the volume management 103*7c478bd9Sstevel@tonic-gate * symbolic name. If an application wants to determine 104*7c478bd9Sstevel@tonic-gate * what the device associated with a particular symbolic name 105*7c478bd9Sstevel@tonic-gate * might be, this is the function to use. 106*7c478bd9Sstevel@tonic-gate * 107*7c478bd9Sstevel@tonic-gate * arguments: 108*7c478bd9Sstevel@tonic-gate * path - a string containing the symbolic device name. For example, 109*7c478bd9Sstevel@tonic-gate * "cdrom0" or "floppy0". 110*7c478bd9Sstevel@tonic-gate * 111*7c478bd9Sstevel@tonic-gate * return value(s): 112*7c478bd9Sstevel@tonic-gate * pointer to a string containing the /dev name. 113*7c478bd9Sstevel@tonic-gate * 114*7c478bd9Sstevel@tonic-gate * NULL indicates that volume management isn't managing that device. 115*7c478bd9Sstevel@tonic-gate * 116*7c478bd9Sstevel@tonic-gate * The string must be free(3)'d. 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate char *volmgt_symdev(char *symname); 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* 121*7c478bd9Sstevel@tonic-gate * volmgt_ownspath: 122*7c478bd9Sstevel@tonic-gate * check to see if the given path is contained in 123*7c478bd9Sstevel@tonic-gate * the volume management name space. 124*7c478bd9Sstevel@tonic-gate * 125*7c478bd9Sstevel@tonic-gate * arguments: 126*7c478bd9Sstevel@tonic-gate * path - string containing the path. 127*7c478bd9Sstevel@tonic-gate * 128*7c478bd9Sstevel@tonic-gate * return value(s): 129*7c478bd9Sstevel@tonic-gate * TRUE if the path is owned by volume management, FALSE if not. 130*7c478bd9Sstevel@tonic-gate * Will return FALSE if volume management isn't running. 131*7c478bd9Sstevel@tonic-gate * 132*7c478bd9Sstevel@tonic-gate */ 133*7c478bd9Sstevel@tonic-gate int volmgt_ownspath(char *path); 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate /* 136*7c478bd9Sstevel@tonic-gate * volmgt_root: 137*7c478bd9Sstevel@tonic-gate * return the root of where the volume management 138*7c478bd9Sstevel@tonic-gate * name space is mounted. 139*7c478bd9Sstevel@tonic-gate * 140*7c478bd9Sstevel@tonic-gate * arguments: 141*7c478bd9Sstevel@tonic-gate * none. 142*7c478bd9Sstevel@tonic-gate * 143*7c478bd9Sstevel@tonic-gate * return value(s): 144*7c478bd9Sstevel@tonic-gate * Returns a pointer to a string containing the path to the 145*7c478bd9Sstevel@tonic-gate * volume management root (e.g. "/vol"). 146*7c478bd9Sstevel@tonic-gate * Will return NULL if volume management isn't running. 147*7c478bd9Sstevel@tonic-gate */ 148*7c478bd9Sstevel@tonic-gate const char *volmgt_root(void); 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate /* 151*7c478bd9Sstevel@tonic-gate * media_findname: 152*7c478bd9Sstevel@tonic-gate * try to come up with the character device when 153*7c478bd9Sstevel@tonic-gate * provided with a starting point. This interface provides the 154*7c478bd9Sstevel@tonic-gate * application programmer to provide "user friendly" names and 155*7c478bd9Sstevel@tonic-gate * easily determine the "/vol" name. 156*7c478bd9Sstevel@tonic-gate * 157*7c478bd9Sstevel@tonic-gate * arguments: 158*7c478bd9Sstevel@tonic-gate * start - a string describing a device. This string can be: 159*7c478bd9Sstevel@tonic-gate * - a full path name to a device (insures it's a 160*7c478bd9Sstevel@tonic-gate * character device by using getfullrawname()). 161*7c478bd9Sstevel@tonic-gate * - a full path name to a volume management media name 162*7c478bd9Sstevel@tonic-gate * with partitions (will return the lowest numbered 163*7c478bd9Sstevel@tonic-gate * raw partition. 164*7c478bd9Sstevel@tonic-gate * - the name of a piece of media (e.g. "fred"). 165*7c478bd9Sstevel@tonic-gate * - a symbolic device name (e.g. floppy0, cdrom0, etc) 166*7c478bd9Sstevel@tonic-gate * - a name like "floppy" or "cdrom". Will pick the lowest 167*7c478bd9Sstevel@tonic-gate * numbered device with media in it. 168*7c478bd9Sstevel@tonic-gate * 169*7c478bd9Sstevel@tonic-gate * return value(s): 170*7c478bd9Sstevel@tonic-gate * A pointer to a string that contains the character device 171*7c478bd9Sstevel@tonic-gate * most appropriate to the "start" argument. 172*7c478bd9Sstevel@tonic-gate * 173*7c478bd9Sstevel@tonic-gate * NULL indicates that we were unable to find media based on "start". 174*7c478bd9Sstevel@tonic-gate * 175*7c478bd9Sstevel@tonic-gate * The string must be free(3)'d. 176*7c478bd9Sstevel@tonic-gate */ 177*7c478bd9Sstevel@tonic-gate char *media_findname(char *start); 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate /* 180*7c478bd9Sstevel@tonic-gate * media_getattr: 181*7c478bd9Sstevel@tonic-gate * returns the value for an attribute for a piece of 182*7c478bd9Sstevel@tonic-gate * removable media. 183*7c478bd9Sstevel@tonic-gate * 184*7c478bd9Sstevel@tonic-gate * arguments: 185*7c478bd9Sstevel@tonic-gate * path - Path to the media in /vol. Can be the block or character 186*7c478bd9Sstevel@tonic-gate * device. 187*7c478bd9Sstevel@tonic-gate * 188*7c478bd9Sstevel@tonic-gate * attr - name of the attribute. 189*7c478bd9Sstevel@tonic-gate * 190*7c478bd9Sstevel@tonic-gate * return value(s): 191*7c478bd9Sstevel@tonic-gate * returns NULL or a pointer to a string that contains the value for 192*7c478bd9Sstevel@tonic-gate * the requested attribute. 193*7c478bd9Sstevel@tonic-gate * 194*7c478bd9Sstevel@tonic-gate * NULL can mean: 195*7c478bd9Sstevel@tonic-gate * - the media doesn't exist 196*7c478bd9Sstevel@tonic-gate * - there is no more space for malloc(3) 197*7c478bd9Sstevel@tonic-gate * - the attribute doesn't exist for the named media 198*7c478bd9Sstevel@tonic-gate * - the attribute is a boolean and is FALSE 199*7c478bd9Sstevel@tonic-gate * 200*7c478bd9Sstevel@tonic-gate * the pointer to the string must be free'd with free(3). 201*7c478bd9Sstevel@tonic-gate */ 202*7c478bd9Sstevel@tonic-gate char *media_getattr(char *path, char *attr); 203*7c478bd9Sstevel@tonic-gate 204*7c478bd9Sstevel@tonic-gate /* 205*7c478bd9Sstevel@tonic-gate * media_setattr: 206*7c478bd9Sstevel@tonic-gate * set an attribute for a piece of media to a 207*7c478bd9Sstevel@tonic-gate * particular value. 208*7c478bd9Sstevel@tonic-gate * 209*7c478bd9Sstevel@tonic-gate * arguments: 210*7c478bd9Sstevel@tonic-gate * path - Path to the media in /vol. Can be the block or character 211*7c478bd9Sstevel@tonic-gate * device. 212*7c478bd9Sstevel@tonic-gate * 213*7c478bd9Sstevel@tonic-gate * attr - name of the attribute. 214*7c478bd9Sstevel@tonic-gate * 215*7c478bd9Sstevel@tonic-gate * value - value of the attribute. If value == "", the flag is 216*7c478bd9Sstevel@tonic-gate * considered to be a boolean that is TRUE. If value == 0, it 217*7c478bd9Sstevel@tonic-gate * is considered to be a FALSE boolean. 218*7c478bd9Sstevel@tonic-gate * 219*7c478bd9Sstevel@tonic-gate * return value(s): 220*7c478bd9Sstevel@tonic-gate * TRUE on success, FALSE for failure. 221*7c478bd9Sstevel@tonic-gate * 222*7c478bd9Sstevel@tonic-gate * Can fail because: 223*7c478bd9Sstevel@tonic-gate * - don't have permission to set the attribute because caller 224*7c478bd9Sstevel@tonic-gate * is not the owner of the media and attribute is a "system" 225*7c478bd9Sstevel@tonic-gate * attribute. 226*7c478bd9Sstevel@tonic-gate * 227*7c478bd9Sstevel@tonic-gate * - don't have permission to set the attribute because the 228*7c478bd9Sstevel@tonic-gate * attribute is a "system" attribute and is read-only. 229*7c478bd9Sstevel@tonic-gate */ 230*7c478bd9Sstevel@tonic-gate int media_setattr(char *path, char *attr, char *value); 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate /* 233*7c478bd9Sstevel@tonic-gate * media_getid: 234*7c478bd9Sstevel@tonic-gate * return the "id" of a piece of media. 235*7c478bd9Sstevel@tonic-gate * 236*7c478bd9Sstevel@tonic-gate * arguments: 237*7c478bd9Sstevel@tonic-gate * path - Path to the media in /vol. Can be the block or character 238*7c478bd9Sstevel@tonic-gate * device. 239*7c478bd9Sstevel@tonic-gate * return value(s): 240*7c478bd9Sstevel@tonic-gate * returns a u_longlong_t that is the "id" of the volume. 241*7c478bd9Sstevel@tonic-gate * 242*7c478bd9Sstevel@tonic-gate */ 243*7c478bd9Sstevel@tonic-gate u_longlong_t media_getid(char *path); 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate /* 246*7c478bd9Sstevel@tonic-gate * volmgt_feature_enabled: 247*7c478bd9Sstevel@tonic-gate * check to see if a volume management feature is available 248*7c478bd9Sstevel@tonic-gate * 249*7c478bd9Sstevel@tonic-gate * arguments: 250*7c478bd9Sstevel@tonic-gate * feat_str - a string containing the feature to be checked for 251*7c478bd9Sstevel@tonic-gate * 252*7c478bd9Sstevel@tonic-gate * return value(s): 253*7c478bd9Sstevel@tonic-gate * returns non-zero if the specified feature is available 254*7c478bd9Sstevel@tonic-gate * in volume management, else return zero 255*7c478bd9Sstevel@tonic-gate */ 256*7c478bd9Sstevel@tonic-gate int volmgt_feature_enabled(char *feat_str); 257*7c478bd9Sstevel@tonic-gate 258*7c478bd9Sstevel@tonic-gate /* 259*7c478bd9Sstevel@tonic-gate * volmgt_acquire 260*7c478bd9Sstevel@tonic-gate * try to acquire the volmgt advisory device reservation 261*7c478bd9Sstevel@tonic-gate * for a specific device. -- if volmgt isn't running then try to 262*7c478bd9Sstevel@tonic-gate * reserve the device specified 263*7c478bd9Sstevel@tonic-gate * 264*7c478bd9Sstevel@tonic-gate * arguments: 265*7c478bd9Sstevel@tonic-gate * dev - a device name to attempt reserving. This string can be: 266*7c478bd9Sstevel@tonic-gate * - a full path name to a device in /vol if volmgt is running 267*7c478bd9Sstevel@tonic-gate * - a symbolic device name (e.g. floppy0) if volmgt is running 268*7c478bd9Sstevel@tonic-gate * - a /dev pathname if volmgt is not running 269*7c478bd9Sstevel@tonic-gate * 270*7c478bd9Sstevel@tonic-gate * id - a reservation string that hopefully describes the application 271*7c478bd9Sstevel@tonic-gate * making this reservation. 272*7c478bd9Sstevel@tonic-gate * 273*7c478bd9Sstevel@tonic-gate * ovr - an override indicator. If set to non-zero, the caller requests 274*7c478bd9Sstevel@tonic-gate * that this reservation be made unconditionally. 275*7c478bd9Sstevel@tonic-gate * 276*7c478bd9Sstevel@tonic-gate * err - the address of a char ptr that will updated to point to the 277*7c478bd9Sstevel@tonic-gate * id argument used when the current device was reserved. This 278*7c478bd9Sstevel@tonic-gate * is only used when the current reservation attempt fails due 279*7c478bd9Sstevel@tonic-gate * to an already existing reservation for this device. 280*7c478bd9Sstevel@tonic-gate * 281*7c478bd9Sstevel@tonic-gate * pidp - a pointer to a pid_t type. If this argument is not NULL 282*7c478bd9Sstevel@tonic-gate * and the requested device is already reserved, the process 283*7c478bd9Sstevel@tonic-gate * id of the reservation owner will be returned in this 284*7c478bd9Sstevel@tonic-gate * location. 285*7c478bd9Sstevel@tonic-gate * 286*7c478bd9Sstevel@tonic-gate * 287*7c478bd9Sstevel@tonic-gate * return value(s): 288*7c478bd9Sstevel@tonic-gate * A non-zero indicator if successful. 289*7c478bd9Sstevel@tonic-gate * 290*7c478bd9Sstevel@tonic-gate * A zero indicator if unsuccessful. If errno is EBUSY, then the err 291*7c478bd9Sstevel@tonic-gate * argument will be set to point to the string that the process currently 292*7c478bd9Sstevel@tonic-gate * holding the reservation supplied when reserving the device. It is up 293*7c478bd9Sstevel@tonic-gate * to the caller to release the storage occupied by the string via 294*7c478bd9Sstevel@tonic-gate * free(3C) when no longer needed. 295*7c478bd9Sstevel@tonic-gate */ 296*7c478bd9Sstevel@tonic-gate int volmgt_acquire(char *dev, char *id, int ovr, char **err, pid_t *pidp); 297*7c478bd9Sstevel@tonic-gate 298*7c478bd9Sstevel@tonic-gate /* 299*7c478bd9Sstevel@tonic-gate * the max length for the "id" string in volmgt_acquire 300*7c478bd9Sstevel@tonic-gate */ 301*7c478bd9Sstevel@tonic-gate #define VOL_RSV_MAXIDLEN 256 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate /* 304*7c478bd9Sstevel@tonic-gate * volmgt_release: 305*7c478bd9Sstevel@tonic-gate * try to release the volmgt advisory device reservation 306*7c478bd9Sstevel@tonic-gate * for a specific device. 307*7c478bd9Sstevel@tonic-gate * 308*7c478bd9Sstevel@tonic-gate * arguments: 309*7c478bd9Sstevel@tonic-gate * dev - a device name to attempt reserving. This string can be: 310*7c478bd9Sstevel@tonic-gate * - a full path name to a device in /vol if volmgt is running 311*7c478bd9Sstevel@tonic-gate * - a symbolic device name (e.g. floppy0) if volmgt is running 312*7c478bd9Sstevel@tonic-gate * - a /dev pathname if volmgt is not running 313*7c478bd9Sstevel@tonic-gate * 314*7c478bd9Sstevel@tonic-gate * return value(s): 315*7c478bd9Sstevel@tonic-gate * A non-zero indicator if successful 316*7c478bd9Sstevel@tonic-gate * A zero indicator if unsuccessful 317*7c478bd9Sstevel@tonic-gate * 318*7c478bd9Sstevel@tonic-gate * preconditions: 319*7c478bd9Sstevel@tonic-gate * none 320*7c478bd9Sstevel@tonic-gate */ 321*7c478bd9Sstevel@tonic-gate int volmgt_release(char *dev); 322*7c478bd9Sstevel@tonic-gate 323*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 324*7c478bd9Sstevel@tonic-gate } 325*7c478bd9Sstevel@tonic-gate #endif 326*7c478bd9Sstevel@tonic-gate 327*7c478bd9Sstevel@tonic-gate #endif /* _VOLMGT_H */ 328