-
Notifications
You must be signed in to change notification settings - Fork 4
/
part1-4-1.xml
242 lines (242 loc) · 8.1 KB
/
part1-4-1.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xml; charset=utf-8"/>
<title>Case Study</title>
<link rel="stylesheet" href="css/book.css" type="text/css"/>
</head>
<body>
<h3>
Case Study
</h3>
<p>
I now introduce a case study of a real-world system call manual, in particular the manual for the <span
class="func">fsync</span> function from <a class="term" href="glossary.xml#openbsd">OpenBSD</a>. The
original file may be viewed on-line at <a class="external"
href="http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/sys/fsync.2">src/lib/libc/sys/fsync.2</a>, file version
1.9.
</p>
<div class="mdocin">
.\" $​OpenBSD: fsync.2,v 1.9 2011/04/29 07:12:44 jmc Exp $
<br />
.\" $​NetBSD: fsync.2,v 1.4 1995/02/27 12:32:38 cgd Exp $
<br />
.\"
<br />
.\" Copyright (c) 1983, 1993
<br />
.\" The Regents of the University of California. All rights reserved.
<br />
.\"
<br />
.\" Redistribution and use in source and binary forms, with or without
<br />
.\" modification, are permitted provided that the following conditions
<br />
.\" are met:
<br />
.\" 1. Redistributions of source code must retain the above copyright
<br />
.\" notice, this list of conditions and the following disclaimer.
<br />
.\" 2. Redistributions in binary form must reproduce the above copyright
<br />
.\" notice, this list of conditions and the following disclaimer in the
<br />
.\" documentation and/or other materials provided with the distribution.
<br />
.\" 3. Neither the name of the University nor the names of its contributors
<br />
.\" may be used to endorse or promote products derived from this software
<br />
.\" without specific prior written permission.
<br />
.\"
<br />
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
<br />
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<br />
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
<br />
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
<br />
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<br />
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
<br />
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
<br />
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
<br />
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
<br />
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
<br />
.\" SUCH DAMAGE.
<br />
.\"
<br />
.\" @(#)fsync.2 8.1 (Berkeley) 6/4/93
</div>
<p>
The <a href="commands.xml#cmd_cvs" class="cmd">cvs</a> identifiers (both from the current system, <a class="term"
href="glossary.xml#openbsd">OpenBSD</a>, and the import source system, <a class="term"
href="glossary.xml#netbsd">NetBSD</a>), copyright, license, and <a href="commands.xml#cmd_sccs"
class="cmd">sccs</a> identifier (from the original system) are presented in the usual way: the the <span
class="screen">$​OpenBSD$</span> and <span class="screen">$​NetBSD$</span> lines are automatically
updated by the revision control system, <a href="commands.xml#cmd_cvs" class="cmd">cvs</a>, whenever an update to the
file is committed. The line following is the copyright message, and following that is the text form of the <a
class="term" href="glossary.xml#bsd_license">BSD license</a>.
</p>
<div class="mdocin">
.Dd $​Mdocdate: April 29 2011 $
<br />
.Dt FSYNC 2
<br />
.Os
</div>
<p>
The manual's last-modified date is maintained with the automatically-updated <span
class="screen">$​Mdocdate$</span> sequence. Its title is set to the single function's capitalised form,
category <span class="cat">2</span> for system calls under the current operating system.
</p>
<div class="mdocin">
.Sh NAME
<br />
.Nm fsync
<br />
.Nd "synchronize a file's in-core state with that on disk"
</div>
<p>
The <a href="macros.xml#macro_nd" class="macro">Nd</a> macro's arguments are superfluously quoted again.
</p>
<div class="mdocin">
.Sh SYNOPSIS
<br />
.Fd #include <unistd.h>
<br />
.Ft int
<br />
.Fn fsync "int fd"
</div>
<p>
Again, in historical manuals, <a href="macros.xml#macro_fd" class="macro">Fd</a> is sometimes used instead of the
modern <a href="macros.xml#macro_in" class="macro">In</a> macro. Note also the inclusion of the function argument's
name, <span class="screen">fd</span>, where regular C prototypes would usually only include the type.
</p>
<div class="mdocin">
.Sh DESCRIPTION
<br />
.Fn fsync
<br />
causes all modified data and attributes of
<br />
.Fa fd
<br />
to be moved to a permanent storage device.
<br />
This normally results in all in-core modified copies
<br />
of buffers for the associated file to be written to a disk.
<br />
.Pp
<br />
.Fn fsync
<br />
should be used by programs that require a file to be in a known state,
<br />
for example, in building a simple transaction facility.
</div>
<p>
Since <span class="func">fsync</span> is a simple function, its description is fairly straightforward. The single
function argument <span class="screen">fd</span> is fully described as well.
</p>
<div class="mdocin">
<br />
.Sh RETURN VALUES
<br />
A 0 value is returned on success.
<br />
A \-1 value indicates an error.
</div>
<p>
This is not correct, as it omits information on the <span class="var">errno</span> global error being set. The <a
href="macros.xml#macro_rv" class="macro">Rv</a> macro should be used instead.
</p>
<div class="mdocin">
.Sh ERRORS
<br />
The
<br />
.Fn fsync
<br />
fails if:
<br />
.Bl -tag -width Er
<br />
.It Bq Er EBADF
<br />
.Fa fd
<br />
is not a valid descriptor.
<br />
.It Bq Er EINVAL
<br />
.Fa fd
<br />
refers to a socket, not to a file.
<br />
.It Bq Er EIO
<br />
An I/O error occurred while reading from or writing to the file system.
<br />
.El
</div>
<p>
Most (if not all) system calls set the <span class="var">errno</span> global error upon failure. This, erroneously, was
not mentioned in the <span class="sec">RETURN VALUES</span> section, but is documented here.
</p>
<div class="mdocin">
.Sh SEE ALSO
<br />
.Xr sync 2 ,
<br />
.Xr sync 8
<br />
.Sh HISTORY
<br />
The
<br />
.Fn fsync
<br />
function call appeared in
<br />
.Bx 4.2 .
</div>
<p>
Note that the cross-references in <span class="sec">SEE ALSO</span> are ordered first by section, then alphabetically.
The <a href="macros.xml#macro_bx" class="macro">Bx</a> is referenced as the origin of the system call. The <span
class="sec">STANDARDS</span> section is sorely missing, as <span class="func">fsync</span> is a function
specified by <a href="glossary.xml#posix" class="term">POSIX</a>.1-2008 standard.
</p>
<p>
We again found several inconsistent uses of <span class="lang">mdoc</span> in this case study. Let this serve as a
reminder that if you find bad or unusual <span class="lang">mdoc</span> in your manuals, notify the authors! A bug in a
manual is just as important as a bug in the code.
</p>
<table class="nav">
<tbody>
<tr>
<td class="nav-contents"><a href="toc.xml">Contents</a></td>
<td class="nav-next"><a href="part2.xml">Next</a></td>
<td class="nav-home"><a href="http://manpages.bsd.lv/index.html">Home</a></td>
<td class="nav-history"><a href="http://manpages.bsd.lv/cgi-bin/cvsweb/part1-4-1.xml?cvsroot=manpages">History</a></td>
</tr>
</tbody>
</table>
<p class="edits">
Last edited by $Author$ on $Date$. Copyright © 2011, Kristaps Dzonsons. CC BY-SA.
</p>
</body>
</html>