|
|
1 | /* |
|
|
2 | * libeio API header |
|
|
3 | * |
|
|
4 | * Copyright (c) 2007,2008 Marc Alexander Lehmann <libeio@schmorp.de> |
|
|
5 | * All rights reserved. |
|
|
6 | * |
|
|
7 | * Redistribution and use in source and binary forms, with or without modifica- |
|
|
8 | * tion, are permitted provided that the following conditions are met: |
|
|
9 | * |
|
|
10 | * 1. Redistributions of source code must retain the above copyright notice, |
|
|
11 | * this list of conditions and the following disclaimer. |
|
|
12 | * |
|
|
13 | * 2. Redistributions in binary form must reproduce the above copyright |
|
|
14 | * notice, this list of conditions and the following disclaimer in the |
|
|
15 | * documentation and/or other materials provided with the distribution. |
|
|
16 | * |
|
|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
|
18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- |
|
|
19 | * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|
|
20 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- |
|
|
21 | * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
|
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
|
23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
|
24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- |
|
|
25 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
|
26 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
27 | * |
|
|
28 | * Alternatively, the contents of this file may be used under the terms of |
|
|
29 | * the GNU General Public License ("GPL") version 2 or any later version, |
|
|
30 | * in which case the provisions of the GPL are applicable instead of |
|
|
31 | * the above. If you wish to allow the use of your version of this file |
|
|
32 | * only under the terms of the GPL and not to allow others to use your |
|
|
33 | * version of this file under the BSD license, indicate your decision |
|
|
34 | * by deleting the provisions above and replace them with the notice |
|
|
35 | * and other provisions required by the GPL. If you do not delete the |
|
|
36 | * provisions above, a recipient may use your version of this file under |
|
|
37 | * either the BSD or the GPL. |
|
|
38 | */ |
|
|
39 | |
1 | #ifndef EIO_H_ |
40 | #ifndef EIO_H_ |
2 | #define EIO_H_ |
41 | #define EIO_H_ |
3 | |
42 | |
4 | #include <stddef.h> |
43 | #include <stddef.h> |
5 | #include <sys/types.h> |
44 | #include <sys/types.h> |
… | |
… | |
15 | #ifndef EIO_STRUCT_STAT |
54 | #ifndef EIO_STRUCT_STAT |
16 | # define EIO_STRUCT_STAT struct stat |
55 | # define EIO_STRUCT_STAT struct stat |
17 | #endif |
56 | #endif |
18 | |
57 | |
19 | enum { |
58 | enum { |
20 | EIO_QUIT, |
|
|
21 | EIO_OPEN, EIO_CLOSE, EIO_DUP2, |
59 | EIO_OPEN, EIO_CLOSE, EIO_DUP2, |
22 | EIO_READ, EIO_WRITE, |
60 | EIO_READ, EIO_WRITE, |
23 | EIO_READAHEAD, EIO_SENDFILE, |
61 | EIO_READAHEAD, EIO_SENDFILE, |
24 | EIO_STAT, EIO_LSTAT, EIO_FSTAT, |
62 | EIO_STAT, EIO_LSTAT, EIO_FSTAT, |
25 | EIO_TRUNCATE, EIO_FTRUNCATE, |
63 | EIO_TRUNCATE, EIO_FTRUNCATE, |
… | |
… | |
38 | |
76 | |
39 | /* eio request structure */ |
77 | /* eio request structure */ |
40 | /* this structure is mostly read-only */ |
78 | /* this structure is mostly read-only */ |
41 | struct eio_req |
79 | struct eio_req |
42 | { |
80 | { |
43 | eio_req volatile *next; /* private */ |
81 | eio_req volatile *next; /* private ETP */ |
44 | |
82 | |
45 | ssize_t result; /* result of syscall, e.g. result = read (... */ |
83 | ssize_t result; /* result of syscall, e.g. result = read (... */ |
46 | off_t offs; /* read, write, truncate, readahead: file offset; mknod: dev_t */ |
84 | off_t offs; /* read, write, truncate, readahead: file offset; mknod: dev_t */ |
47 | size_t size; /* read, write, readahead, sendfile: length */ |
85 | size_t size; /* read, write, readahead, sendfile: length */ |
48 | void *ptr1; /* all applicable requests: pathname, old name */ |
86 | void *ptr1; /* all applicable requests: pathname, old name */ |
49 | void *ptr2; /* all applicable requests: new name or memory buffer */ |
87 | void *ptr2; /* all applicable requests: new name or memory buffer */ |
50 | eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */ |
88 | eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */ |
51 | eio_tstamp nv2; /* utime, futime: mtime */ |
89 | eio_tstamp nv2; /* utime, futime: mtime */ |
52 | |
90 | |
53 | int type; /* EIO_xxx constant */ |
91 | int type; /* EIO_xxx constant ETP */ |
54 | int int1; /* all applicable requests: file descriptor; sendfile: output fd; open: flags */ |
92 | int int1; /* all applicable requests: file descriptor; sendfile: output fd; open: flags */ |
55 | long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode */ |
93 | long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode */ |
56 | long int3; /* chown, fchown: gid */ |
94 | long int3; /* chown, fchown: gid */ |
57 | int errorno; /* errno value on syscall return */ |
95 | int errorno; /* errno value on syscall return */ |
58 | |
96 | |
… | |
… | |
78 | enum { |
116 | enum { |
79 | EIO_PRI_MIN = -4, |
117 | EIO_PRI_MIN = -4, |
80 | EIO_PRI_MAX = 4, |
118 | EIO_PRI_MAX = 4, |
81 | |
119 | |
82 | EIO_PRI_DEFAULT = 0, |
120 | EIO_PRI_DEFAULT = 0, |
83 | EIO_PRI_BIAS = -EIO_PRI_MIN, |
|
|
84 | EIO_NUM_PRI = EIO_PRI_MAX + EIO_PRI_BIAS + 1 |
|
|
85 | }; |
121 | }; |
86 | |
122 | |
87 | /* returns < 0 on error, errno set |
123 | /* returns < 0 on error, errno set |
88 | * need_poll, if non-zero, will be called when results are available |
124 | * need_poll, if non-zero, will be called when results are available |
89 | * and eio_poll_cb needs to be invoked (it MUST NOT call eio_poll_cb itself). |
125 | * and eio_poll_cb needs to be invoked (it MUST NOT call eio_poll_cb itself). |