md_link.c revision b2178a54bfad47b786da1c125ad5c89bbffb0a03
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <meta.h>
#include <regex.h>
#include <devfsadm.h>
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <limits.h>
#define MD_LINK_RE_DEVICES "^md/r?dsk/.+$"
#define MD_LINK_RE_SHARED "^md/shared/[0-9]+/r?dsk/.+$"
#define MD_LINK_RE_ADMIN "^md/admin"
/*
* The devfsadm link module require the next section to
* be defined in order to know what and when to call functions
* in the module on device creation and removal.
*/
/* setup for device creation */
static devfsadm_create_t md_cbt[] = {
{ "pseudo", "ddi_pseudo", "md",
},
};
/*
* remove devices - always allow disks to be dynamically removed. Only allow
* admin device to be removed at reboot.
*/
static devfsadm_remove_t md_remove_cbt[] = {
};
/*
* For the admin device:
*
* For metadevice:
*
* Where 'foobar' is user specified arbitrary name and '100'
* is the minor number returned by MD_IOCMAKE_DEV ioctl
*
*/
static int
{
char *device_name;
int key;
/*
* Check whether we are being requested to setup the admin
* device link or one of the metadevice links. They need
* to be treated differently.
*/
} else {
/*
* Extract out the minor components and create the
* appropriate links. The node looks like:
* md@<set>,<mdev>,<type>
* where the <set> number is the named diskset,
* <mdev> is the metadevice number, and <type>
* is the trailing "blk" or "raw" indication.
*
* NOTE: when <set> is non-zero, we need to create
* under the "shared" directory entry instead of linking
*/
type++;
dir = "dsk";
} else {
dir = "rdsk";
}
(void) close_admin(&ep);
return (DEVFSADM_CONTINUE);
}
if (set == 0) {
/* this is a simple md */
} else {
/* this is a shared md */
/*
* flush the caches so the next call to
* metasetnosetname will get us the
* updated cache.
*/
metaflushnames(0);
!= NULL) {
sizeof (sym_path), "md/%s",
}
}
(void) devfsadm_secondary_link(sym_path,
set_path, 0);
}
}
}
(void) close_admin(&ep);
return (DEVFSADM_CONTINUE);
}