10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*1623Stw21770 * Common Development and Distribution License (the "License").
6*1623Stw21770 * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*1623Stw21770 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
270Sstevel@tonic-gate
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate * return mount association with meta device
300Sstevel@tonic-gate */
310Sstevel@tonic-gate
320Sstevel@tonic-gate #include <meta.h>
330Sstevel@tonic-gate
340Sstevel@tonic-gate #include <sys/mnttab.h>
350Sstevel@tonic-gate
360Sstevel@tonic-gate #include "meta_lib_prv.h"
370Sstevel@tonic-gate
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate * return associated mount point with this mdname_t
400Sstevel@tonic-gate */
410Sstevel@tonic-gate char *
meta_get_mountp(mdsetname_t * sp,mdname_t * np,md_error_t * ep)420Sstevel@tonic-gate meta_get_mountp(
430Sstevel@tonic-gate mdsetname_t *sp,
440Sstevel@tonic-gate mdname_t *np,
450Sstevel@tonic-gate md_error_t *ep
460Sstevel@tonic-gate )
470Sstevel@tonic-gate {
480Sstevel@tonic-gate FILE *mfp;
490Sstevel@tonic-gate struct mnttab m;
500Sstevel@tonic-gate char *mountp = NULL;
510Sstevel@tonic-gate char mnt_mountp[MNT_LINE_MAX];
520Sstevel@tonic-gate char mnt_special[MNT_LINE_MAX];
530Sstevel@tonic-gate
540Sstevel@tonic-gate /* should have a set */
550Sstevel@tonic-gate assert(sp != NULL);
560Sstevel@tonic-gate
570Sstevel@tonic-gate /* look in mnttab */
580Sstevel@tonic-gate if ((mfp = open_mnttab()) == NULL) {
590Sstevel@tonic-gate (void) mdsyserror(ep, errno, MNTTAB);
600Sstevel@tonic-gate return (NULL);
610Sstevel@tonic-gate }
620Sstevel@tonic-gate
630Sstevel@tonic-gate while ((!mountp) && (getmntent(mfp, &m) == 0)) {
640Sstevel@tonic-gate mdname_t *mnp;
650Sstevel@tonic-gate
660Sstevel@tonic-gate if ((m.mnt_special == NULL) || (m.mnt_mountp == NULL))
670Sstevel@tonic-gate continue;
680Sstevel@tonic-gate
690Sstevel@tonic-gate if (m.mnt_mountp[0] != '/')
700Sstevel@tonic-gate continue;
710Sstevel@tonic-gate
720Sstevel@tonic-gate if ((strcmp(m.mnt_fstype, "nfs") == 0) ||
730Sstevel@tonic-gate (strcmp(m.mnt_fstype, "autofs") == 0) ||
740Sstevel@tonic-gate (strcmp(m.mnt_fstype, "proc") == 0) ||
750Sstevel@tonic-gate (strcmp(m.mnt_fstype, "tmpfs") == 0) ||
760Sstevel@tonic-gate (strcmp(m.mnt_fstype, "cachefs") == 0) ||
770Sstevel@tonic-gate (strcmp(m.mnt_fstype, "lofs") == 0) ||
780Sstevel@tonic-gate (strcmp(m.mnt_fstype, "rfs") == 0) ||
790Sstevel@tonic-gate (strcmp(m.mnt_fstype, "fd") == 0))
800Sstevel@tonic-gate continue;
810Sstevel@tonic-gate
820Sstevel@tonic-gate (void) strcpy(mnt_mountp, m.mnt_mountp);
830Sstevel@tonic-gate (void) strcpy(mnt_special, m.mnt_special);
84*1623Stw21770 if ((mnp = metaname(&sp, mnt_special, UNKNOWN, ep)) == NULL) {
850Sstevel@tonic-gate mdclrerror(ep);
860Sstevel@tonic-gate continue;
870Sstevel@tonic-gate }
880Sstevel@tonic-gate
890Sstevel@tonic-gate if (np->dev == mnp->dev) {
900Sstevel@tonic-gate mountp = mnt_mountp;
910Sstevel@tonic-gate }
920Sstevel@tonic-gate }
930Sstevel@tonic-gate
940Sstevel@tonic-gate /* return success, if found */
950Sstevel@tonic-gate return (mountp? Strdup(mountp): NULL);
960Sstevel@tonic-gate }
97