blob: ed0185945bb2e8c23d8f7b0fc069f7c0babaf761 [file] [log] [blame]
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02001/* include/linux/aio_abi.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * Copyright 2000,2001,2002 Red Hat.
4 *
5 * Written by Benjamin LaHaise <bcrl@kvack.org>
6 *
7 * Distribute under the terms of the GPLv2 (see ../../COPYING) or under
8 * the following terms.
9 *
10 * Permission to use, copy, modify, and distribute this software and its
11 * documentation is hereby granted, provided that the above copyright
12 * notice appears in all copies. This software is provided without any
13 * warranty, express or implied. Red Hat makes no representations about
14 * the suitability of this software for any purpose.
15 *
16 * IN NO EVENT SHALL RED HAT BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
17 * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
18 * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RED HAT HAS BEEN ADVISED
19 * OF THE POSSIBILITY OF SUCH DAMAGE.
20 *
21 * RED HAT DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
24 * RED HAT HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
25 * ENHANCEMENTS, OR MODIFICATIONS.
26 */
27#ifndef __LINUX__AIO_ABI_H
28#define __LINUX__AIO_ABI_H
29
Jaswinder Singh Rajputbd247b32009-01-30 20:20:10 +053030#include <linux/types.h>
Christoph Hellwigddef7ed2017-07-06 18:58:37 +020031#include <linux/fs.h>
Christoph Hellwig7a074e92018-05-02 19:51:00 +020032#include <linux/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/byteorder.h>
34
H. Peter Anvinff889432012-02-14 12:58:56 -080035typedef __kernel_ulong_t aio_context_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37enum {
38 IOCB_CMD_PREAD = 0,
39 IOCB_CMD_PWRITE = 1,
40 IOCB_CMD_FSYNC = 2,
41 IOCB_CMD_FDSYNC = 3,
Christoph Hellwig2c14fa82018-03-20 16:34:36 +010042 /* 4 was the experimental IOCB_CMD_PREADX */
43 IOCB_CMD_POLL = 5,
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 IOCB_CMD_NOOP = 6,
Badari Pulavartyeed4e512006-09-30 23:28:49 -070045 IOCB_CMD_PREADV = 7,
46 IOCB_CMD_PWRITEV = 8,
Linus Torvalds1da177e2005-04-16 15:20:36 -070047};
48
Davide Libenzi9c3060b2007-05-10 22:23:21 -070049/*
50 * Valid flags for the "aio_flags" member of the "struct iocb".
51 *
52 * IOCB_FLAG_RESFD - Set if the "aio_resfd" member of the "struct iocb"
53 * is valid.
54 */
55#define IOCB_FLAG_RESFD (1 << 0)
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057/* read() from /dev/aio returns these structures. */
58struct io_event {
59 __u64 data; /* the data field from the iocb */
60 __u64 obj; /* what iocb this event came from */
61 __s64 res; /* result code for this event */
62 __s64 res2; /* secondary result */
63};
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065/*
66 * we always use a 64bit off_t when communicating
67 * with userland. its up to libraries to do the
68 * proper padding and aio_error abstraction
69 */
70
71struct iocb {
72 /* these are internal to the kernel/libc. */
73 __u64 aio_data; /* data to be returned in event's data */
Christoph Hellwigddef7ed2017-07-06 18:58:37 +020074
75#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
76 __u32 aio_key; /* the kernel sets aio_key to the req # */
77 __kernel_rwf_t aio_rw_flags; /* RWF_* flags */
78#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
79 __kernel_rwf_t aio_rw_flags; /* RWF_* flags */
80 __u32 aio_key; /* the kernel sets aio_key to the req # */
81#else
82#error edit for your odd byteorder.
83#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85 /* common fields */
86 __u16 aio_lio_opcode; /* see IOCB_CMD_ above */
87 __s16 aio_reqprio;
88 __u32 aio_fildes;
89
90 __u64 aio_buf;
91 __u64 aio_nbytes;
92 __s64 aio_offset;
93
94 /* extra parameters */
95 __u64 aio_reserved2; /* TODO: use this for a (struct sigevent *) */
Davide Libenzi9c3060b2007-05-10 22:23:21 -070096
97 /* flags for the "struct iocb" */
98 __u32 aio_flags;
99
100 /*
101 * if the IOCB_FLAG_RESFD flag of "aio_flags" is set, this is an
102 * eventfd to signal AIO readiness to
103 */
104 __u32 aio_resfd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105}; /* 64 bytes */
106
107#undef IFBIG
108#undef IFLITTLE
109
Christoph Hellwig7a074e92018-05-02 19:51:00 +0200110struct __aio_sigset {
111 sigset_t __user *sigmask;
112 size_t sigsetsize;
113};
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#endif /* __LINUX__AIO_ABI_H */
116