2 * Copyright (c) 1997 John S. Dyson. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
16 * $Id: aio.h,v 1.8 1998/04/12 03:09:43 dyson Exp $
22 #include <sys/types.h>
23 #include <sys/signal.h>
26 * Returned by aio_cancel:
27 * (Note that FreeBSD's aio is not cancellable -- yet.)
29 #define AIO_CANCELED 0x1
30 #define AIO_NOTCANCELED 0x2
31 #define AIO_ALLDONE 0x3
43 #define LIO_NOWAIT 0x0
47 * Maximum number of allowed LIO operations
49 #define AIO_LISTIO_MAX 16
52 * Private mode bit for aio.
53 * (This bit is set by the library routine
54 * to allow the kernel to support sync
55 * or async operations in the future.)
57 #define AIO_PMODE_SYNC 0x1
58 #define AIO_PMODE_DONE 0x2
59 #define AIO_PMODE_SUSPEND 0x4
60 #define AIO_PMODE_ACTIVE 0x2357c0de
63 * Private members for aiocb -- don't access
66 struct __aiocb_private {
80 typedef struct aiocb {
81 int aio_fildes; /* File descriptor */
82 off_t aio_offset; /* File offset for I/O */
83 volatile void *aio_buf; /* I/O buffer in process space */
84 size_t aio_nbytes; /* Number of bytes for I/O */
85 struct sigevent aio_sigevent; /* Signal to deliver */
86 int aio_lio_opcode; /* LIO opcode */
87 int aio_reqprio; /* Request priority -- ignored */
88 struct __aiocb_private _aiocb_private;
95 * Asynchronously read from a file
97 int aio_read(struct aiocb *);
100 * Asynchronously write to file
102 int aio_write(struct aiocb *);
105 * List I/O Asynchronously/synchronously read/write to/from file
106 * "lio_mode" specifies whether or not the I/O is synchronous.
107 * "acb_list" is an array of "nacb_listent" I/O control blocks.
108 * when all I/Os are complete, the optional signal "sig" is sent.
110 int lio_listio(int, struct aiocb * const [], int, struct sigevent *);
113 * Get completion status
114 * returns EINPROGRESS until I/O is complete.
115 * this routine does not block.
117 int aio_error(const struct aiocb *);
120 * Finish up I/O, releasing I/O resources and returns the value
121 * that would have been associated with a synchronous I/O request.
122 * This routine must be called once and only once for each
123 * I/O control block who has had I/O associated with it.
125 ssize_t aio_return(struct aiocb *);
128 * Cancel I/O -- implemented only to return AIO_NOTCANCELLED or
129 * AIO_ALLDONE. No cancellation operation will occur.
131 int aio_cancel(int, struct aiocb *);
134 * Suspend until all specified I/O or timeout is complete.
136 int aio_suspend(const struct aiocb * const[], int, const struct timespec *);
139 * Retrieve the status of the specified I/O request.
141 int aio_error(const struct aiocb *);
147 void aio_proc_rundown(struct proc *p);