OSDN Git Service

5dc23554289ade8edeb0d95a874a44b67c32497a
[linuxjm/LDP_man-pages.git] / original / man3 / getfsent.3
1 .\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Inspired by a page written by Walter Harms.
26 .\"
27 .TH GETFSENT 3 2002-02-28 "GNU" "Linux Programmer's Manual"
28 .SH NAME
29 getfsent, getfsspec, getfsfile, setfsent, endfsent \- handle fstab entries
30 .SH SYNOPSIS
31 .B #include <fstab.h>
32 .sp
33 .B "void endfsent(void);"
34 .sp
35 .B "struct fstab *getfsent(void);"
36 .sp
37 .BI "struct fstab *getfsfile(const char *" mount_point );
38 .sp
39 .BI "struct fstab *getfsspec(const char *" special_file );
40 .sp
41 .B "int setfsent(void);"
42 .SH DESCRIPTION
43 These functions read from the file
44 .IR /etc/fstab .
45 The
46 .IR "struct fstab"
47 is defined by:
48 .LP
49 .in +4n
50 .nf
51 struct fstab {
52     char       *fs_spec;       /* block device name */
53     char       *fs_file;       /* mount point */
54     char       *fs_vfstype;    /* file-system type */
55     char       *fs_mntops;     /* mount options */
56     const char *fs_type;       /* rw/rq/ro/sw/xx option */
57     int         fs_freq;       /* dump frequency, in days */
58     int         fs_passno;     /* pass number on parallel dump */
59 };
60 .fi
61 .in
62 .PP
63 Here the field
64 .I fs_type
65 contains (on a *BSD system)
66 one of the five strings "rw", "rq", "ro", "sw", "xx"
67 (read-write, read-write with quota, read-only, swap, ignore).
68
69 The function
70 .BR setfsent ()
71 opens the file when required and positions it at the first line.
72 .LP
73 The function
74 .BR getfsent ()
75 parses the next line from the file.
76 (After opening it when required.)
77 .LP
78 The function
79 .BR endfsent ()
80 closes the file when required.
81 .LP
82 The function
83 .BR getfsspec ()
84 searches the file from the start and returns the first entry found
85 for which the
86 .I fs_spec
87 field matches the
88 .I special_file
89 argument.
90 .LP
91 The function
92 .BR getfsfile ()
93 searches the file from the start and returns the first entry found
94 for which the
95 .I fs_file
96 field matches the
97 .I mount_point
98 argument.
99 .SH RETURN VALUE
100 Upon success, the functions
101 .BR getfsent (),
102 .BR getfsfile (),
103 and
104 .BR getfsspec ()
105 return a pointer to a
106 .IR "struct fstab" ,
107 while
108 .BR setfsent ()
109 returns 1.
110 Upon failure or end-of-file, these functions return NULL and 0, respectively.
111 .\" .SH HISTORY
112 .\" The
113 .\" .BR getfsent ()
114 .\" function appeared in 4.0BSD; the other four functions appeared in 4.3BSD.
115 .SH CONFORMING TO
116 These functions are not in POSIX.1-2001.
117 Several operating systems have them, for example,
118 *BSD, SunOS, Digital UNIX, AIX (which also has a
119 .BR getfstype ()).
120 HP-UX has functions of the same names,
121 that however use a
122 .IR "struct checklist"
123 instead of a
124 .IR "struct fstab" ,
125 and calls these functions obsolete, superseded by
126 .BR getmntent (3).
127 .SH NOTES
128 These functions are not thread-safe.
129 .LP
130 Since Linux allows mounting a block special device in several places,
131 and since several devices can have the same mount point, where the
132 last device with a given mount point is the interesting one,
133 while
134 .BR getfsfile ()
135 and
136 .BR getfsspec ()
137 only return the first occurrence, these two functions are not suitable
138 for use under Linux.
139 .SH SEE ALSO
140 .BR getmntent (3),
141 .BR fstab (5)
142 .SH COLOPHON
143 This page is part of release 3.67 of the Linux
144 .I man-pages
145 project.
146 A description of the project,
147 information about reporting bugs,
148 and the latest version of this page,
149 can be found at
150 \%http://www.kernel.org/doc/man\-pages/.