1.\" $OpenBSD: getfsent.3,v 1.13 2014/01/21 03:15:45 schwarze Exp $ 2.\" 3.\" Copyright (c) 1983, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.Dd $Mdocdate: January 21 2014 $ 31.Dt GETFSENT 3 32.Os 33.Sh NAME 34.Nm getfsent , 35.Nm getfsspec , 36.Nm getfsfile , 37.Nm setfsent , 38.Nm endfsent 39.Nd get file system descriptor file entry 40.Sh SYNOPSIS 41.In fstab.h 42.Ft struct fstab * 43.Fn getfsent void 44.Ft struct fstab * 45.Fn getfsspec "const char *spec" 46.Ft struct fstab * 47.Fn getfsfile "const char *file" 48.Ft int 49.Fn setfsent void 50.Ft void 51.Fn endfsent void 52.Sh DESCRIPTION 53The 54.Fn getfsent , 55.Fn getfsspec , 56and 57.Fn getfsfile 58functions each return a pointer to an object with the following structure 59containing the broken-out fields of a line in the file system 60description file, 61.In fstab.h . 62.Bd -literal -offset indent 63struct fstab { 64 char *fs_spec; /* block special device name */ 65 char *fs_file; /* file system path prefix */ 66 char *fs_vfstype; /* type of file system */ 67 char *fs_mntops; /* comma separated mount options */ 68 char *fs_type; /* rw, ro, sw, or xx */ 69 int fs_freq; /* dump frequency, in days */ 70 int fs_passno; /* pass number on parallel fsck */ 71}; 72.Ed 73.Pp 74The fields have meanings described in 75.Xr fstab 5 . 76.Pp 77.Fn setfsent 78opens the file (closing any previously opened file) or rewinds it 79if it is already open. 80.Pp 81.Fn endfsent 82closes the file. 83.Pp 84The 85.Fn getfsspec 86and 87.Fn getfsfile 88functions search the entire file (opening it if necessary) for a matching 89special file name or file system file name. 90.Pp 91For programs wishing to read the entire database, 92.Fn getfsent 93reads the next entry (opening the file if necessary). 94.Pp 95All entries in the file with a type field equivalent to 96.Dv FSTAB_XX 97are ignored. 98Lines which are formatted incorrectly are silently ignored. 99.Sh RETURN VALUES 100The 101.Fn getfsent , 102.Fn getfsspec , 103and 104.Fn getfsfile 105functions return a null pointer on 106.Dv EOF 107or error. 108The 109.Fn setfsent 110function returns 0 on failure or 1 on success. 111The 112.Fn endfsent 113function returns nothing. 114.Sh FILES 115.Bl -tag -width /etc/fstab -compact 116.It Pa /etc/fstab 117file system table 118.El 119.Sh SEE ALSO 120.Xr fstab 5 121.Sh HISTORY 122The 123.Fn getfsent 124function appeared in 125.Bx 4.0 ; 126the 127.Fn endfsent , 128.Fn getfsfile , 129.Fn getfsspec , 130and 131.Fn setfsent 132functions appeared in 133.Bx 4.3 . 134.Sh BUGS 135These functions use static data storage; if the data is needed for future use, 136it should be copied before any subsequent calls overwrite it. 137