1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * return mount association with meta device 31 */ 32 33 #include <meta.h> 34 35 #include <sys/mnttab.h> 36 37 #include "meta_lib_prv.h" 38 39 /* 40 * return associated mount point with this mdname_t 41 */ 42 char * 43 meta_get_mountp( 44 mdsetname_t *sp, 45 mdname_t *np, 46 md_error_t *ep 47 ) 48 { 49 FILE *mfp; 50 struct mnttab m; 51 char *mountp = NULL; 52 char mnt_mountp[MNT_LINE_MAX]; 53 char mnt_special[MNT_LINE_MAX]; 54 55 /* should have a set */ 56 assert(sp != NULL); 57 58 /* look in mnttab */ 59 if ((mfp = open_mnttab()) == NULL) { 60 (void) mdsyserror(ep, errno, MNTTAB); 61 return (NULL); 62 } 63 64 while ((!mountp) && (getmntent(mfp, &m) == 0)) { 65 mdname_t *mnp; 66 67 if ((m.mnt_special == NULL) || (m.mnt_mountp == NULL)) 68 continue; 69 70 if (m.mnt_mountp[0] != '/') 71 continue; 72 73 if ((strcmp(m.mnt_fstype, "nfs") == 0) || 74 (strcmp(m.mnt_fstype, "autofs") == 0) || 75 (strcmp(m.mnt_fstype, "proc") == 0) || 76 (strcmp(m.mnt_fstype, "tmpfs") == 0) || 77 (strcmp(m.mnt_fstype, "cachefs") == 0) || 78 (strcmp(m.mnt_fstype, "lofs") == 0) || 79 (strcmp(m.mnt_fstype, "rfs") == 0) || 80 (strcmp(m.mnt_fstype, "fd") == 0)) 81 continue; 82 83 (void) strcpy(mnt_mountp, m.mnt_mountp); 84 (void) strcpy(mnt_special, m.mnt_special); 85 if ((mnp = metaname(&sp, mnt_special, ep)) == NULL) { 86 mdclrerror(ep); 87 continue; 88 } 89 90 if (np->dev == mnp->dev) { 91 mountp = mnt_mountp; 92 } 93 } 94 95 /* return success, if found */ 96 return (mountp? Strdup(mountp): NULL); 97 } 98