man-pages/man3/getfsent.3.html
2021-03-31 01:06:50 +01:00

245 lines
5.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GETFSENT</TITLE>
</HEAD><BODY>
<H1>GETFSENT</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
getfsent, getfsspec, getfsfile, setfsent, endfsent - handle fstab entries
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A HREF="file:///usr/include/fstab.h">fstab.h</A>&gt;</B>
<P>
<B>void endfsent(void);</B>
<P>
<B>struct fstab *getfsent(void);</B>
<P>
<B>struct fstab *getfsfile(const char *</B><I>mount_point</I><B>);</B>
<P>
<B>struct fstab *getfsspec(const char *</B><I>special_file</I><B>);</B>
<P>
<B>int setfsent(void);</B>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
These functions read from the file
<I>/etc/fstab</I>.
The
<I>struct fstab</I>
is defined by:
<P>
struct fstab {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*fs_spec;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;block&nbsp;device&nbsp;name&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*fs_file;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;mount&nbsp;point&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*fs_vfstype;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;file-system&nbsp;type&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*fs_mntops;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;mount&nbsp;options&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;char&nbsp;*fs_type;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;rw/rq/ro/sw/xx&nbsp;option&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fs_freq;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;dump&nbsp;frequency,&nbsp;in&nbsp;days&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fs_passno;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;pass&nbsp;number&nbsp;on&nbsp;parallel&nbsp;dump&nbsp;*/
};
<P>
Here the field
<I>fs_type</I>
contains (on a *BSD system)
one of the five strings &quot;rw&quot;, &quot;rq&quot;, &quot;ro&quot;, &quot;sw&quot;, &quot;xx&quot;
(read-write, read-write with quota, read-only, swap, ignore).
<P>
The function
<B>setfsent</B>()
opens the file when required and positions it at the first line.
<P>
The function
<B>getfsent</B>()
parses the next line from the file.
(After opening it when required.)
<P>
The function
<B>endfsent</B>()
closes the file when required.
<P>
The function
<B>getfsspec</B>()
searches the file from the start and returns the first entry found
for which the
<I>fs_spec</I>
field matches the
<I>special_file</I>
argument.
<P>
The function
<B>getfsfile</B>()
searches the file from the start and returns the first entry found
for which the
<I>fs_file</I>
field matches the
<I>mount_point</I>
argument.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
Upon success, the functions
<B>getfsent</B>(),
<B>getfsfile</B>(),
and
<B>getfsspec</B>()
return a pointer to a
<I>struct fstab</I>,
while
<B>setfsent</B>()
returns 1.
Upon failure or end-of-file, these functions return NULL and 0, respectively.
<A NAME="lbAF">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>endfsent</B>(),
<BR>
<B>setfsent</B>()
</TD><TD>Thread safety</TD><TD>MT-Unsafe race:fsent<BR></TD></TR>
<TR VALIGN=top><TD>
<B>getfsent</B>(),
<BR>
<B>getfsspec</B>(),
<BR>
<B>getfsfile</B>()
</TD><TD>Thread safety</TD><TD>MT-Unsafe race:fsent locale<BR></TD></TR>
</TABLE>
<A NAME="lbAG">&nbsp;</A>
<H2>CONFORMING TO</H2>
These functions are not in POSIX.1.
Several operating systems have them, for example,
*BSD, SunOS, Digital UNIX, AIX (which also has a
<B>getfstype</B>()).
HP-UX has functions of the same names,
that however use a
<I>struct checklist</I>
instead of a
<I>struct fstab</I>,
and calls these functions obsolete, superseded by
<B><A HREF="/cgi-bin/man/man2html?3+getmntent">getmntent</A></B>(3).
<A NAME="lbAH">&nbsp;</A>
<H2>NOTES</H2>
These functions are not thread-safe.
<P>
Since Linux allows mounting a block special device in several places,
and since several devices can have the same mount point, where the
last device with a given mount point is the interesting one,
while
<B>getfsfile</B>()
and
<B>getfsspec</B>()
only return the first occurrence, these two functions are not suitable
for use under Linux.
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+getmntent">getmntent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?5+fstab">fstab</A></B>(5)
<A NAME="lbAJ">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="5"><A HREF="#lbAF">ATTRIBUTES</A><DD>
<DT id="6"><A HREF="#lbAG">CONFORMING TO</A><DD>
<DT id="7"><A HREF="#lbAH">NOTES</A><DD>
<DT id="8"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="9"><A HREF="#lbAJ">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:44 GMT, March 31, 2021
</BODY>
</HTML>