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 (c) 1993, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * return set for a device 2N/A /* regular device */ 2N/A * convert system to md types 2N/A * convert efi to md types 2N/A * Should always get geom from metadevice unit if metadevice. 2N/A * If metadevice is built on top of efi disks then it will 2N/A * have MD_EFI_FG_ values, otherwise it will have geom from 2N/A * the first component. 2N/A * It is possible to present an efi label but be using vtoc 2N/A * disks to create a > 1 TB metadevice. In case the first 2N/A * disk in the underlying metadevice is a vtoc disk and starts 2N/A * at the beginning of the disk it is necessary to convey this 2N/A * information to the user. 2N/A * Due to the lack of a label for the entire partition table, 2N/A * we use p_name of the reserved partition 2N/A /* Stop at first (if any) space or tab */ 2N/A /* first we count how many partitions we have to send */ 2N/A /* if we are here, we know the partition is really used */ 2N/A * Due to the lack of a label for the entire partition table, 2N/A * we use p_name of the reserved partition 2N/A * getdrvnode -- return the driver name based on mdname_t->bname 2N/A * Need to free pointer when finished. 2N/A * At this point devicespath should be like the following 2N/A * "/devices/<unknow_and_dont_care>/xxxx@vvvv" 2N/A * There's a couple of 'if' statements below which could 2N/A * return an error condition, but I've decide to allow 2N/A * a more open approach regarding the mapping so as to 2N/A * not restrict possible future projects. 2N/A * drvnode now just "xxxx@vvvv" 2N/A * Now drvnode is just the driver name "xxxx" 2N/A * meta_load_dl -- open dynamic library using LDLIBRARYPATH, a debug 2N/A * environment variable METALDPATH, or the default location. 2N/A * Library seach algorithm: 2N/A * 1) Use LDLIBRARYPATH which is implied when a non-absolute 2N/A * path name is passed to dlopen() 2N/A * 2) Use the value of METALDPATH as the directory. Mainly 2N/A * used for debugging 2N/A * 3) Last search the default location of "/usr/lib" 2N/A * Common failure here would be failing to 2N/A * Some controllers will not have a library 2N/A * because there's no enclosure or name 2N/A * translation required. 2N/A * meta_match_names -- possibly convert the driver names returned by CINFO 2N/A * meta_match_enclosure -- return any enclosure info if found 2N/A * Looks like this library wanted to handle 2N/A * our device and had an internal error. 2N/A * Found a library to handle the request so 2N/A * just return with data provided. 2N/A * Need to continue the search 2N/A * See if the driver name returned from DKIOCINFO 2N/A * is valid or not. In somecases, such as the ap_dmd 2N/A * driver, we need to modify the name that's return 2N/A * for everything to work. 2N/A /* return success */ 2N/A * free allocations in vtoc 2N/A int err = 0;
/* saves errno from ioctl */ 2N/A * the following assigment works because the 2N/A * mdname_t structs are always created as part 2N/A * of the drivenamep struct. When a user 2N/A * creates an mdname_t struct it either 2N/A * uses an existing drivenamep struct or creates 2N/A * a new one and then adds the mdname_t struct 2N/A * as part of its parts_val array. So what is 2N/A * being computed below is the slice offset in 2N/A * the parts_val array. 2N/A /* can't get vtoc */ 2N/A /* get all the info */ 2N/A * The disk is open so this is a good point to get the devid 2N/A * otherwise it will need to be done at another time which 2N/A * means reopening it. 2N/A /* there is no devid for the disk */ 2N/A * The minor name could be NULL if the underlying 2N/A * device driver does not support 'minor names'. 2N/A * This means we do not use devid's for this device. 2N/A * SunCluster did driver does not support minor names. 2N/A "%s no minor name (no devid)\n"),
2N/A * if our drivenamep points to a device not supporting DKIOCGGEOM, 2N/A * it's likely to have an EFI label. 2N/A * If we are here, there was either no failure on DKIOCGGEOM or 2N/A * the failure was ENOTSUP 2N/A /* DKIOCGGEOM yielded ENOTSUP => try efi_alloc_and_read */ 2N/A /* this also sets errno */ 2N/A /* convert to our format */ 2N/A * libmeta needs at least V_NUMPAR partitions. 2N/A * If we have an EFI partition with less than V_NUMPAR slices, 2N/A * we nevertheless reserve space for V_NUMPAR 2N/A * Is np a metadevice? 2N/A /* no error on DKIOCGGEOM, try meta_getvtoc */ 2N/A /* convert to our format */ 2N/A /* fix up any drives which are now accessible */ 2N/A * Set the vtoc, but use the cached copy to get the info from. 2N/A * We write np->drivenamep->vtoc to disk. 2N/A * Before we can do this we read the vtoc in. 2N/A * if we're dealing with a metadevice and this metadevice is a 64 bit device 2N/A * dnp->vtoc (actually being a mdvtoc_t) into a vtoc_t 2N/A /* allocation of gpt is done in meta_mdvtoc_to_efi */ 2N/A /* get controller info */ 2N/A /* convert to our format */ 2N/A * get partition number 2N/A * get size of device 2N/A * get label of device 2N/A * find out where database replicas end 2N/A /* make sure we have a component */ 2N/A /* get replicas, quit if none */ 2N/A /* go through all the replicas */ 2N/A /* cleanup, return success */ 2N/A * return cached start block 2N/A /* look for database locations */ 2N/A * does device have a metadb 2N/A * return cached start block 2N/A /* look for database locations */ 2N/A /* check for label */ 2N/A /* roundup to next cylinder */ 2N/A * return cached devices name 2N/A /* follow symlink */ 2N/A * get metadevice misc name 2N/A /* get misc module from driver */ 2N/A /* return miscname */ 2N/A * get unit structure from driver 2N/A /* should have a set */ 2N/A /* get size of unit structure */ 2N/A /* get actual unit structure */ 2N/A * free metadevice unit 2N/A * free metadevice name info 2N/A /* get rid of cached name info */ 2N/A /* get rid of cached drivename info */ 2N/A * get metadevice unit 2N/A * shortcut: if the device is open, no need to check on other nodes, 2N/A * even in case of a mn metadevice 2N/A * Also return in case we're told not to check on other nodes. 2N/A * If the device is closed locally, but it's a mn device, 2N/A * check on all other nodes, too 2N/A * This message is never directly issued. 2N/A * So we launch it with a suspend override flag. 2N/A * If the commd is suspended, and this message comes 2N/A * along it must be sent due to replaying a metainit or 2N/A * similar. In that case we don't want this message to 2N/A * If the commd is not suspended, the flag does no harm. 2N/A * Additionally we don't want the result of the message 2N/A * cached in the MCT, because we want uptodate results, 2N/A * and the message doesn't need being logged either. 2N/A * Hence NO_LOG and NO_MCT 2N/A * in case some error occurred, 2N/A * we better say the device is open 2N/A * Return the minor name associated with a given disk slice