xref: /freebsd/share/examples/mdoc/example.9 (revision 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
1fff9b474SMateusz Piotrowski.\"
2*4d846d26SWarner Losh.\" SPDX-License-Identifier: BSD-2-Clause
3fff9b474SMateusz Piotrowski.\"
4496ff35dSGiorgos Keramidas.\" Copyright (c) [year] [your name]
5496ff35dSGiorgos Keramidas.\"
6496ff35dSGiorgos Keramidas.\" Redistribution and use in source and binary forms, with or without
7496ff35dSGiorgos Keramidas.\" modification, are permitted provided that the following conditions
8496ff35dSGiorgos Keramidas.\" are met:
9496ff35dSGiorgos Keramidas.\" 1. Redistributions of source code must retain the above copyright
10496ff35dSGiorgos Keramidas.\"    notice, this list of conditions and the following disclaimer.
11496ff35dSGiorgos Keramidas.\" 2. Redistributions in binary form must reproduce the above copyright
12496ff35dSGiorgos Keramidas.\"    notice, this list of conditions and the following disclaimer in the
13496ff35dSGiorgos Keramidas.\"    documentation and/or other materials provided with the distribution.
14496ff35dSGiorgos Keramidas.\"
15496ff35dSGiorgos Keramidas.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16496ff35dSGiorgos Keramidas.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17496ff35dSGiorgos Keramidas.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18496ff35dSGiorgos Keramidas.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19496ff35dSGiorgos Keramidas.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20496ff35dSGiorgos Keramidas.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21496ff35dSGiorgos Keramidas.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22496ff35dSGiorgos Keramidas.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23496ff35dSGiorgos Keramidas.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24496ff35dSGiorgos Keramidas.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25496ff35dSGiorgos Keramidas.\" SUCH DAMAGE.
26496ff35dSGiorgos Keramidas.\"
27496ff35dSGiorgos Keramidas.\" Note: The date here should be updated whenever a non-trivial
28496ff35dSGiorgos Keramidas.\" change is made to the manual page.
29e5cccaf0SPawel Jakub Dawidek.Dd September 27, 2006
30496ff35dSGiorgos Keramidas.Dt EXAMPLE 9
31496ff35dSGiorgos Keramidas.Os
32496ff35dSGiorgos Keramidas.Sh NAME
33496ff35dSGiorgos Keramidas.Nm example
34496ff35dSGiorgos Keramidas.Nd "example kernel interface manual page"
35496ff35dSGiorgos Keramidas.Sh SYNOPSIS
36bff0341eSJoseph Koshy.In sys/example.h
37496ff35dSGiorgos Keramidas.Ft int
38496ff35dSGiorgos Keramidas.Fn example "char *ptr" "int mode"
39496ff35dSGiorgos Keramidas.Sh DESCRIPTION
40bff0341eSJoseph KoshyThis is an example manual page for the
41496ff35dSGiorgos Keramidas.Fn example
42496ff35dSGiorgos Keramidaskernel function.
43496ff35dSGiorgos KeramidasIt is intended that this example can be used as a template
44496ff35dSGiorgos Keramidaswhen writing a new manual page.
45496ff35dSGiorgos Keramidas.Pp
46496ff35dSGiorgos KeramidasThe
47496ff35dSGiorgos Keramidas.Fn example
48496ff35dSGiorgos Keramidasfunction takes two arguments:
49496ff35dSGiorgos Keramidas.Fa ptr
50496ff35dSGiorgos Keramidasand
51496ff35dSGiorgos Keramidas.Fa mode .
52496ff35dSGiorgos KeramidasThe argument
53496ff35dSGiorgos Keramidas.Fa mode
54496ff35dSGiorgos Keramidasmay have one of the following values:
551fb04df9SMateusz Piotrowski.Bl -tag -width "EXAMPLE_ONE"
56496ff35dSGiorgos Keramidas.It Dv EXAMPLE_ONE
57496ff35dSGiorgos KeramidasFirst example of a defined variable.
58496ff35dSGiorgos Keramidas.Dv EXAMPLE_ONE
59496ff35dSGiorgos Keramidasis described below.
60496ff35dSGiorgos Keramidas.It Dv EXAMPLE_TWO
61496ff35dSGiorgos KeramidasSecond example.
62496ff35dSGiorgos Keramidas.El
63496ff35dSGiorgos Keramidas.Pp
64496ff35dSGiorgos KeramidasThe above values are defined in
65496ff35dSGiorgos Keramidas.In example.h
66496ff35dSGiorgos Keramidasas follows:
67496ff35dSGiorgos Keramidas.Bd -literal
68496ff35dSGiorgos Keramidas#define EXAMPLE_ONE  1
69496ff35dSGiorgos Keramidas#define EXAMPLE_TWO  2
70496ff35dSGiorgos Keramidas.Ed
71496ff35dSGiorgos Keramidas.Sh IMPLEMENTATION NOTES
72496ff35dSGiorgos KeramidasThe
73496ff35dSGiorgos Keramidas.Fn example
74496ff35dSGiorgos Keramidasfunction is not actually implemented.
75bff0341eSJoseph Koshy.Sh LOCKING
76bff0341eSJoseph KoshyThe
77bff0341eSJoseph Koshy.Va example_lock
78bff0341eSJoseph Koshylock must be held before
79bff0341eSJoseph Koshy.Fn example
80bff0341eSJoseph Koshyis called.
81bff0341eSJoseph Koshy.Pp
82bff0341eSJoseph KoshySince
83bff0341eSJoseph Koshy.Va example_lock
84bff0341eSJoseph Koshyis a
85bff0341eSJoseph Koshy.Xr mutex 9 ,
86bff0341eSJoseph Koshyno sleepable locks (i.e.,
87bff0341eSJoseph Koshy.Xr sx 9
88bff0341eSJoseph Koshylocks) can be acquired in
89bff0341eSJoseph Koshy.Fn example .
90496ff35dSGiorgos Keramidas.Sh RETURN VALUES
91496ff35dSGiorgos KeramidasThe
92496ff35dSGiorgos Keramidas.Fn example
93496ff35dSGiorgos Keramidasfunction returns the value 0 if successful;
94496ff35dSGiorgos Keramidasotherwise one of the values listed in the
95496ff35dSGiorgos Keramidas.Sx ERRORS
96496ff35dSGiorgos Keramidassection is returned, to indicate the error.
97496ff35dSGiorgos Keramidas.Sh EXAMPLES
98496ff35dSGiorgos Keramidas.Bd -literal
99e5cccaf0SPawel Jakub Dawidek	int error;
100496ff35dSGiorgos Keramidas
101e5cccaf0SPawel Jakub Dawidek	mtx_lock(&example_lock);
102e5cccaf0SPawel Jakub Dawidek	if ((error = example(NULL, EXAMPLE_ONE)) != 0) {
103e5cccaf0SPawel Jakub Dawidek		mtx_unlock(&example_lock);
104e5cccaf0SPawel Jakub Dawidek		return (error);
105bff0341eSJoseph Koshy	}
106e5cccaf0SPawel Jakub Dawidek	mtx_unlock(&example_lock);
107496ff35dSGiorgos Keramidas.Ed
108496ff35dSGiorgos Keramidas.Sh COMPATIBILITY
109496ff35dSGiorgos KeramidasThe
110496ff35dSGiorgos Keramidas.Fn example
111496ff35dSGiorgos Keramidasfunction has no known compatibility issues.
112496ff35dSGiorgos Keramidas.Sh ERRORS
113496ff35dSGiorgos Keramidas.\" Delete any errno's that are not returned by your
114496ff35dSGiorgos Keramidas.\" function or system call and then tailor the
115496ff35dSGiorgos Keramidas.\" remaining text as needed.
116496ff35dSGiorgos KeramidasThe
117496ff35dSGiorgos Keramidas.Fn example
118496ff35dSGiorgos Keramidasfunction will fail if:
119496ff35dSGiorgos Keramidas.Bl -tag -width Er
120496ff35dSGiorgos Keramidas.It Bq Er EPERM
121496ff35dSGiorgos KeramidasOperation not permitted.
122496ff35dSGiorgos Keramidas.It Bq Er ENOENT
123496ff35dSGiorgos KeramidasNo such file or directory.
124496ff35dSGiorgos Keramidas.It Bq Er ESRCH
125496ff35dSGiorgos KeramidasNo such process.
126496ff35dSGiorgos Keramidas.It Bq Er EINTR
127496ff35dSGiorgos KeramidasInterrupted system call.
128496ff35dSGiorgos Keramidas.It Bq Er EIO
129496ff35dSGiorgos KeramidasInput/output error.
130496ff35dSGiorgos Keramidas.It Bq Er ENXIO
131496ff35dSGiorgos KeramidasDevice not configured.
132496ff35dSGiorgos Keramidas.It Bq Er E2BIG
133496ff35dSGiorgos KeramidasArgument list too long.
134496ff35dSGiorgos Keramidas.It Bq Er ENOEXEC
135496ff35dSGiorgos KeramidasExec format error.
136496ff35dSGiorgos Keramidas.It Bq Er EBADF
137496ff35dSGiorgos KeramidasBad file descriptor.
138496ff35dSGiorgos Keramidas.It Bq Er ECHILD
139496ff35dSGiorgos KeramidasNo child processes.
140496ff35dSGiorgos Keramidas.It Bq Er EDEADLK
141496ff35dSGiorgos KeramidasResource deadlock avoided.
142496ff35dSGiorgos Keramidas.It Bq Er ENOMEM
143496ff35dSGiorgos KeramidasCannot allocate memory.
144496ff35dSGiorgos Keramidas.It Bq Er EACCES
145496ff35dSGiorgos KeramidasPermission denied.
146496ff35dSGiorgos Keramidas.It Bq Er EFAULT
147496ff35dSGiorgos KeramidasBad address.
148496ff35dSGiorgos Keramidas.It Bq Er ENOTBLK
149496ff35dSGiorgos KeramidasBlock device required.
150496ff35dSGiorgos Keramidas.It Bq Er EBUSY
151496ff35dSGiorgos KeramidasDevice busy.
152496ff35dSGiorgos Keramidas.It Bq Er EEXIST
153496ff35dSGiorgos KeramidasFile exists.
154496ff35dSGiorgos Keramidas.It Bq Er EXDEV
155496ff35dSGiorgos KeramidasCross-device link.
156496ff35dSGiorgos Keramidas.It Bq Er ENODEV
157496ff35dSGiorgos KeramidasOperation not supported by device.
158496ff35dSGiorgos Keramidas.It Bq Er ENOTDIR
159496ff35dSGiorgos KeramidasNot a directory.
160496ff35dSGiorgos Keramidas.It Bq Er EISDIR
161496ff35dSGiorgos KeramidasIs a directory.
162496ff35dSGiorgos Keramidas.It Bq Er EINVAL
163496ff35dSGiorgos KeramidasInvalid argument.
164496ff35dSGiorgos Keramidas.It Bq Er ENFILE
165496ff35dSGiorgos KeramidasToo many open files in system.
166496ff35dSGiorgos Keramidas.It Bq Er EMFILE
167496ff35dSGiorgos KeramidasToo many open files.
168496ff35dSGiorgos Keramidas.It Bq Er ENOTTY
169496ff35dSGiorgos KeramidasInappropriate ioctl for device.
170496ff35dSGiorgos Keramidas.It Bq Er ETXTBSY
171496ff35dSGiorgos KeramidasText file busy.
172496ff35dSGiorgos Keramidas.It Bq Er EFBIG
173496ff35dSGiorgos KeramidasFile too large.
174496ff35dSGiorgos Keramidas.It Bq Er ENOSPC
175496ff35dSGiorgos KeramidasNo space left on device.
176496ff35dSGiorgos Keramidas.It Bq Er ESPIPE
177496ff35dSGiorgos KeramidasIllegal seek.
178496ff35dSGiorgos Keramidas.It Bq Er EROFS
179496ff35dSGiorgos KeramidasRead-only file system.
180496ff35dSGiorgos Keramidas.It Bq Er EMLINK
181496ff35dSGiorgos KeramidasToo many links.
182496ff35dSGiorgos Keramidas.It Bq Er EPIPE
183496ff35dSGiorgos KeramidasBroken pipe.
184496ff35dSGiorgos Keramidas.It Bq Er EDOM
185496ff35dSGiorgos KeramidasNumerical argument out of domain.
186496ff35dSGiorgos Keramidas.It Bq Er ERANGE
187496ff35dSGiorgos KeramidasResult too large.
188496ff35dSGiorgos Keramidas.It Bq Er EAGAIN
189496ff35dSGiorgos KeramidasResource temporarily unavailable.
190496ff35dSGiorgos Keramidas.It Bq Er EWOULDBLOCK
191496ff35dSGiorgos KeramidasOperation would block.
192496ff35dSGiorgos Keramidas.It Bq Er EINPROGRESS
193496ff35dSGiorgos KeramidasOperation now in progress.
194496ff35dSGiorgos Keramidas.It Bq Er EALREADY
195496ff35dSGiorgos KeramidasOperation already in progress.
196496ff35dSGiorgos Keramidas.It Bq Er ENOTSOCK
197496ff35dSGiorgos KeramidasSocket operation on non-socket.
198496ff35dSGiorgos Keramidas.It Bq Er EDESTADDRREQ
199496ff35dSGiorgos KeramidasDestination address required.
200496ff35dSGiorgos Keramidas.It Bq Er EMSGSIZE
201496ff35dSGiorgos KeramidasMessage too long.
202496ff35dSGiorgos Keramidas.It Bq Er EPROTOTYPE
203496ff35dSGiorgos KeramidasProtocol wrong type for socket.
204496ff35dSGiorgos Keramidas.It Bq Er ENOPROTOOPT
205496ff35dSGiorgos KeramidasProtocol not available.
206496ff35dSGiorgos Keramidas.It Bq Er EPROTONOSUPPORT
207496ff35dSGiorgos KeramidasProtocol not supported.
208496ff35dSGiorgos Keramidas.It Bq Er ESOCKTNOSUPPORT
209496ff35dSGiorgos KeramidasSocket type not supported.
210496ff35dSGiorgos Keramidas.It Bq Er EOPNOTSUPP
211496ff35dSGiorgos KeramidasOperation not supported.
212496ff35dSGiorgos Keramidas.It Bq Er EPFNOSUPPORT
213496ff35dSGiorgos KeramidasProtocol family not supported.
214496ff35dSGiorgos Keramidas.It Bq Er EAFNOSUPPORT
215496ff35dSGiorgos KeramidasAddress family not supported by protocol family.
216496ff35dSGiorgos Keramidas.It Bq Er EADDRINUSE
217496ff35dSGiorgos KeramidasAddress already in use.
218496ff35dSGiorgos Keramidas.It Bq Er EADDRNOTAVAIL
219496ff35dSGiorgos KeramidasCannot assign requested address.
220496ff35dSGiorgos Keramidas.It Bq Er ENETDOWN
221496ff35dSGiorgos KeramidasNetwork is down.
222496ff35dSGiorgos Keramidas.It Bq Er ENETUNREACH
223496ff35dSGiorgos KeramidasNetwork is unreachable.
224496ff35dSGiorgos Keramidas.It Bq Er ENETRESET
225496ff35dSGiorgos KeramidasNetwork dropped connection on reset.
226496ff35dSGiorgos Keramidas.It Bq Er ECONNABORTED
227496ff35dSGiorgos KeramidasSoftware causes connection abort.
228496ff35dSGiorgos Keramidas.It Bq Er ENOBUFS
229496ff35dSGiorgos KeramidasNo buffer space available.
230496ff35dSGiorgos Keramidas.It Bq Er EISCONN
231496ff35dSGiorgos KeramidasSocket is already connected.
232496ff35dSGiorgos Keramidas.It Bq Er ENOTCONN
233496ff35dSGiorgos KeramidasSocket is not connected.
234496ff35dSGiorgos Keramidas.It Bq Er ESHUTDOWN
235496ff35dSGiorgos KeramidasCannot send after socket shutdown.
236496ff35dSGiorgos Keramidas.It Bq Er ETOOMANYREFS
237496ff35dSGiorgos KeramidasToo many references: cannot splice.
238496ff35dSGiorgos Keramidas.It Bq Er ETIMEDOUT
239496ff35dSGiorgos KeramidasOperation timed out.
240496ff35dSGiorgos Keramidas.It Bq Er ECONNREFUSED
241496ff35dSGiorgos KeramidasConnection refused.
242496ff35dSGiorgos Keramidas.It Bq Er ELOOP
243496ff35dSGiorgos KeramidasToo many levels of symbolic links.
244496ff35dSGiorgos Keramidas.It Bq Er ENAMETOOLONG
245496ff35dSGiorgos KeramidasFile name too long.
246496ff35dSGiorgos Keramidas.It Bq Er EHOSTDOWN
247496ff35dSGiorgos KeramidasHost is down.
248496ff35dSGiorgos Keramidas.It Bq Er EHOSTUNREACH
249496ff35dSGiorgos KeramidasNo route to host.
250496ff35dSGiorgos Keramidas.It Bq Er ENOTEMPTY
251496ff35dSGiorgos KeramidasDirectory not empty.
252496ff35dSGiorgos Keramidas.It Bq Er EPROCLIM
253496ff35dSGiorgos KeramidasToo many processes.
254496ff35dSGiorgos Keramidas.It Bq Er EUSERS
255496ff35dSGiorgos KeramidasToo many users.
256496ff35dSGiorgos Keramidas.It Bq Er EDQUOT
257496ff35dSGiorgos KeramidasDisc quota exceeded.
258496ff35dSGiorgos Keramidas.It Bq Er ESTALE
259496ff35dSGiorgos KeramidasStale NFS file handle.
260496ff35dSGiorgos Keramidas.It Bq Er EREMOTE
261496ff35dSGiorgos KeramidasToo many levels of remote in path.
262496ff35dSGiorgos Keramidas.It Bq Er EBADRPC
263496ff35dSGiorgos KeramidasRPC struct is bad.
264496ff35dSGiorgos Keramidas.It Bq Er ERPCMISMATCH
265496ff35dSGiorgos KeramidasRPC version wrong.
266496ff35dSGiorgos Keramidas.It Bq Er EPROGUNAVAIL
267496ff35dSGiorgos KeramidasRPC program not available.
268496ff35dSGiorgos Keramidas.It Bq Er EPROGMISMATCH
269496ff35dSGiorgos KeramidasProgram version wrong.
270496ff35dSGiorgos Keramidas.It Bq Er EPROCUNAVAIL
271496ff35dSGiorgos KeramidasBad procedure for program.
272496ff35dSGiorgos Keramidas.It Bq Er ENOLCK
273496ff35dSGiorgos KeramidasNo locks available.
274496ff35dSGiorgos Keramidas.It Bq Er ENOSYS
275496ff35dSGiorgos KeramidasFunction not implemented.
276496ff35dSGiorgos Keramidas.It Bq Er EFTYPE
277496ff35dSGiorgos KeramidasInappropriate file type or format.
278496ff35dSGiorgos Keramidas.It Bq Er EAUTH
279496ff35dSGiorgos KeramidasAuthentication error.
280496ff35dSGiorgos Keramidas.It Bq Er ENEEDAUTH
281496ff35dSGiorgos KeramidasNeed authenticator.
282496ff35dSGiorgos Keramidas.It Bq Er EIDRM
283496ff35dSGiorgos KeramidasIdentifier removed.
284496ff35dSGiorgos Keramidas.It Bq Er ENOMSG
285496ff35dSGiorgos KeramidasNo message of desired type.
286496ff35dSGiorgos Keramidas.It Bq Er EOVERFLOW
287496ff35dSGiorgos KeramidasValue too large to be stored in data type.
288496ff35dSGiorgos Keramidas.It Bq Er ECANCELED
289496ff35dSGiorgos KeramidasOperation canceled.
290496ff35dSGiorgos Keramidas.It Bq Er EILSEQ
291496ff35dSGiorgos KeramidasIllegal byte sequence.
292496ff35dSGiorgos Keramidas.It Bq Er ENOATTR
293496ff35dSGiorgos KeramidasAttribute not found.
294496ff35dSGiorgos Keramidas.It Bq Er EDOOFUS
295496ff35dSGiorgos KeramidasProgramming error.
296496ff35dSGiorgos Keramidas.El
297496ff35dSGiorgos Keramidas.Sh SEE ALSO
298496ff35dSGiorgos Keramidas.Xr example 1 ,
299496ff35dSGiorgos Keramidas.Xr example 3 ,
300496ff35dSGiorgos Keramidas.Xr example 4 ,
301e5cccaf0SPawel Jakub Dawidek.Xr mdoc 7 ,
302e5cccaf0SPawel Jakub Dawidek.Xr mutex 9
303496ff35dSGiorgos Keramidas.Rs
304496ff35dSGiorgos Keramidas.%A "A. B. Author"
305496ff35dSGiorgos Keramidas.%T "Example RFC Title"
306496ff35dSGiorgos Keramidas.%O RFC0000
307496ff35dSGiorgos Keramidas.Re
308496ff35dSGiorgos Keramidas.Rs
309496ff35dSGiorgos Keramidas.%A "A. B. Author"
310496ff35dSGiorgos Keramidas.%B "Example Book Title"
311496ff35dSGiorgos Keramidas.%O ISBN-0-000-00000-0
312496ff35dSGiorgos Keramidas.Re
313496ff35dSGiorgos Keramidas.Rs
314496ff35dSGiorgos Keramidas.%A "A. B. Author"
315496ff35dSGiorgos Keramidas.%D "January 1997"
316496ff35dSGiorgos Keramidas.%J "Example Journal Name"
317496ff35dSGiorgos Keramidas.%T "Example Article Title"
318496ff35dSGiorgos Keramidas.Re
319496ff35dSGiorgos Keramidas.Sh HISTORY
320496ff35dSGiorgos KeramidasThe
321496ff35dSGiorgos Keramidas.Nm
322496ff35dSGiorgos Keramidasmanual page example first appeared in
323496ff35dSGiorgos Keramidas.Fx 6.0 .
324496ff35dSGiorgos Keramidas.Pp
325496ff35dSGiorgos KeramidasSome other common
326496ff35dSGiorgos Keramidas.Sx HISTORY
327496ff35dSGiorgos Keramidassection examples are:
328496ff35dSGiorgos Keramidas.Pp
329496ff35dSGiorgos KeramidasThe
330496ff35dSGiorgos Keramidas.Nm
331496ff35dSGiorgos Keramidasmanual page example first appeared in
332496ff35dSGiorgos Keramidas.Bx 4.4 .
333496ff35dSGiorgos Keramidas.Pp
334496ff35dSGiorgos KeramidasThe
335496ff35dSGiorgos Keramidas.Nm
336496ff35dSGiorgos Keramidasmanual page example first appeared in
337496ff35dSGiorgos Keramidas.At v6 .
338496ff35dSGiorgos Keramidas.Sh AUTHORS
339496ff35dSGiorgos KeramidasThis
340496ff35dSGiorgos Keramidasmanual page was written by
341bd0891ceSBaptiste Daroussin.An Giorgos Keramidas Aq Mt keramida@FreeBSD.org .
342496ff35dSGiorgos Keramidas.Sh BUGS
343496ff35dSGiorgos KeramidasThe actual code for this function is vaporware.
344