… | |
… | |
38 | */ |
38 | */ |
39 | |
39 | |
40 | #ifndef EIO_H_ |
40 | #ifndef EIO_H_ |
41 | #define EIO_H_ |
41 | #define EIO_H_ |
42 | |
42 | |
|
|
43 | #ifdef __cplusplus |
|
|
44 | extern "C" { |
|
|
45 | #endif |
|
|
46 | |
43 | #include <stddef.h> |
47 | #include <stddef.h> |
44 | #include <sys/types.h> |
48 | #include <sys/types.h> |
45 | |
49 | |
46 | typedef struct eio_req eio_req; |
50 | typedef struct eio_req eio_req; |
47 | |
51 | |
… | |
… | |
67 | EIO_SYNC, EIO_FSYNC, EIO_FDATASYNC, |
71 | EIO_SYNC, EIO_FSYNC, EIO_FDATASYNC, |
68 | EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME, |
72 | EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME, |
69 | EIO_MKNOD, EIO_READDIR, |
73 | EIO_MKNOD, EIO_READDIR, |
70 | EIO_LINK, EIO_SYMLINK, EIO_READLINK, |
74 | EIO_LINK, EIO_SYMLINK, EIO_READLINK, |
71 | EIO_GROUP, EIO_NOP, |
75 | EIO_GROUP, EIO_NOP, |
72 | EIO_BUSY, |
76 | EIO_BUSY, EIO_CUSTOM |
73 | }; |
77 | }; |
74 | |
78 | |
75 | typedef double eio_tstamp; /* feel free to use double in your code directly */ |
79 | typedef double eio_tstamp; /* feel free to use double in your code directly */ |
76 | |
80 | |
77 | /* eio request structure */ |
81 | /* eio request structure */ |
… | |
… | |
79 | struct eio_req |
83 | struct eio_req |
80 | { |
84 | { |
81 | eio_req volatile *next; /* private ETP */ |
85 | eio_req volatile *next; /* private ETP */ |
82 | |
86 | |
83 | ssize_t result; /* result of syscall, e.g. result = read (... */ |
87 | ssize_t result; /* result of syscall, e.g. result = read (... */ |
84 | off_t offs; /* read, write, truncate, readahead: file offset; mknod: dev_t */ |
88 | off_t offs; /* read, write, truncate, readahead: file offset */ |
85 | size_t size; /* read, write, readahead, sendfile: length */ |
89 | size_t size; /* read, write, readahead, sendfile: length */ |
86 | void *ptr1; /* all applicable requests: pathname, old name */ |
90 | void *ptr1; /* all applicable requests: pathname, old name */ |
87 | void *ptr2; /* all applicable requests: new name or memory buffer */ |
91 | void *ptr2; /* all applicable requests: new name or memory buffer */ |
88 | eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */ |
92 | eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */ |
89 | eio_tstamp nv2; /* utime, futime: mtime */ |
93 | eio_tstamp nv2; /* utime, futime: mtime */ |
90 | |
94 | |
91 | int type; /* EIO_xxx constant ETP */ |
95 | int type; /* EIO_xxx constant ETP */ |
92 | int int1; /* all applicable requests: file descriptor; sendfile: output fd; open: flags */ |
96 | int int1; /* all applicable requests: file descriptor; sendfile: output fd; open: flags */ |
93 | long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode */ |
97 | long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode */ |
94 | long int3; /* chown, fchown: gid */ |
98 | long int3; /* chown, fchown: gid; mknod: dev_t */ |
95 | int errorno; /* errno value on syscall return */ |
99 | int errorno; /* errno value on syscall return */ |
96 | |
100 | |
97 | unsigned char flags; /* private */ |
101 | unsigned char flags; /* private */ |
98 | signed char pri; /* the priority */ |
102 | signed char pri; /* the priority */ |
99 | |
103 | |
… | |
… | |
114 | }; |
118 | }; |
115 | |
119 | |
116 | enum { |
120 | enum { |
117 | EIO_PRI_MIN = -4, |
121 | EIO_PRI_MIN = -4, |
118 | EIO_PRI_MAX = 4, |
122 | EIO_PRI_MAX = 4, |
119 | |
|
|
120 | EIO_PRI_DEFAULT = 0, |
123 | EIO_PRI_DEFAULT = 0, |
121 | }; |
124 | }; |
122 | |
125 | |
123 | /* returns < 0 on error, errno set |
126 | /* returns < 0 on error, errno set |
124 | * need_poll, if non-zero, will be called when results are available |
127 | * need_poll, if non-zero, will be called when results are available |
125 | * and eio_poll_cb needs to be invoked (it MUST NOT call eio_poll_cb itself). |
128 | * and eio_poll_cb needs to be invoked (it MUST NOT call eio_poll_cb itself). |
… | |
… | |
182 | eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ |
185 | eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ |
183 | eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data); |
186 | eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data); |
184 | eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data); |
187 | eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data); |
185 | eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data); |
188 | eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data); |
186 | eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data); |
189 | eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data); |
|
|
190 | eio_req *eio_custom (eio_cb execute, int pri, eio_cb cb, void *data); |
187 | #endif |
191 | #endif |
188 | |
192 | |
189 | /*****************************************************************************/ |
193 | /*****************************************************************************/ |
190 | /* groups */ |
194 | /* groups */ |
191 | |
195 | |
… | |
… | |
217 | /*****************************************************************************/ |
221 | /*****************************************************************************/ |
218 | /* convinience functions */ |
222 | /* convinience functions */ |
219 | |
223 | |
220 | ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count); |
224 | ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count); |
221 | |
225 | |
|
|
226 | #ifdef __cplusplus |
|
|
227 | } |
222 | #endif |
228 | #endif |
223 | |
229 | |
|
|
230 | #endif |
|
|
231 | |