xref: /linux/include/uapi/linux/aio_abi.h (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1607ca46eSDavid Howells /* include/linux/aio_abi.h
2607ca46eSDavid Howells  *
3607ca46eSDavid Howells  * Copyright 2000,2001,2002 Red Hat.
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * Written by Benjamin LaHaise <bcrl@kvack.org>
6607ca46eSDavid Howells  *
7607ca46eSDavid Howells  * Distribute under the terms of the GPLv2 (see ../../COPYING) or under
8607ca46eSDavid Howells  * the following terms.
9607ca46eSDavid Howells  *
10607ca46eSDavid Howells  * Permission to use, copy, modify, and distribute this software and its
11607ca46eSDavid Howells  * documentation is hereby granted, provided that the above copyright
12607ca46eSDavid Howells  * notice appears in all copies.  This software is provided without any
13607ca46eSDavid Howells  * warranty, express or implied.  Red Hat makes no representations about
14607ca46eSDavid Howells  * the suitability of this software for any purpose.
15607ca46eSDavid Howells  *
16607ca46eSDavid Howells  * IN NO EVENT SHALL RED HAT BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
17607ca46eSDavid Howells  * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
18607ca46eSDavid Howells  * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RED HAT HAS BEEN ADVISED
19607ca46eSDavid Howells  * OF THE POSSIBILITY OF SUCH DAMAGE.
20607ca46eSDavid Howells  *
21607ca46eSDavid Howells  * RED HAT DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22607ca46eSDavid Howells  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23607ca46eSDavid Howells  * PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
24607ca46eSDavid Howells  * RED HAT HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
25607ca46eSDavid Howells  * ENHANCEMENTS, OR MODIFICATIONS.
26607ca46eSDavid Howells  */
27607ca46eSDavid Howells #ifndef __LINUX__AIO_ABI_H
28607ca46eSDavid Howells #define __LINUX__AIO_ABI_H
29607ca46eSDavid Howells 
30607ca46eSDavid Howells #include <linux/types.h>
31ddef7ed2SChristoph Hellwig #include <linux/fs.h>
32607ca46eSDavid Howells #include <asm/byteorder.h>
33607ca46eSDavid Howells 
34607ca46eSDavid Howells typedef __kernel_ulong_t aio_context_t;
35607ca46eSDavid Howells 
36607ca46eSDavid Howells enum {
37607ca46eSDavid Howells 	IOCB_CMD_PREAD = 0,
38607ca46eSDavid Howells 	IOCB_CMD_PWRITE = 1,
39607ca46eSDavid Howells 	IOCB_CMD_FSYNC = 2,
40607ca46eSDavid Howells 	IOCB_CMD_FDSYNC = 3,
41bfe4037eSChristoph Hellwig 	/* 4 was the experimental IOCB_CMD_PREADX */
42bfe4037eSChristoph Hellwig 	IOCB_CMD_POLL = 5,
43607ca46eSDavid Howells 	IOCB_CMD_NOOP = 6,
44607ca46eSDavid Howells 	IOCB_CMD_PREADV = 7,
45607ca46eSDavid Howells 	IOCB_CMD_PWRITEV = 8,
46607ca46eSDavid Howells };
47607ca46eSDavid Howells 
48607ca46eSDavid Howells /*
49607ca46eSDavid Howells  * Valid flags for the "aio_flags" member of the "struct iocb".
50607ca46eSDavid Howells  *
51607ca46eSDavid Howells  * IOCB_FLAG_RESFD - Set if the "aio_resfd" member of the "struct iocb"
52607ca46eSDavid Howells  *                   is valid.
53*23464f8cSDamien Le Moal  * IOCB_FLAG_IOPRIO - Set if the "aio_reqprio" member of the "struct iocb"
54*23464f8cSDamien Le Moal  *                    is valid.
55607ca46eSDavid Howells  */
56607ca46eSDavid Howells #define IOCB_FLAG_RESFD		(1 << 0)
57d9a08a9eSAdam Manzanares #define IOCB_FLAG_IOPRIO	(1 << 1)
58607ca46eSDavid Howells 
59607ca46eSDavid Howells /* read() from /dev/aio returns these structures. */
60607ca46eSDavid Howells struct io_event {
61607ca46eSDavid Howells 	__u64		data;		/* the data field from the iocb */
62607ca46eSDavid Howells 	__u64		obj;		/* what iocb this event came from */
63607ca46eSDavid Howells 	__s64		res;		/* result code for this event */
64607ca46eSDavid Howells 	__s64		res2;		/* secondary result */
65607ca46eSDavid Howells };
66607ca46eSDavid Howells 
67607ca46eSDavid Howells /*
68607ca46eSDavid Howells  * we always use a 64bit off_t when communicating
69607ca46eSDavid Howells  * with userland.  its up to libraries to do the
70607ca46eSDavid Howells  * proper padding and aio_error abstraction
71607ca46eSDavid Howells  */
72607ca46eSDavid Howells 
73607ca46eSDavid Howells struct iocb {
74607ca46eSDavid Howells 	/* these are internal to the kernel/libc. */
75607ca46eSDavid Howells 	__u64	aio_data;	/* data to be returned in event's data */
76ddef7ed2SChristoph Hellwig 
77ddef7ed2SChristoph Hellwig #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
78ddef7ed2SChristoph Hellwig 	__u32	aio_key;	/* the kernel sets aio_key to the req # */
79ddef7ed2SChristoph Hellwig 	__kernel_rwf_t aio_rw_flags;	/* RWF_* flags */
80ddef7ed2SChristoph Hellwig #elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
81ddef7ed2SChristoph Hellwig 	__kernel_rwf_t aio_rw_flags;	/* RWF_* flags */
82ddef7ed2SChristoph Hellwig 	__u32	aio_key;	/* the kernel sets aio_key to the req # */
83ddef7ed2SChristoph Hellwig #else
84ddef7ed2SChristoph Hellwig #error edit for your odd byteorder.
85ddef7ed2SChristoph Hellwig #endif
86607ca46eSDavid Howells 
87607ca46eSDavid Howells 	/* common fields */
88607ca46eSDavid Howells 	__u16	aio_lio_opcode;	/* see IOCB_CMD_ above */
89607ca46eSDavid Howells 	__s16	aio_reqprio;
90607ca46eSDavid Howells 	__u32	aio_fildes;
91607ca46eSDavid Howells 
92607ca46eSDavid Howells 	__u64	aio_buf;
93607ca46eSDavid Howells 	__u64	aio_nbytes;
94607ca46eSDavid Howells 	__s64	aio_offset;
95607ca46eSDavid Howells 
96607ca46eSDavid Howells 	/* extra parameters */
97607ca46eSDavid Howells 	__u64	aio_reserved2;	/* TODO: use this for a (struct sigevent *) */
98607ca46eSDavid Howells 
99607ca46eSDavid Howells 	/* flags for the "struct iocb" */
100607ca46eSDavid Howells 	__u32	aio_flags;
101607ca46eSDavid Howells 
102607ca46eSDavid Howells 	/*
103607ca46eSDavid Howells 	 * if the IOCB_FLAG_RESFD flag of "aio_flags" is set, this is an
104607ca46eSDavid Howells 	 * eventfd to signal AIO readiness to
105607ca46eSDavid Howells 	 */
106607ca46eSDavid Howells 	__u32	aio_resfd;
107607ca46eSDavid Howells }; /* 64 bytes */
108607ca46eSDavid Howells 
109607ca46eSDavid Howells #undef IFBIG
110607ca46eSDavid Howells #undef IFLITTLE
111607ca46eSDavid Howells 
112607ca46eSDavid Howells #endif /* __LINUX__AIO_ABI_H */
113607ca46eSDavid Howells 
114