OSDN Git Service

(split) LDP: Change Makefile to stamp-based compilation
[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 \fIstruct fstab\fP is defined by:
46 .LP
47 .in +4n
48 .nf
49 struct fstab {
50     char       *fs_spec;       /* block device name */
51     char       *fs_file;       /* mount point */
52     char       *fs_vfstype;    /* file-sysem type */
53     char       *fs_mntops;     /* mount options */
54     const char *fs_type;       /* rw/rq/ro/sw/xx option */
55     int         fs_freq;       /* dump frequency, in days */
56     int         fs_passno;     /* pass number on parallel dump */
57 };
58 .fi
59 .in
60 .PP
61 Here the field
62 .I fs_type
63 contains (on a *BSD system)
64 one of the five strings "rw", "rq", "ro", "sw", "xx"
65 (read-write, read-write with quota, read-only, swap, ignore).
66
67 The function
68 .BR setfsent ()
69 opens the file when required and positions it at the first line.
70 .LP
71 The function
72 .BR getfsent ()
73 parses the next line from the file.
74 (After opening it when required.)
75 .LP
76 The function
77 .BR endfsent ()
78 closes the file when required.
79 .LP
80 The function
81 .BR getfsspec ()
82 searches the file from the start and returns the first entry found
83 for which the
84 .I fs_spec
85 field matches the
86 .I special_file
87 argument.
88 .LP
89 The function
90 .BR getfsfile ()
91 searches the file from the start and returns the first entry found
92 for which the
93 .I fs_file
94 field matches the
95 .I mount_point
96 argument.
97 .SH RETURN VALUE
98 Upon success, the functions
99 .BR getfsent (),
100 .BR getfsfile (),
101 and
102 .BR getfsspec ()
103 return a pointer to a \fIstruct fstab\fP, while
104 .BR setfsent ()
105 returns 1.
106 Upon failure or end-of-file, these functions return NULL and 0, respectively.
107 .\" .SH HISTORY
108 .\" The
109 .\" .BR getfsent ()
110 .\" function appeared in 4.0BSD; the other four functions appeared in 4.3BSD.
111 .SH CONFORMING TO
112 These functions are not in POSIX.1-2001.
113 Several operating systems have them,
114 e.g., *BSD, SunOS, Digital UNIX, AIX (which also has a
115 .BR getfstype ()).
116 HP-UX has functions of the same names,
117 that however use a \fIstruct checklist\fP
118 instead of a \fIstruct fstab\fP,
119 and calls these functions obsolete, superseded by
120 .BR getmntent (3).
121 .SH NOTES
122 These functions are not thread-safe.
123 .LP
124 Since Linux allows mounting a block special device in several places,
125 and since several devices can have the same mount point, where the
126 last device with a given mount point is the interesting one,
127 while
128 .BR getfsfile ()
129 and
130 .BR getfsspec ()
131 only return the first occurrence, these two functions are not suitable
132 for use under Linux.
133 .SH SEE ALSO
134 .BR getmntent (3),
135 .BR fstab (5)