1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate /* 24*0Sstevel@tonic-gate * Copyright 1992-2002 Sun Microsystems, Inc. All rights reserved. 25*0Sstevel@tonic-gate * Use is subject to license terms. 26*0Sstevel@tonic-gate */ 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate /* 32*0Sstevel@tonic-gate * attach operations 33*0Sstevel@tonic-gate */ 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #include <meta.h> 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate /* 38*0Sstevel@tonic-gate * grow generic device 39*0Sstevel@tonic-gate */ 40*0Sstevel@tonic-gate int 41*0Sstevel@tonic-gate meta_concat_generic( 42*0Sstevel@tonic-gate mdsetname_t *sp, 43*0Sstevel@tonic-gate mdname_t *namep, 44*0Sstevel@tonic-gate u_longlong_t big_or_little, 45*0Sstevel@tonic-gate md_error_t *ep 46*0Sstevel@tonic-gate ) 47*0Sstevel@tonic-gate { 48*0Sstevel@tonic-gate md_grow_params_t mgp; 49*0Sstevel@tonic-gate char *miscname; 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate /* should have a set */ 52*0Sstevel@tonic-gate assert(sp != NULL); 53*0Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(namep->dev))); 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate /* get type */ 56*0Sstevel@tonic-gate if ((miscname = metagetmiscname(namep, ep)) == NULL) 57*0Sstevel@tonic-gate return (-1); 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate /* grow device */ 60*0Sstevel@tonic-gate (void) memset(&mgp, 0, sizeof (mgp)); 61*0Sstevel@tonic-gate if (big_or_little == MD_64BIT_META_DEV) 62*0Sstevel@tonic-gate mgp.options = MD_CRO_64BIT; 63*0Sstevel@tonic-gate else 64*0Sstevel@tonic-gate mgp.options = MD_CRO_32BIT; 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate mgp.mnum = meta_getminor(namep->dev); 67*0Sstevel@tonic-gate MD_SETDRIVERNAME(&mgp, miscname, sp->setno); 68*0Sstevel@tonic-gate if (metaioctl(MD_IOCGROW, &mgp, &mgp.mde, namep->cname) != 0) 69*0Sstevel@tonic-gate return (mdstealerror(ep, &mgp.mde)); 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate /* clear cache */ 72*0Sstevel@tonic-gate meta_invalidate_name(namep); 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* return success */ 75*0Sstevel@tonic-gate return (0); 76*0Sstevel@tonic-gate } 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate /* 79*0Sstevel@tonic-gate * grow the parent of a device 80*0Sstevel@tonic-gate */ 81*0Sstevel@tonic-gate int 82*0Sstevel@tonic-gate meta_concat_parent( 83*0Sstevel@tonic-gate mdsetname_t *sp, 84*0Sstevel@tonic-gate mdname_t *childnp, 85*0Sstevel@tonic-gate md_error_t *ep 86*0Sstevel@tonic-gate ) 87*0Sstevel@tonic-gate { 88*0Sstevel@tonic-gate md_common_t *mdp; 89*0Sstevel@tonic-gate mdname_t *parentnp; 90*0Sstevel@tonic-gate md_unit_t *mup; 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate /* should have a set */ 93*0Sstevel@tonic-gate assert(sp != NULL); 94*0Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(childnp->dev))); 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate /* get parent */ 97*0Sstevel@tonic-gate if ((mdp = meta_get_unit(sp, childnp, ep)) == NULL) 98*0Sstevel@tonic-gate return (-1); 99*0Sstevel@tonic-gate if (! MD_HAS_PARENT(mdp->parent)) 100*0Sstevel@tonic-gate return (0); 101*0Sstevel@tonic-gate if (mdp->parent == MD_MULTI_PARENT) 102*0Sstevel@tonic-gate return (0); 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate /* single parent */ 105*0Sstevel@tonic-gate if ((parentnp = metamnumname(&sp, mdp->parent, 0, ep)) == NULL) 106*0Sstevel@tonic-gate return (-1); 107*0Sstevel@tonic-gate /* don't grow non-metadevices or soft partitions */ 108*0Sstevel@tonic-gate if (! metaismeta(parentnp) || meta_sp_issp(sp, parentnp, ep) == 0) 109*0Sstevel@tonic-gate return (0); 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate if ((mup = meta_get_mdunit(sp, childnp, ep)) == NULL) 112*0Sstevel@tonic-gate return (-1); 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate /* grow parent */ 115*0Sstevel@tonic-gate if (meta_concat_generic(sp, parentnp, mup->c.un_revision, ep) != 0) 116*0Sstevel@tonic-gate return (-1); 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* recursively check for parents of parents */ 119*0Sstevel@tonic-gate return (meta_concat_parent(sp, parentnp, ep)); 120*0Sstevel@tonic-gate } 121