9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / getmntent.3c
blob16995f58f12df89f7d7793ea431cce7b8d7002aa
1 '\" te
2 .\" Copyright 1989 AT&T.  Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH GETMNTENT 3C "Mar 22, 2004"
7 .SH NAME
8 getmntent, getmntany, getextmntent, hasmntopt, putmntent, resetmnttab \- get
9 mounted device information
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <stdio.h>
14 #include <sys/mnttab.h>
16 \fBint\fR \fBgetmntent\fR(\fBFILE *\fR\fIfp\fR, \fBstruct mnttab *\fR\fImp\fR);
17 .fi
19 .LP
20 .nf
21 \fBint\fR \fBgetmntany\fR(\fBFILE *\fR\fIfp\fR, \fBstruct mnttab *\fR\fImp\fR, \fBstruct mnttab *\fR\fImpref\fR);
22 .fi
24 .LP
25 .nf
26 \fBint\fR \fBgetextmntent\fR(\fBFILE *\fR\fIfp\fR, \fBstruct extmnttab *\fR\fImp\fR, \fBint\fR \fIlen\fR);
27 .fi
29 .LP
30 .nf
31 \fBchar *\fR\fBhasmntopt\fR(\fBstruct mnttab *\fR\fImnt\fR, \fBchar *\fR\fIopt\fR);
32 .fi
34 .LP
35 .nf
36 \fBint\fR \fBputmntent\fR(\fBFILE *\fR\fIiop\fR, \fBstruct mnttab *\fR\fImp\fR);
37 .fi
39 .LP
40 .nf
41 \fBvoid\fR \fBresetmnttab\fR(\fBFILE *\fR\fIfp\fR);
42 .fi
44 .SH DESCRIPTION
45 .SS "\fBgetmntent()\fR and \fBgetmntany()\fR"
46 .sp
47 .LP
48 The \fBgetmntent()\fR and \fBgetmntany()\fR functions each fill in the
49 structure pointed to by \fImp\fR with the broken-out fields of a line in the
50 \fBmnttab\fR file. Each line read from the file contains a \fBmnttab\fR
51 structure, which is defined in the <\fBsys/mnttab.h\fR> header. The structure
52 contains the following members, which correspond to the broken-out fields from
53 a line in \fB/etc/mnttab\fR (see \fBmnttab\fR(4)).
54 .sp
55 .in +2
56 .nf
57 char   *mnt_special;     /* name of mounted resource */
58 char   *mnt_mountp;      /* mount point */
59 char   *mnt_fstype;      /* type of file system mounted */
60 char   *mnt_mntopts;     /* options for this mount */
61 char   *mnt_time;        /* time file system mounted */
62 .fi
63 .in -2
65 .sp
66 .LP
67 Fields with no actual content in \fB/etc/mnttab\fR are represented in the file
68 as "-". To clearly distinguish empty fields, \fBgetmntent()\fR set the
69 corresponding field in \fImp\fR to \fINULL\fR.
70 .sp
71 .LP
72 Each \fBgetmntent()\fR call causes a new line to be read from the \fBmnttab\fR
73 file. Successive calls can be used to search the entire list. The
74 \fBgetmntany()\fR function searches the file referenced by \fIfp\fR until a
75 match is found between a line in the file and \fImpref\fR. A match occurs if
76 all non-null entries in \fImpref\fR match the corresponding fields in the file.
77 These functions do not open, close, or rewind the file.
78 .SS "\fBgetextmntent()\fR"
79 .sp
80 .LP
81 The \fBgetextmntent()\fR function is an extended version of the
82 \fBgetmntent()\fR function that returns, in addition to the information that
83 \fBgetmntent()\fR returns, the major and minor number of the mounted resource
84 to which the line in \fBmnttab\fR corresponds. The \fBgetextmntent()\fR
85 function also fills in the \fBextmntent\fR structure defined in the
86 <\fBsys/mnttab.h\fR> header.  For \fBgetextmntent()\fR to function properly, it
87 must be notified when the \fBmnttab\fR file has been reopened or rewound since
88 a previous \fBgetextmntent()\fR call.  This notification is accomplished by
89 calling \fBresetmnttab()\fR. Otherwise, it behaves exactly as \fBgetmntent()\fR
90 described above
91 .sp
92 .LP
93 The data pointed to by the \fBmnttab\fR structure members are stored in a
94 static area and must be copied to be saved between successive calls.
95 .SS "\fBhasmntopt()\fR"
96 .sp
97 .LP
98 The \fBhasmntopt()\fR function scans the \fBmnt_mntopts\fR member of the
99 \fBmnttab\fR structure \fImnt\fR for a substring that matches \fIopt\fR. It
100 returns the address of the substring if a match is found; otherwise it returns
101 \fB0\fR. Substrings are delimited by commas and the end of the
102 \fBmnt_mntopts\fR string.
103 .SS "\fBputmntent()\fR"
106 The \fBputmntent()\fR function is obsolete and no longer has any effect.
107 Entries appear in \fBmnttab\fR as a side effect of a \fBmount\fR(2) call. The
108 function name is still defined for transition purposes.
109 .SS "\fBresetmnttab()\fR"
112 The \fBresetmnttab()\fR function notifies \fBgetextmntent()\fR to reload from
113 the kernel the device information that corresponds to the new snapshot of the
114 \fBmnttab\fR information (see \fBmnttab\fR(4)). Subsequent \fBgetextmntent()\fR
115 calls then return correct \fBextmnttab\fR information. This function should be
116 called whenever the \fBmnttab\fR file is either rewound or closed and reopened
117 before any calls are made to \fBgetextmntent()\fR.
118 .SH RETURN VALUES
119 .SS "\fBgetmntent()\fR and \fBgetmntany()\fR"
122 If the next entry is successfully read by \fBgetmntent()\fR or a match is found
123 with \fBgetmntany()\fR, \fB0\fR is returned.  If an \fBEOF\fR is encountered on
124 reading, these functions return \fB\(mi1\fR\&. If an error is encountered, a
125 value greater than 0 is returned. The following error values are defined in
126 \fB<sys/mnttab.h>\fR:
128 .ne 2
130 \fB\fBMNT_TOOLONG\fR\fR
132 .RS 15n
133 A line in the file exceeded the internal buffer size of \fBMNT_LINE_MAX\fR.
137 .ne 2
139 \fB\fBMNT_TOOMANY\fR\fR
141 .RS 15n
142 A line in the file contains too many fields.
146 .ne 2
148 \fB\fBMNT_TOOFEW\fR\fR
150 .RS 15n
151 A line in the file contains too few fields.
154 .SS "\fBhasmntopt()\fR"
157 Upon successful completion, \fBhasmntopt()\fR returns the address of the
158 substring if a match is found. Otherwise, it returns \fB0\fR.
159 .SS "\fBputmntent()\fR"
162 The \fBputmntent()\fR is obsolete and always returns \fB\(mi1\fR\&.
163 .SH ATTRIBUTES
166 See \fBattributes\fR(5) for descriptions of the following attributes:
171 box;
172 c | c
173 l | l .
174 ATTRIBUTE TYPE  ATTRIBUTE VALUE
176 MT-Level        Safe
179 .SH SEE ALSO
182 \fBmount\fR(2), \fBmnttab\fR(4), \fBattributes\fR(5)