| 1 |
.\" Copyright 2003, Free Software Foundation, Inc. |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: GPL-1.0-or-later |
| 5 |
.\" |
| 6 |
.TH io_setup 2 2026-04-11 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
io_setup \- create an asynchronous I/O context |
| 9 |
.SH LIBRARY |
| 10 |
Standard C library |
| 11 |
.RI ( libc ,\~ \-lc ) |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
.B #include <linux/aio_abi.h> |
| 15 |
.BR "#include <sys/syscall.h>" " /* Definition of SYS_* constants */" |
| 16 |
.B #include <unistd.h> |
| 17 |
.P |
| 18 |
.BI "long\~syscall(SYS_io_setup, unsigned int " n ", aio_context_t *" ctx_idp ); |
| 19 |
.fi |
| 20 |
.SH DESCRIPTION |
| 21 |
.IR Note : |
| 22 |
you probably want to use the |
| 23 |
.BR io_setup (3) |
| 24 |
wrapper function provided by |
| 25 |
.IR libaio ; |
| 26 |
see VERSIONS. |
| 27 |
.P |
| 28 |
The |
| 29 |
.BR io_setup () |
| 30 |
system call |
| 31 |
creates an asynchronous I/O context suitable for concurrently processing |
| 32 |
.I n |
| 33 |
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, |
| 39 |
.I *ctx_idp |
| 40 |
is filled in |
| 41 |
with the resulting handle. |
| 42 |
.SH RETURN VALUE |
| 43 |
On success, |
| 44 |
.BR io_setup () |
| 45 |
returns 0. |
| 46 |
On error, |
| 47 |
\-1 is returned, |
| 48 |
and |
| 49 |
.I errno |
| 50 |
is set to indicate the error. |
| 51 |
.SH ERRORS |
| 52 |
.TP |
| 53 |
.B EAGAIN |
| 54 |
The specified |
| 55 |
.I n |
| 56 |
exceeds the limit of available events, |
| 57 |
as defined in |
| 58 |
.I /proc/sys/fs/aio\-max\-nr |
| 59 |
(see |
| 60 |
.BR proc_sys_fs (5)). |
| 61 |
.TP |
| 62 |
.B EFAULT |
| 63 |
An invalid pointer is passed for |
| 64 |
.IR ctx_idp . |
| 65 |
.TP |
| 66 |
.B EINVAL |
| 67 |
.I *ctx_idp |
| 68 |
is not initialized to 0. |
| 69 |
.TP |
| 70 |
.B EINVAL |
| 71 |
The specified |
| 72 |
.I n |
| 73 |
exceeds internal limits. |
| 74 |
.I n |
| 75 |
should be greater than 0. |
| 76 |
.TP |
| 77 |
.B ENOMEM |
| 78 |
Insufficient kernel resources are available. |
| 79 |
.TP |
| 80 |
.B ENOSYS |
| 81 |
.BR io_setup () |
| 82 |
is not implemented on this architecture. |
| 83 |
.SH VERSIONS |
| 84 |
.UR https://pagure.io/libaio |
| 85 |
.I libaio |
| 86 |
.UE |
| 87 |
provides a wrapper function with the same name, |
| 88 |
but different prototype and return value. |
| 89 |
You probably want to use that wrapper. |
| 90 |
.SH STANDARDS |
| 91 |
Linux. |
| 92 |
.SH HISTORY |
| 93 |
Linux 2.5. |
| 94 |
.SH SEE ALSO |
| 95 |
.BR io_cancel (2), |
| 96 |
.BR io_destroy (2), |
| 97 |
.BR io_getevents (2), |
| 98 |
.BR io_submit (2), |
| 99 |
.BR io_setup (3), |
| 100 |
.BR aio (7) |
| 101 |
.\" .SH AUTHOR |
| 102 |
.\" Kent Yoder. |