FreeBSD/Linux Kernel Cross Reference
sys/sys/aio.h
1 /*
2 * Copyright (c) 1997 John S. Dyson. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. John S. Dyson's name may not be used to endorse or promote products
10 * derived from this software without specific prior written permission.
11 *
12 * DISCLAIMER: This code isn't warranted to do anything useful. Anything
13 * bad that happens because of using this software isn't the responsibility
14 * of the author. This software is distributed AS-IS.
15 *
16 * $FreeBSD$
17 */
18
19 #ifndef _SYS_AIO_H_
20 #define _SYS_AIO_H_
21
22 #include <sys/time.h>
23 #include <sys/types.h>
24 #include <sys/signal.h>
25
26 /*
27 * Returned by aio_cancel:
28 * (Note that FreeBSD's aio is not cancellable -- yet.)
29 */
30 #define AIO_CANCELED 0x1
31 #define AIO_NOTCANCELED 0x2
32 #define AIO_ALLDONE 0x3
33
34 /*
35 * LIO opcodes
36 */
37 #define LIO_NOP 0x0
38 #define LIO_WRITE 0x1
39 #define LIO_READ 0x2
40
41 /*
42 * LIO modes
43 */
44 #define LIO_NOWAIT 0x0
45 #define LIO_WAIT 0x1
46
47 /*
48 * Maximum number of allowed LIO operations
49 */
50 #define AIO_LISTIO_MAX 16
51
52 /*
53 * Private mode bit for aio.
54 * (This bit is set by the library routine
55 * to allow the kernel to support sync
56 * or async operations in the future.)
57 */
58 #define AIO_PMODE_SYNC 0x1
59 #define AIO_PMODE_DONE 0x2
60 #define AIO_PMODE_SUSPEND 0x4
61 #define AIO_PMODE_ACTIVE 0x2357c0de
62
63 /*
64 * Private members for aiocb -- don't access
65 * directly.
66 */
67 struct __aiocb_private {
68 int status;
69 int error;
70 int privatemodes;
71 int active;
72 int tid;
73 int threadinfo;
74 void *userinfo;
75 void *kernelinfo;
76 };
77
78 /*
79 * I/O control block
80 */
81 typedef struct aiocb {
82 int aio_fildes; /* File descriptor */
83 off_t aio_offset; /* File offset for I/O */
84 volatile void *aio_buf; /* I/O buffer in process space */
85 size_t aio_nbytes; /* Number of bytes for I/O */
86 struct sigevent aio_sigevent; /* Signal to deliver */
87 int aio_lio_opcode; /* LIO opcode */
88 int aio_reqprio; /* Request priority -- ignored */
89 struct __aiocb_private _aiocb_private;
90 } aiocb_t;
91
92 #ifndef KERNEL
93
94 __BEGIN_DECLS
95 /*
96 * Asynchronously read from a file
97 */
98 int aio_read(struct aiocb *);
99
100 /*
101 * Asynchronously write to file
102 */
103 int aio_write(struct aiocb *);
104
105 /*
106 * List I/O Asynchronously/synchronously read/write to/from file
107 * "lio_mode" specifies whether or not the I/O is synchronous.
108 * "acb_list" is an array of "nacb_listent" I/O control blocks.
109 * when all I/Os are complete, the optional signal "sig" is sent.
110 */
111 int lio_listio(int, struct aiocb * const [], int, struct sigevent *);
112
113 /*
114 * Get completion status
115 * returns EINPROGRESS until I/O is complete.
116 * this routine does not block.
117 */
118 int aio_error(const struct aiocb *);
119
120 /*
121 * Finish up I/O, releasing I/O resources and returns the value
122 * that would have been associated with a synchronous I/O request.
123 * This routine must be called once and only once for each
124 * I/O control block who has had I/O associated with it.
125 */
126 ssize_t aio_return(struct aiocb *);
127
128 /*
129 * Cancel I/O -- implemented only to return AIO_NOTCANCELLED or
130 * AIO_ALLDONE. No cancellation operation will occur.
131 */
132 int aio_cancel(int, struct aiocb *);
133
134 /*
135 * Suspend until all specified I/O or timeout is complete.
136 */
137 int aio_suspend(const struct aiocb * const[], int, const struct timespec *);
138
139 /*
140 * Retrieve the status of the specified I/O request.
141 */
142 int aio_error(const struct aiocb *);
143
144 __END_DECLS
145
146 #else
147
148 void aio_proc_rundown(struct proc *p);
149
150 #endif
151
152 #endif
153
Cache object: 31fea1134c73308f7eec836b5ad82dbb
|