volmgt.c revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_running: check to see if volume management is running. 2N/A * TRUE if volume management is running, FALSE if not. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_inuse: check to see if volume management is currently 2N/A * managing a particular device. 2N/A * path - the name of the device in /dev. For example, 2N/A * TRUE if volume management is managing the device, FALSE if not. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_check: have volume management look at its devices to check 2N/A * for media having arrived. Since volume management can't 2N/A * automatically check all types of devices, this function is provided 2N/A * to allow applications to cause the check to happen automatically. 2N/A * path - the name of the device in /dev. For example, 2N/A * TRUE if media was found in the device, FALSE if not. 2N/A * volume management must be running. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_ownspath: check to see if the given path is contained in 2N/A * the volume management name space. 2N/A * path - string containing the path. 2N/A * TRUE if the path is owned by volume management, FALSE if not. 2N/A * Will return FALSE if volume management isn't running. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_root: return the root of where the volume management 2N/A * name space is mounted. 2N/A * Returns a pointer to a static string containing the path to the 2N/A * volume management root (e.g. "/vol"). 2N/A * Will return NULL if volume management isn't running. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_symname: Returns the volume management symbolic name 2N/A * for a given device. If an application wants to determine 2N/A * device would be, this is the function to use. 2N/A * path - a string containing the /dev device name. For example, 2N/A * Note: must be a block- or char-spcl device, and have a non-zero 2N/A * st_rdev (real device) stat() value. 2N/A * pointer to a string containing the symbolic name. 2N/A * NULL indicates that volume management isn't managing that device. 2N/A * The string must be free(3)'d. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_symdev: Returns the device given the volume management 2N/A * symbolic name. If an application wants to determine 2N/A * what the device associated with a particular symbolic name 2N/A * might be, this is the function to use. 2N/A * path - a string containing the symbolic device name. For example, 2N/A * "cdrom0" or "floppy0". 2N/A * pointer to a string containing the /dev name. 2N/A * NULL indicates that volume management isn't managing that device. 2N/A * The string must be free(3)'d. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_feat_enabled: check to see if a volume management feature 2N/A * feat_str - a string containing the feature to be checked for 2N/A * return non-zero if the specified feature is available in 2N/A * volume management, else return zero 2N/A * the following is a lit of the "feature" available in volmgt 2N/A * this list is meant to be updated when new features (that users may 2N/A * want to use) are added to volmgt 2N/A * note: feature strings added should be all lower case, and spaces are 2N/A * (see psarc/1995/138 for more info) 2N/A "direct-dev-access",
/* access through /dev co-exists */ 2N/A "floppy-summit-interfaces",
/* volmgt_{acquire,release} */ 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_acquire: try to acquire the volmgt advisory device reservation 2N/A * for a specific device. 2N/A * dev - a device name to attempt reserving. This string can be: 2N/A * - a full path name to a device 2N/A * - a symbolic device name (e.g. floppy0) 2N/A * id - a reservation string that hopefully describes the application 2N/A * making this reservation. 2N/A * pid - a pointer to a pid_t type. If this argument is not NULL 2N/A * and the requested device is already reserved, the process 2N/A * id of the reservation owner will be returned in this 2N/A * ovr - an override indicator. If set to non-zero, the caller requests 2N/A * that this reservation be made unconditionally. 2N/A * err - the address of a pointer to a string which is to receive the 2N/A * id argument used when the current device was reserved. This 2N/A * is only used when the current reservation attempt fails due 2N/A * to an already existing reservation for this device. 2N/A * A non-zero indicator if successful. 2N/A * A zero indicator if unsuccessful. If errno is EBUSY, then the err 2N/A * argument will be set to point to the string that the process currently 2N/A * holding the reservation supplied when reserving the device. It is up 2N/A * to the caller to release the storage occupied by the string via 2N/A * free(3C) when no longer needed. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * volmgt_release: try to release the volmgt advisory device reservation 2N/A * for a specific device. 2N/A * dev - a device name to attempt reserving. This string can be: 2N/A * - a full path name to a device 2N/A * - a symbolic device name (e.g. floppy0) 2N/A * A non-zero indicator if successful 2N/A * A zero indicator if unsuccessful 2N/A * returns the "value" of the attribute. 2N/A * If the attribute is boolean and is TRUE, 2N/A * "true" is returned. If the boolean is 2N/A * FALSE, NULL is returned. If the attribute 2N/A * doesn't exist, NULL is returned. The pointer 2N/A * returned by media_getattr has been malloc'd and 2N/A * it is the callers responsibility to free it. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * media_getattr: returns the value for an attribute for a piece of 2N/A * path - Path to the media in /vol. Can be the block or character 2N/A * attr - name of the attribute. 2N/A * returns NULL or a pointer to a string that contains the value for 2N/A * the requested attribute. 2N/A * - the media doesn't exist 2N/A * - there is no more space for malloc(3) 2N/A * - the attribute doesn't exist for the named media 2N/A * - the attribute is a boolean and is FALSE 2N/A * the pointer to the string must be free'd with free(3). 2N/A * volume management (vold) must be running. 2N/A * sets the attribute "attr" to value "value". 2N/A * If value == "" the flag is 2N/A * considered to be a TRUE boolean. 2N/A * If value == 0, it is considered to be a FALSE boolean. 2N/A * returns TRUE on success, FALSE on failure. 2N/A * Can fail for reasons of permission, or if you 2N/A * write a read-only attribute. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * media_setattr: set an attribute for a piece of media to a 2N/A * path - Path to the media in /vol. Can be the block or character 2N/A * attr - name of the attribute. 2N/A * value - value of the attribute. If value == "", the flag is 2N/A * considered to be a boolean that is TRUE. If value == 0, it 2N/A * is considered to be a FALSE boolean. 2N/A * TRUE on success, FALSE for failure. 2N/A * - don't have permission to set the attribute because caller 2N/A * is not the owner of the media and attribute is a "system" 2N/A * - don't have permission to set the attribute because the 2N/A * attribute is a "system" attribute and is read-only. 2N/A * volume management must be running. 2N/A * Returns the "id" of a volume. If the returned value 2N/A * & VOLID_TMP, the volume is temporary and this value 2N/A * cannot be relied upon across reboots. 2N/A * arc approved interface 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * media_getid: return the "id" of a piece of media. 2N/A * path - Path to the media in /vol. Can be the block or character 2N/A * returns a u_longlong_t that is the "id" of the volume. 2N/A * volume management must be running. 2N/A * arc approved interface (pending) 2N/A * - can not be modified without approval from an arc 2N/A * committment level: 2N/A * media_findname: try to come up with the character device when 2N/A * provided with a starting point. This interface provides the 2N/A * application programmer to provide "user friendly" names and 2N/A * easily determine the "/vol" name. 2N/A * start - a string describing a device. This string can be: 2N/A * - a full path name to a device (insures it's a 2N/A * character device by using getfullrawname()). 2N/A * - a full path name to a volume management media name 2N/A * with partitions (will return the lowest numbered 2N/A * - the name of a piece of media (e.g. "fred"). 2N/A * - a symbolic device name (e.g. floppy0, cdrom0, etc) 2N/A * - a name like "floppy" or "cdrom". Will pick the lowest 2N/A * numbered device with media in it. 2N/A * A pointer to a string that contains the character device 2N/A * most appropriate to the "start" argument. 2N/A * NULL indicates that we were unable to find media based on "start". 2N/A * The string must be free(3)'d. 2N/A * Eventually should implement using HAL interfaces. 2N/A * In the short term however, return NULL for aliases, 2N/A * and self for absolute pathnames. 2N/A * "old" aliases -- used to be used when vold wasn't running 2N/A {
"cd0",
"cdrom0" },
2N/A {
"cd1",
"cdrom1" },
2N/A * This is an ON Consolidation Private interface. 2N/A * This is an ON Consolidation Private interface. 2N/A * Print out the aliases available to the program user. Changes 2N/A * depending in whether volume management is running.