17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*eb4a63c6SJiri Cervenka * Common Development and Distribution License (the "License"). 6*eb4a63c6SJiri Cervenka * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*eb4a63c6SJiri Cervenka 227c478bd9Sstevel@tonic-gate /* 23*eb4a63c6SJiri Cervenka * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* 287c478bd9Sstevel@tonic-gate * Attempt to dynamically link in the Veritas libvxvmsc.so so that we can 297c478bd9Sstevel@tonic-gate * see if there are any Veritas volumes on any of the slices. 307c478bd9Sstevel@tonic-gate */ 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <stdlib.h> 337c478bd9Sstevel@tonic-gate #include <stdio.h> 347c478bd9Sstevel@tonic-gate #include <strings.h> 357c478bd9Sstevel@tonic-gate #include <sys/param.h> 367c478bd9Sstevel@tonic-gate #include <sys/errno.h> 377c478bd9Sstevel@tonic-gate #include <thread.h> 387c478bd9Sstevel@tonic-gate #include <synch.h> 397c478bd9Sstevel@tonic-gate #include <dlfcn.h> 407c478bd9Sstevel@tonic-gate #include <link.h> 417c478bd9Sstevel@tonic-gate #include <ctype.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #include "libdiskmgt.h" 447c478bd9Sstevel@tonic-gate #include "disks_private.h" 457c478bd9Sstevel@tonic-gate 46*eb4a63c6SJiri Cervenka #define VXVM_LIB_NAME "libvxvmsc.so" 47*eb4a63c6SJiri Cervenka 487c478bd9Sstevel@tonic-gate #define VXVM_NAME_SIZE 1 497c478bd9Sstevel@tonic-gate #define VXVM_PATH_SIZE 2 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate typedef char *vm_name_t; 527c478bd9Sstevel@tonic-gate typedef char *vm_path_t; 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * Pointers to libvxvmsc.so functions that we dynamically resolve. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate static int (*vxdl_libvxvm_get_version)(int version); 587c478bd9Sstevel@tonic-gate static int (*vxdl_libvxvm_get_conf)(int param); 597c478bd9Sstevel@tonic-gate static int (*vxdl_libvxvm_get_dgs)(int len, vm_name_t namep[]); 607c478bd9Sstevel@tonic-gate static int (*vxdl_libvxvm_get_disks)(vm_name_t dgname, int len, 617c478bd9Sstevel@tonic-gate vm_path_t pathp[]); 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate #define MAX_DISK_GROUPS 128 647c478bd9Sstevel@tonic-gate #define MAX_DISKS_DG 1024 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate struct vxvm_list { 677c478bd9Sstevel@tonic-gate struct vxvm_list *next; 687c478bd9Sstevel@tonic-gate char *slice; 697c478bd9Sstevel@tonic-gate }; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate static struct vxvm_list *vxvm_listp = NULL; 727c478bd9Sstevel@tonic-gate static time_t timestamp = 0; 737c478bd9Sstevel@tonic-gate static mutex_t vxvm_lock = DEFAULTMUTEX; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate static int add_use_record(char *devname); 767c478bd9Sstevel@tonic-gate static void free_vxvm(); 777c478bd9Sstevel@tonic-gate static void *init_vxvm(); 787c478bd9Sstevel@tonic-gate static int is_ctds(char *name); 797c478bd9Sstevel@tonic-gate static int load_vxvm(); 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate int 827c478bd9Sstevel@tonic-gate inuse_vxvm(char *slice, nvlist_t *attrs, int *errp) 837c478bd9Sstevel@tonic-gate { 847c478bd9Sstevel@tonic-gate int found = 0; 857c478bd9Sstevel@tonic-gate time_t curr_time; 867c478bd9Sstevel@tonic-gate char *sp = NULL; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate *errp = 0; 897c478bd9Sstevel@tonic-gate if (slice == NULL) { 907c478bd9Sstevel@tonic-gate return (found); 917c478bd9Sstevel@tonic-gate } 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * Since vxvm "encapsulates" the disk we need to match on any 957c478bd9Sstevel@tonic-gate * slice passed in. Strip the slice component from the devname. 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate if (is_ctds(slice)) { 987c478bd9Sstevel@tonic-gate if ((sp = strrchr(slice, '/')) == NULL) 997c478bd9Sstevel@tonic-gate sp = slice; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate while (*sp && *sp != 's') 1027c478bd9Sstevel@tonic-gate sp++; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate if (*sp) 1057c478bd9Sstevel@tonic-gate *sp = 0; 1067c478bd9Sstevel@tonic-gate else 1077c478bd9Sstevel@tonic-gate sp = NULL; 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate (void) mutex_lock(&vxvm_lock); 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate curr_time = time(NULL); 1137c478bd9Sstevel@tonic-gate if (timestamp < curr_time && (curr_time - timestamp) > 60) { 1147c478bd9Sstevel@tonic-gate free_vxvm(); /* free old entries */ 1157c478bd9Sstevel@tonic-gate *errp = load_vxvm(); /* load the cache */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate timestamp = curr_time; 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate if (*errp == 0) { 1217c478bd9Sstevel@tonic-gate struct vxvm_list *listp; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate listp = vxvm_listp; 1247c478bd9Sstevel@tonic-gate while (listp != NULL) { 1257c478bd9Sstevel@tonic-gate if (strcmp(slice, listp->slice) == 0) { 126*eb4a63c6SJiri Cervenka libdiskmgt_add_str(attrs, DM_USED_BY, 127*eb4a63c6SJiri Cervenka DM_USE_VXVM, errp); 128*eb4a63c6SJiri Cervenka libdiskmgt_add_str(attrs, DM_USED_NAME, 129*eb4a63c6SJiri Cervenka "", errp); 1307c478bd9Sstevel@tonic-gate found = 1; 1317c478bd9Sstevel@tonic-gate break; 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate listp = listp->next; 1347c478bd9Sstevel@tonic-gate } 1357c478bd9Sstevel@tonic-gate } 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate (void) mutex_unlock(&vxvm_lock); 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate /* restore slice name to orignal value */ 1407c478bd9Sstevel@tonic-gate if (sp != NULL) 1417c478bd9Sstevel@tonic-gate *sp = 's'; 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate return (found); 1447c478bd9Sstevel@tonic-gate } 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate static int 1477c478bd9Sstevel@tonic-gate add_use_record(char *devname) 1487c478bd9Sstevel@tonic-gate { 1497c478bd9Sstevel@tonic-gate struct vxvm_list *sp; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate sp = (struct vxvm_list *)malloc(sizeof (struct vxvm_list)); 1527c478bd9Sstevel@tonic-gate if (sp == NULL) { 1537c478bd9Sstevel@tonic-gate return (ENOMEM); 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate if ((sp->slice = strdup(devname)) == NULL) { 1577c478bd9Sstevel@tonic-gate free(sp); 1587c478bd9Sstevel@tonic-gate return (ENOMEM); 1597c478bd9Sstevel@tonic-gate } 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate sp->next = vxvm_listp; 1627c478bd9Sstevel@tonic-gate vxvm_listp = sp; 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate /* 1657c478bd9Sstevel@tonic-gate * Since vxvm "encapsulates" the disk we need to match on any 1667c478bd9Sstevel@tonic-gate * slice passed in. Strip the slice component from the devname. 1677c478bd9Sstevel@tonic-gate */ 1687c478bd9Sstevel@tonic-gate if (is_ctds(sp->slice)) { 1697c478bd9Sstevel@tonic-gate char *dp; 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate if ((dp = strrchr(sp->slice, '/')) == NULL) 1727c478bd9Sstevel@tonic-gate dp = sp->slice; 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate while (*dp && *dp != 's') 1757c478bd9Sstevel@tonic-gate dp++; 1767c478bd9Sstevel@tonic-gate *dp = 0; 1777c478bd9Sstevel@tonic-gate } 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate return (0); 1807c478bd9Sstevel@tonic-gate } 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * If the input name is in c[t]ds format then return 1, otherwise return 0. 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate static int 1867c478bd9Sstevel@tonic-gate is_ctds(char *name) 1877c478bd9Sstevel@tonic-gate { 1887c478bd9Sstevel@tonic-gate char *p; 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate if ((p = strrchr(name, '/')) == NULL) 1917c478bd9Sstevel@tonic-gate p = name; 1927c478bd9Sstevel@tonic-gate else 1937c478bd9Sstevel@tonic-gate p++; 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate if (*p++ != 'c') { 1967c478bd9Sstevel@tonic-gate return (0); 1977c478bd9Sstevel@tonic-gate } 1987c478bd9Sstevel@tonic-gate /* skip controller digits */ 1997c478bd9Sstevel@tonic-gate while (isdigit(*p)) { 2007c478bd9Sstevel@tonic-gate p++; 2017c478bd9Sstevel@tonic-gate } 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate /* handle optional target */ 2047c478bd9Sstevel@tonic-gate if (*p == 't') { 2057c478bd9Sstevel@tonic-gate p++; 2067c478bd9Sstevel@tonic-gate /* skip over target */ 2077c478bd9Sstevel@tonic-gate while (isdigit(*p) || isupper(*p)) { 2087c478bd9Sstevel@tonic-gate p++; 2097c478bd9Sstevel@tonic-gate } 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate if (*p++ != 'd') { 2137c478bd9Sstevel@tonic-gate return (0); 2147c478bd9Sstevel@tonic-gate } 2157c478bd9Sstevel@tonic-gate while (isdigit(*p)) { 2167c478bd9Sstevel@tonic-gate p++; 2177c478bd9Sstevel@tonic-gate } 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate if (*p++ != 's') { 2207c478bd9Sstevel@tonic-gate return (0); 2217c478bd9Sstevel@tonic-gate } 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate /* check the slice number */ 2247c478bd9Sstevel@tonic-gate while (isdigit(*p)) { 2257c478bd9Sstevel@tonic-gate p++; 2267c478bd9Sstevel@tonic-gate } 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate if (*p != 0) { 2297c478bd9Sstevel@tonic-gate return (0); 2307c478bd9Sstevel@tonic-gate } 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate return (1); 2337c478bd9Sstevel@tonic-gate } 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate /* 2367c478bd9Sstevel@tonic-gate * Free the list of vxvm entries. 2377c478bd9Sstevel@tonic-gate */ 2387c478bd9Sstevel@tonic-gate static void 2397c478bd9Sstevel@tonic-gate free_vxvm() 2407c478bd9Sstevel@tonic-gate { 2417c478bd9Sstevel@tonic-gate struct vxvm_list *listp = vxvm_listp; 2427c478bd9Sstevel@tonic-gate struct vxvm_list *nextp; 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate while (listp != NULL) { 2457c478bd9Sstevel@tonic-gate nextp = listp->next; 2467c478bd9Sstevel@tonic-gate free((void *)listp->slice); 2477c478bd9Sstevel@tonic-gate free((void *)listp); 2487c478bd9Sstevel@tonic-gate listp = nextp; 2497c478bd9Sstevel@tonic-gate } 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate vxvm_listp = NULL; 2527c478bd9Sstevel@tonic-gate } 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate /* 2557c478bd9Sstevel@tonic-gate * Try to dynamically link the vxvm functions we need. 2567c478bd9Sstevel@tonic-gate */ 2577c478bd9Sstevel@tonic-gate static void * 2587c478bd9Sstevel@tonic-gate init_vxvm() 2597c478bd9Sstevel@tonic-gate { 2607c478bd9Sstevel@tonic-gate void *lh; 2617c478bd9Sstevel@tonic-gate 262*eb4a63c6SJiri Cervenka if ((lh = dlopen(VXVM_LIB_NAME, RTLD_NOW)) == NULL) { 263*eb4a63c6SJiri Cervenka return (NULL); 2647c478bd9Sstevel@tonic-gate } 2657c478bd9Sstevel@tonic-gate 2667c478bd9Sstevel@tonic-gate if ((vxdl_libvxvm_get_version = (int (*)(int))dlsym(lh, 2677c478bd9Sstevel@tonic-gate "libvxvm_get_version")) == NULL) { 2687c478bd9Sstevel@tonic-gate (void) dlclose(lh); 2697c478bd9Sstevel@tonic-gate return (NULL); 2707c478bd9Sstevel@tonic-gate } 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate if ((vxdl_libvxvm_get_conf = (int (*)(int))dlsym(lh, 2737c478bd9Sstevel@tonic-gate "libvxvm_get_conf")) == NULL) { 2747c478bd9Sstevel@tonic-gate (void) dlclose(lh); 2757c478bd9Sstevel@tonic-gate return (NULL); 2767c478bd9Sstevel@tonic-gate } 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate if ((vxdl_libvxvm_get_dgs = (int (*)(int, vm_name_t []))dlsym(lh, 2797c478bd9Sstevel@tonic-gate "libvxvm_get_dgs")) == NULL) { 2807c478bd9Sstevel@tonic-gate (void) dlclose(lh); 2817c478bd9Sstevel@tonic-gate return (NULL); 2827c478bd9Sstevel@tonic-gate } 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate if ((vxdl_libvxvm_get_disks = (int (*)(vm_name_t, int, vm_path_t [])) 2857c478bd9Sstevel@tonic-gate dlsym(lh, "libvxvm_get_disks")) == NULL) { 2867c478bd9Sstevel@tonic-gate (void) dlclose(lh); 2877c478bd9Sstevel@tonic-gate return (NULL); 2887c478bd9Sstevel@tonic-gate } 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate return (lh); 2917c478bd9Sstevel@tonic-gate } 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate static int 2947c478bd9Sstevel@tonic-gate load_vxvm() 2957c478bd9Sstevel@tonic-gate { 2967c478bd9Sstevel@tonic-gate void *lh; 2977c478bd9Sstevel@tonic-gate int vers; 2987c478bd9Sstevel@tonic-gate int nsize; 2997c478bd9Sstevel@tonic-gate int psize; 3007c478bd9Sstevel@tonic-gate int n_disk_groups; 3017c478bd9Sstevel@tonic-gate vm_name_t *namep; 3027c478bd9Sstevel@tonic-gate char *pnp; 3037c478bd9Sstevel@tonic-gate vm_path_t *pathp; 3047c478bd9Sstevel@tonic-gate int i; 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate if ((lh = init_vxvm()) == NULL) { 3077c478bd9Sstevel@tonic-gate /* No library. */ 3087c478bd9Sstevel@tonic-gate return (0); 3097c478bd9Sstevel@tonic-gate } 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate vers = (vxdl_libvxvm_get_version)(1 << 8); 3127c478bd9Sstevel@tonic-gate if (vers == -1) { 3137c478bd9Sstevel@tonic-gate /* unsupported version */ 3147c478bd9Sstevel@tonic-gate (void) dlclose(lh); 3157c478bd9Sstevel@tonic-gate return (0); 3167c478bd9Sstevel@tonic-gate } 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate nsize = (vxdl_libvxvm_get_conf)(VXVM_NAME_SIZE); 3197c478bd9Sstevel@tonic-gate psize = (vxdl_libvxvm_get_conf)(VXVM_PATH_SIZE); 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate if (nsize == -1 || psize == -1) { 3227c478bd9Sstevel@tonic-gate (void) dlclose(lh); 3237c478bd9Sstevel@tonic-gate return (0); 3247c478bd9Sstevel@tonic-gate } 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate namep = (vm_name_t *)calloc(MAX_DISK_GROUPS, nsize); 3277c478bd9Sstevel@tonic-gate if (namep == NULL) { 3287c478bd9Sstevel@tonic-gate (void) dlclose(lh); 3297c478bd9Sstevel@tonic-gate return (ENOMEM); 3307c478bd9Sstevel@tonic-gate } 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate pathp = (vm_path_t *)calloc(MAX_DISKS_DG, psize); 3337c478bd9Sstevel@tonic-gate if (pathp == NULL) { 3347c478bd9Sstevel@tonic-gate (void) dlclose(lh); 3357c478bd9Sstevel@tonic-gate free(namep); 3367c478bd9Sstevel@tonic-gate return (ENOMEM); 3377c478bd9Sstevel@tonic-gate } 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate n_disk_groups = (vxdl_libvxvm_get_dgs)(MAX_DISK_GROUPS, namep); 3407c478bd9Sstevel@tonic-gate if (n_disk_groups < 0) { 3417c478bd9Sstevel@tonic-gate (void) dlclose(lh); 3427c478bd9Sstevel@tonic-gate free(namep); 3437c478bd9Sstevel@tonic-gate free(pathp); 3447c478bd9Sstevel@tonic-gate return (0); 3457c478bd9Sstevel@tonic-gate } 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate pnp = (char *)namep; 3487c478bd9Sstevel@tonic-gate for (i = 0; i < n_disk_groups; i++) { 3497c478bd9Sstevel@tonic-gate int n_disks; 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate n_disks = (vxdl_libvxvm_get_disks)(pnp, MAX_DISKS_DG, pathp); 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate if (n_disks >= 0) { 3547c478bd9Sstevel@tonic-gate int j; 3557c478bd9Sstevel@tonic-gate char *ppp; 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate ppp = (char *)pathp; 3587c478bd9Sstevel@tonic-gate for (j = 0; j < n_disks; j++) { 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate if (strncmp(ppp, "/dev/vx/", 8) == 0) { 3617c478bd9Sstevel@tonic-gate char *pslash; 3627c478bd9Sstevel@tonic-gate char nm[MAXPATHLEN]; 3637c478bd9Sstevel@tonic-gate 3647c478bd9Sstevel@tonic-gate pslash = strrchr(ppp, '/'); 3657c478bd9Sstevel@tonic-gate pslash++; 3667c478bd9Sstevel@tonic-gate 367*eb4a63c6SJiri Cervenka (void) snprintf(nm, sizeof (nm), 368*eb4a63c6SJiri Cervenka "/dev/dsk/%s", pslash); 3697c478bd9Sstevel@tonic-gate if (add_use_record(nm)) { 3707c478bd9Sstevel@tonic-gate (void) dlclose(lh); 3717c478bd9Sstevel@tonic-gate free(pathp); 3727c478bd9Sstevel@tonic-gate free(namep); 3737c478bd9Sstevel@tonic-gate return (ENOMEM); 3747c478bd9Sstevel@tonic-gate } 3757c478bd9Sstevel@tonic-gate } else { 3767c478bd9Sstevel@tonic-gate if (add_use_record(ppp)) { 3777c478bd9Sstevel@tonic-gate (void) dlclose(lh); 3787c478bd9Sstevel@tonic-gate free(pathp); 3797c478bd9Sstevel@tonic-gate free(namep); 3807c478bd9Sstevel@tonic-gate return (ENOMEM); 3817c478bd9Sstevel@tonic-gate } 3827c478bd9Sstevel@tonic-gate } 3837c478bd9Sstevel@tonic-gate 3847c478bd9Sstevel@tonic-gate ppp += psize; 3857c478bd9Sstevel@tonic-gate } 3867c478bd9Sstevel@tonic-gate } 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate pnp += nsize; 3897c478bd9Sstevel@tonic-gate } 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate (void) dlclose(lh); 3927c478bd9Sstevel@tonic-gate free(pathp); 3937c478bd9Sstevel@tonic-gate free(namep); 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate return (0); 3967c478bd9Sstevel@tonic-gate } 397