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
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.
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/types.h>
32 #include <sys/mnttab.h>
33 #include <sys/mntent.h>
39 #include "statcommon.h"
46 static void build_mnt_list(FILE *);
49 lookup_mntent_byname(char *nm
)
60 if (strcmp(nm
, minfo
->device_name
)) {
63 else if (did_nfs
== 0) {
85 if (stat(MNTTAB
, &buf
) == 0) {
86 if (buf
.st_mtime
!= mtime
) {
88 * File has changed. Get the new file.
90 if ((mpt
= fopen(MNTTAB
, "r"))) {
95 (void) fcntl(fileno(mpt
), F_SETLKW
, &lb
);
99 * Lock goes away when we close the file.
108 build_mnt_list(FILE *mpt
)
114 struct extmnttab mnt
;
118 free(nfs
->device_name
);
119 free(nfs
->mount_point
);
126 free(ufs
->device_name
);
127 free(ufs
->mount_point
);
133 (void) memset(&mnt
, 0, sizeof (struct extmnttab
));
136 while ((found
= getextmntent(mpt
, &mnt
,
137 sizeof (struct extmnttab
))) != -1) {
139 if (strcmp(mnt
.mnt_fstype
, MNTTYPE_UFS
) == 0)
141 else if (strcmp(mnt
.mnt_fstype
,
147 item
= safe_alloc(sizeof (mnt_t
));
149 safe_strdup(mnt
.mnt_special
);
151 safe_strdup(mnt
.mnt_mountp
);
153 safe_strdup(mnt
.mnt_mntopts
);
154 item
->minor
= mnt
.mnt_minor
;