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) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * This is called by media/slice to get the associated partitions. 2N/A * For a media desc. we just get all the partitions, but for a slice desc. 2N/A * we just get the active solaris partition. 2N/A /* allocate the array for the descriptors */ 2N/A /* convert part. name (e.g. c0d0p1) */ 2N/A * If this is a slice desc. we need the first active solaris partition 2N/A * and if there isn't one then we need the first solaris partition. 2N/A * no active solaris part.,*try to get the first solaris part. 2N/A /* we found a solaris partition to use */ 2N/A /* convert part. name (e.g. c0d0p1) */ 2N/A /* the media name comes from the slice desc. */ 2N/A /* Must be for media, so get all the parts. */ 2N/A * Process the descriptors and modify the cxdxpx 2N/A * format so that it refers to the fdisk partition 2N/A * number and not to the physical disk. This is 2N/A * achieved by i+1, where i is the number of the 2N/A * physical disk partition. 2N/A /* convert part. name (e.g. c0d0p1) */ 2N/A /* the media name comes from the media desc. */ 2N/A * Look for the partition by the partition number (which is not too useful). 2N/A /* clean up the unused descriptors */ 2N/A /* There are no stat types defined for partitions */ 2N/A /* on sparc, only removable media can have fdisk parts. */ 2N/A * We assume the caller already made sure media was inserted and 2N/A * partition_make_descriptors 2N/A * A partition descriptor points to a disk, the name is the partition number 2N/A * and the secondary name is the media name. The iparts parameter returned 2N/A * by the get_parts function contains the structures of all of the identified 2N/A * partitions found on each disk on a system. These are processed into an array 2N/A * of descriptors. A descriptor contains all of the information about a 2N/A * specific partition. 2N/A * Returns: 0 on success 2N/A * Error value on failure 2N/A /* convert part. name (e.g. c0d0p1) */ 2N/A * Process the descriptors and modify the cxdxpx 2N/A * format so that it refers to the fdisk partition 2N/A * number and not to the physical disk. This is 2N/A * achieved by i+1, where i is the number of the 2N/A * physical disk partition. 2N/A * convert partition name 2N/A * We already made sure the media was loaded and ready in the 2N/A * get_parts call within partition_get_attributes. 2N/A * A partition has been found. Determine what type of 2N/A * partition it is: logical, extended, or primary. 2N/A * Collect the information for the partition. 2N/A * Discovers the primary, extended, and logical partitions that have 2N/A * been created on a disk. get_parts loops through the partitions, 2N/A * collects the information on each partition and stores it in a 2N/A * disk -The disk device to be evaluated for partitions 2N/A * iparts -The structure that holds information about 2N/A * opath -The device path 2N/A * opath_len -Buffer size used with opath 2N/A * 0 on Successful completion 2N/A * Error Value on failure 2N/A /* Can't use drive_open_disk since we need the partition dev name. */ 2N/A /* First make sure media is inserted and spun up. */ 2N/A * Initialize the memory space to clear unknown garbage 2N/A * that might create confusing results. 2N/A * Check to see if a valid partition exists. If a valid partition 2N/A * exists, check to see if it is an extended partition. 2N/A * If an extended partition exists, collect the logical partition 2N/A * The first 2 error cases indicate that 2N/A * there is no Solaris logical partition, 2N/A * which is a valid condition, 2N/A * so iterating through the disk continues. 2N/A * Any other error cases indicate there is 2N/A * a potential problem with the disk, so 2N/A * don't continue iterating through the disk 2N/A * and return an error. 2N/A * Collect logical drive information 2N/A /* free the device and the epp memory. */ 2N/A/* return 1 if the partition descriptor is still valid, 0 if not. */ 2N/A /* First verify the media name for removable media */ 2N/A * We could verify the partition is still there but this is kind of 2N/A * expensive and other code down the line will do that (e.g. see 2N/A * Return 1 if partition has slices, 0 if not. 2N/A * Slices are associated with the active solaris partition or if there 2N/A * is no active solaris partition, then the first solaris partition. 2N/A /* Check if there are no active solaris partitions. */ 2N/A /* Check if this is the first solaris partition. */ 2N/A * Just open the first devpath. 2N/A /* On intel we need to open partition device (e.g. c0d0p1). */