console_codes.4: tfix
[man-pages.git] / man2 / io_setup.2
blob1e3cdd6e1904644fbb8a02e573c9ba26b5dd5d61
1 .\" Copyright (C) 2003 Free Software Foundation, Inc.
2 .\"
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" This file is distributed according to the GNU General Public License.
5 .\" %%%LICENSE_END
6 .\"
7 .TH IO_SETUP 2 2021-03-22 "Linux" "Linux Programmer's Manual"
8 .SH NAME
9 io_setup \- create an asynchronous I/O context
10 .SH SYNOPSIS
11 .nf
12 .BR "#include <linux/aio_abi.h>" "          /* Defines needed types */"
13 .PP
14 .BI "long io_setup(unsigned int " nr_events ", aio_context_t *" ctx_idp );
15 .fi
16 .PP
17 .IR Note :
18 There is no glibc wrapper for this system call; see NOTES.
19 .SH DESCRIPTION
20 .IR Note :
21 this page describes the raw Linux system call interface.
22 The wrapper function provided by
23 .I libaio
24 uses a different type for the
25 .I ctx_idp
26 argument.
27 See NOTES.
28 .PP
29 The
30 .BR io_setup ()
31 system call
32 creates an asynchronous I/O context suitable for concurrently processing
33 \fInr_events\fP operations.
34 The
35 .I ctx_idp
36 argument must not point to an AIO context that already exists, and must
37 be initialized to 0 prior to the call.
38 On successful creation of the AIO context, \fI*ctx_idp\fP is filled in
39 with the resulting handle.
40 .SH RETURN VALUE
41 On success,
42 .BR io_setup ()
43 returns 0.
44 For the failure return, see NOTES.
45 .SH ERRORS
46 .TP
47 .B EAGAIN
48 The specified \fInr_events\fP exceeds the limit of available events,
49 as defined in
50 .IR /proc/sys/fs/aio\-max\-nr
51 (see
52 .BR proc (5)).
53 .TP
54 .B EFAULT
55 An invalid pointer is passed for \fIctx_idp\fP.
56 .TP
57 .B EINVAL
58 \fIctx_idp\fP is not initialized, or the specified \fInr_events\fP
59 exceeds internal limits.
60 \fInr_events\fP should be greater than 0.
61 .TP
62 .B ENOMEM
63 Insufficient kernel resources are available.
64 .TP
65 .B ENOSYS
66 .BR io_setup ()
67 is not implemented on this architecture.
68 .SH VERSIONS
69 The asynchronous I/O system calls first appeared in Linux 2.5.
70 .SH CONFORMING TO
71 .BR io_setup ()
72 is Linux-specific and should not be used in programs
73 that are intended to be portable.
74 .SH NOTES
75 Glibc does not provide a wrapper for this system call.
76 You could invoke it using
77 .BR syscall (2).
78 But instead, you probably want to use the
79 .BR io_setup ()
80 wrapper function provided by
81 .\" http://git.fedorahosted.org/git/?p=libaio.git
82 .IR libaio .
83 .PP
84 Note that the
85 .I libaio
86 wrapper function uses a different type
87 .RI ( "io_context_t\ *" )
88 .\" But glibc is confused, since <libaio.h> uses 'io_context_t' to declare
89 .\" the system call.
90 for the
91 .I ctx_idp
92 argument.
93 Note also that the
94 .I libaio
95 wrapper does not follow the usual C library conventions for indicating errors:
96 on error it returns a negated error number
97 (the negative of one of the values listed in ERRORS).
98 If the system call is invoked via
99 .BR syscall (2),
100 then the return value follows the usual conventions for
101 indicating an error: \-1, with
102 .I errno
103 set to a (positive) value that indicates the error.
104 .SH SEE ALSO
105 .BR io_cancel (2),
106 .BR io_destroy (2),
107 .BR io_getevents (2),
108 .BR io_submit (2),
109 .BR aio (7)
110 .\" .SH AUTHOR
111 .\" Kent Yoder.