/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Attempt to dynamically link in the Veritas libvxvmsc.so so that we can
* see if there are any Veritas volumes on any of the slices.
*/
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <thread.h>
#include <synch.h>
#include <dlfcn.h>
#include <link.h>
#include <ctype.h>
#include "libdiskmgt.h"
#include "disks_private.h"
typedef char *vm_name_t;
typedef char *vm_path_t;
/*
* Pointers to libvxvmsc.so functions that we dynamically resolve.
*/
struct vxvm_list {
char *slice;
};
static int add_use_record(char *devname);
static void free_vxvm();
static void *init_vxvm();
static int load_vxvm();
int
{
int found = 0;
*errp = 0;
return (found);
}
/*
* Since vxvm "encapsulates" the disk we need to match on any
* slice passed in. Strip the slice component from the devname.
*/
sp++;
if (*sp)
*sp = 0;
else
}
(void) mutex_lock(&vxvm_lock);
free_vxvm(); /* free old entries */
}
if (*errp == 0) {
listp = vxvm_listp;
DM_USE_VXVM, errp);
"", errp);
found = 1;
break;
}
}
}
(void) mutex_unlock(&vxvm_lock);
/* restore slice name to orignal value */
*sp = 's';
return (found);
}
static int
{
return (ENOMEM);
}
return (ENOMEM);
}
vxvm_listp = sp;
/*
* Since vxvm "encapsulates" the disk we need to match on any
* slice passed in. Strip the slice component from the devname.
*/
char *dp;
dp++;
*dp = 0;
}
return (0);
}
/*
* If the input name is in c[t]ds format then return 1, otherwise return 0.
*/
static int
{
char *p;
p = name;
else
p++;
if (*p++ != 'c') {
return (0);
}
/* skip controller digits */
while (isdigit(*p)) {
p++;
}
/* handle optional target */
if (*p == 't') {
p++;
/* skip over target */
p++;
}
}
if (*p++ != 'd') {
return (0);
}
while (isdigit(*p)) {
p++;
}
if (*p++ != 's') {
return (0);
}
/* check the slice number */
while (isdigit(*p)) {
p++;
}
if (*p != 0) {
return (0);
}
return (1);
}
/*
* Free the list of vxvm entries.
*/
static void
{
}
vxvm_listp = NULL;
}
/*
* Try to dynamically link the vxvm functions we need.
*/
static void *
{
void *lh;
return (NULL);
}
"libvxvm_get_version")) == NULL) {
return (NULL);
}
"libvxvm_get_conf")) == NULL) {
return (NULL);
}
"libvxvm_get_dgs")) == NULL) {
return (NULL);
}
return (NULL);
}
return (lh);
}
static int
{
void *lh;
int vers;
int nsize;
int psize;
int n_disk_groups;
char *pnp;
int i;
/* No library. */
return (0);
}
if (vers == -1) {
/* unsupported version */
return (0);
}
return (0);
}
return (ENOMEM);
}
return (ENOMEM);
}
if (n_disk_groups < 0) {
return (0);
}
for (i = 0; i < n_disk_groups; i++) {
int n_disks;
if (n_disks >= 0) {
int j;
char *ppp;
for (j = 0; j < n_disks; j++) {
char *pslash;
pslash++;
if (add_use_record(nm)) {
return (ENOMEM);
}
} else {
if (add_use_record(ppp)) {
return (ENOMEM);
}
}
}
}
}
return (0);
}