1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3 * CDDL HEADER START
4 *
5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
8 * with the License.
9 *
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or https://opensource.org/licenses/CDDL-1.0.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
14 *
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
20 *
21 * CDDL HEADER END
22 */
23 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
24 /* All Rights Reserved */
25 /*
26 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29 /* Copyright 2006 Ricardo Correia */
30
31 #ifndef _SYS_MNTTAB_H
32 #define _SYS_MNTTAB_H
33
34 #include <stdio.h>
35 #include <mntent.h>
36 #include <sys/stat.h>
37 #include <sys/types.h>
38
39 #ifdef MNTTAB
40 #undef MNTTAB
41 #endif /* MNTTAB */
42
43 #define MNTTAB "/proc/self/mounts"
44 #define MNT_LINE_MAX 4108
45
46 #define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */
47 #define MNT_TOOMANY 2 /* too many fields in line */
48 #define MNT_TOOFEW 3 /* too few fields in line */
49
50 struct mnttab {
51 char *mnt_special;
52 char *mnt_mountp;
53 char *mnt_fstype;
54 char *mnt_mntopts;
55 };
56
57 /*
58 * NOTE: fields in extmnttab should match struct mnttab till new fields
59 * are encountered, this allows hasmntopt to work properly when its arg is
60 * a pointer to an extmnttab struct cast to a mnttab struct pointer.
61 */
62
63 struct extmnttab {
64 char *mnt_special;
65 char *mnt_mountp;
66 char *mnt_fstype;
67 char *mnt_mntopts;
68 uint_t mnt_major;
69 uint_t mnt_minor;
70 };
71
72 struct statfs;
73
74 extern int getmntany(FILE *fp, struct mnttab *mp, struct mnttab *mpref);
75 extern int _sol_getmntent(FILE *fp, struct mnttab *mp);
76 extern int getextmntent(const char *path, struct extmnttab *mp,
77 struct stat64 *statbuf);
_sol_hasmntopt(struct mnttab * mnt,const char * opt)78 static inline char *_sol_hasmntopt(struct mnttab *mnt, const char *opt)
79 {
80 struct mntent mnt_new;
81
82 mnt_new.mnt_opts = mnt->mnt_mntopts;
83
84 return (hasmntopt(&mnt_new, opt));
85 }
86
87 #define hasmntopt _sol_hasmntopt
88 #define getmntent _sol_getmntent
89
90 #endif
91