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 1990 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
34 static struct fstab
*pfs
;
38 fstabscan(struct fstab
*fs
)
42 /* skip over all filesystem types except '4.2', 'swap' & 'ignore' */
43 while (((mnt
= getmntent(fs_file
)) != NULL
) &&
44 !((strcmp(mnt
->mnt_type
, MNTTYPE_42
) == 0) ||
45 (strcmp(mnt
->mnt_type
, MNTTYPE_SWAP
) == 0) ||
46 (strcmp(mnt
->mnt_type
, MNTTYPE_IGNORE
) == 0)))
50 fs
->fs_spec
= mnt
->mnt_fsname
;
51 fs
->fs_file
= mnt
->mnt_dir
;
52 if (strcmp(mnt
->mnt_type
, MNTTYPE_IGNORE
) == 0) {
53 strcpy(mnt
->mnt_opts
, FSTAB_XX
);
54 } else if (strcmp(mnt
->mnt_type
, MNTTYPE_SWAP
) == 0) {
55 strcpy(mnt
->mnt_opts
, FSTAB_SW
);
56 } else if (hasmntopt(mnt
, MNTOPT_RO
)) {
57 strcpy(mnt
->mnt_opts
, FSTAB_RO
);
58 } else if (hasmntopt(mnt
, MNTOPT_QUOTA
)) {
59 strcpy(mnt
->mnt_opts
, FSTAB_RQ
);
61 strcpy(mnt
->mnt_opts
, FSTAB_RW
);
63 fs
->fs_type
= mnt
->mnt_opts
;
64 fs
->fs_freq
= mnt
->mnt_freq
;
65 fs
->fs_passno
= mnt
->mnt_passno
;
75 if ((fs_file
= setmntent(FSTAB
, "r")) == NULL
) {
98 if ((fs_file
== 0) && (setfsent() == 0))
99 return ((struct fstab
*)0);
101 pfs
= (struct fstab
*)malloc(sizeof (struct fstab
));
105 nfields
= fstabscan(pfs
);
106 if (nfields
== EOF
|| nfields
!= 5)
107 return ((struct fstab
*)0);
112 getfsspec(char *name
)
116 if (setfsent() == 0) /* start from the beginning */
117 return ((struct fstab
*)0);
118 while((fsp
= getfsent()) != 0)
119 if (strcmp(fsp
->fs_spec
, name
) == 0)
121 return ((struct fstab
*)0);
125 getfsfile(char *name
)
129 if (setfsent() == 0) /* start from the beginning */
130 return ((struct fstab
*)0);
131 while ((fsp
= getfsent()) != 0)
132 if (strcmp(fsp
->fs_file
, name
) == 0)
134 return ((struct fstab
*)0);
138 getfstype(char *type
)
143 return ((struct fstab
*)0);
144 while ((fs
= getfsent()) != 0)
145 if (strcmp(fs
->fs_type
, type
) == 0)
147 return ((struct fstab
*)0);