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