ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/eio.c
(Generate patch)

Comparing libeio/eio.c (file contents):
Revision 1.86 by root, Thu Jul 14 18:30:10 2011 UTC vs.
Revision 1.97 by root, Sun Jul 24 03:32:54 2011 UTC

58#include <sys/stat.h> 58#include <sys/stat.h>
59#include <limits.h> 59#include <limits.h>
60#include <fcntl.h> 60#include <fcntl.h>
61#include <assert.h> 61#include <assert.h>
62 62
63#include <sys/statvfs.h>
64/* intptr_t comes from unistd.h, says POSIX/UNIX/tradition */ 63/* intptr_t comes from unistd.h, says POSIX/UNIX/tradition */
65/* intptr_t only comes from stdint.h, says idiot openbsd coder */ 64/* intptr_t only comes from stdint.h, says idiot openbsd coder */
66#if HAVE_STDINT_H 65#if HAVE_STDINT_H
67# include <stdint.h> 66# include <stdint.h>
68#endif 67#endif
69 68
70#ifndef ECANCELED 69#ifndef ECANCELED
71# define ECANCELED EDOM 70# define ECANCELED EDOM
72#endif 71#endif
72#ifndef ELOOP
73# define ELOOP EDOM
74#endif
75
76#if !defined(ENOTSOCK) && defined(WSAENOTSOCK)
77# define ENOTSOCK WSAENOTSOCK
78#endif
73 79
74static void eio_destroy (eio_req *req); 80static void eio_destroy (eio_req *req);
75 81
76#ifndef EIO_FINISH 82#ifndef EIO_FINISH
77# define EIO_FINISH(req) ((req)->finish) && !EIO_CANCELLED (req) ? (req)->finish (req) : 0 83# define EIO_FINISH(req) ((req)->finish) && !EIO_CANCELLED (req) ? (req)->finish (req) : 0
96 102
97#define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1) 103#define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1)
98 104
99#ifdef _WIN32 105#ifdef _WIN32
100 106
107 #undef PAGESIZE
101 #define PAGESIZE 4096 /* GetSystemInfo? */ 108 #define PAGESIZE 4096 /* GetSystemInfo? */
102 109
110 #ifdef EIO_STRUCT_STATI64
103 #define stat(path,buf) _stati64 (path,buf) 111 #define stat(path,buf) _stati64 (path,buf)
112 #define fstat(fd,buf) _fstati64 (fd,buf)
113 #endif
104 #define lstat(path,buf) stat (path,buf) 114 #define lstat(path,buf) stat (path,buf)
105 #define fstat(fd,buf) _fstati64 (path,buf)
106 #define fsync(fd) (FlushFileBuffers (EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1)) 115 #define fsync(fd) (FlushFileBuffers ((HANDLE)EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1))
107 #define mkdir(path,mode) _mkdir (path) 116 #define mkdir(path,mode) _mkdir (path)
108 #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1)) 117 #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1))
109 118
119 #define chmod(path,mode) _chmod (path, mode)
120 #define dup(fd) _dup (fd)
121 #define dup2(fd1,fd2) _dup2 (fd1, fd2)
122
123 #define fchmod(fd,mode) EIO_ENOSYS ()
110 #define chown(path,uid,gid) EIO_ENOSYS () 124 #define chown(path,uid,gid) EIO_ENOSYS ()
111 #define fchown(fd,uid,gid) EIO_ENOSYS () 125 #define fchown(fd,uid,gid) EIO_ENOSYS ()
112 #define truncate(path,offs) EIO_ENOSYS () /* far-miss: SetEndOfFile */ 126 #define truncate(path,offs) EIO_ENOSYS () /* far-miss: SetEndOfFile */
113 #define ftruncate(fd,offs) EIO_ENOSYS () /* near-miss: SetEndOfFile */ 127 #define ftruncate(fd,offs) EIO_ENOSYS () /* near-miss: SetEndOfFile */
114 #define mknod(path,mode,dev) EIO_ENOSYS () 128 #define mknod(path,mode,dev) EIO_ENOSYS ()
115 #define sync() EIO_ENOSYS () 129 #define sync() EIO_ENOSYS ()
130 #define readlink(path,buf,s) EIO_ENOSYS ()
131 #define statvfs(path,buf) EIO_ENOSYS ()
132 #define fstatvfs(fd,buf) EIO_ENOSYS ()
116 133
117 /* we could even stat and see if it exists */ 134 /* we could even stat and see if it exists */
118 static int 135 static int
119 symlink (const char *old, const char *neu) 136 symlink (const char *old, const char *neu)
120 { 137 {
138 #if WINVER >= 0x0600
121 if (CreateSymbolicLink (neu, old, 1)) 139 if (CreateSymbolicLink (neu, old, 1))
122 return 0; 140 return 0;
123 141
124 if (CreateSymbolicLink (neu, old, 0)) 142 if (CreateSymbolicLink (neu, old, 0))
125 return 0; 143 return 0;
144 #endif
126 145
127 return EIO_ERRNO (ENOENT, -1); 146 return EIO_ERRNO (ENOENT, -1);
128 } 147 }
148
149 /* POSIX API only */
150 #define CreateHardLink(neu,old,flags) 0
151 #define CreateSymbolicLink(neu,old,flags) 0
152
153 struct statvfs
154 {
155 int dummy;
156 };
157
158 #define DT_DIR EIO_DT_DIR
159 #define DT_REG EIO_DT_REG
160 #define D_NAME(entp) entp.cFileName
161 #define D_TYPE(entp) (entp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? DT_DIR : DT_REG)
129 162
130#else 163#else
131 164
132 #include <sys/time.h> 165 #include <sys/time.h>
133 #include <sys/select.h> 166 #include <sys/select.h>
134 #include <sys/statvfs.h> 167 #include <sys/statvfs.h>
135 #include <unistd.h> 168 #include <unistd.h>
136 #include <utime.h>
137 #include <signal.h> 169 #include <signal.h>
138 #include <dirent.h> 170 #include <dirent.h>
139 171
140 #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES 172 #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES
141 #include <sys/mman.h> 173 #include <sys/mman.h>
142 #endif 174 #endif
175
176 #define D_NAME(entp) entp->d_name
143 177
144 /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ 178 /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */
145 #if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ 179 #if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
146 #define _DIRENT_HAVE_D_TYPE /* sigh */ 180 #define _DIRENT_HAVE_D_TYPE /* sigh */
147 #define D_INO(de) (de)->d_fileno 181 #define D_INO(de) (de)->d_fileno
161 195
162 #ifndef EIO_STRUCT_DIRENT 196 #ifndef EIO_STRUCT_DIRENT
163 #define EIO_STRUCT_DIRENT struct dirent 197 #define EIO_STRUCT_DIRENT struct dirent
164 #endif 198 #endif
165 199
200#endif
201
202#if HAVE_UTIMES
203# include <utime.h>
166#endif 204#endif
167 205
168#if HAVE_SENDFILE 206#if HAVE_SENDFILE
169# if __linux 207# if __linux
170# include <sys/sendfile.h> 208# include <sys/sendfile.h>
178# else 216# else
179# error sendfile support requested but not available 217# error sendfile support requested but not available
180# endif 218# endif
181#endif 219#endif
182 220
221#if HAVE_SYS_SYSCALL_H
222# include <sys/syscall.h>
223#endif
224
183#ifndef D_TYPE 225#ifndef D_TYPE
184# define D_TYPE(de) 0 226# define D_TYPE(de) 0
185#endif 227#endif
186#ifndef D_INO 228#ifndef D_INO
187# define D_INO(de) 0 229# define D_INO(de) 0
188#endif 230#endif
189#ifndef D_NAMLEN 231#ifndef D_NAMLEN
190# define D_NAMLEN(de) strlen ((de)->d_name) 232# define D_NAMLEN(entp) strlen (D_NAME (entp))
191#endif 233#endif
192 234
193/* used for struct dirent, AIX doesn't provide it */ 235/* used for struct dirent, AIX doesn't provide it */
194#ifndef NAME_MAX 236#ifndef NAME_MAX
195# define NAME_MAX 4096 237# define NAME_MAX 4096
202 244
203/* buffer size for various temporary buffers */ 245/* buffer size for various temporary buffers */
204#define EIO_BUFSIZE 65536 246#define EIO_BUFSIZE 65536
205 247
206#define dBUF \ 248#define dBUF \
207 char *eio_buf; \
208 ETP_WORKER_LOCK (self); \
209 self->dbuf = eio_buf = malloc (EIO_BUFSIZE); \ 249 char *eio_buf = malloc (EIO_BUFSIZE); \
210 ETP_WORKER_UNLOCK (self); \
211 errno = ENOMEM; \ 250 errno = ENOMEM; \
212 if (!eio_buf) \ 251 if (!eio_buf) \
213 return -1; 252 return -1
253
254#define FUBd \
255 free (eio_buf)
214 256
215#define EIO_TICKS ((1000000 + 1023) >> 10) 257#define EIO_TICKS ((1000000 + 1023) >> 10)
216 258
217#define ETP_PRI_MIN EIO_PRI_MIN 259#define ETP_PRI_MIN EIO_PRI_MIN
218#define ETP_PRI_MAX EIO_PRI_MAX 260#define ETP_PRI_MAX EIO_PRI_MAX
224static int eio_finish (eio_req *req); 266static int eio_finish (eio_req *req);
225#define ETP_FINISH(req) eio_finish (req) 267#define ETP_FINISH(req) eio_finish (req)
226static void eio_execute (struct etp_worker *self, eio_req *req); 268static void eio_execute (struct etp_worker *self, eio_req *req);
227#define ETP_EXECUTE(wrk,req) eio_execute (wrk,req) 269#define ETP_EXECUTE(wrk,req) eio_execute (wrk,req)
228 270
229#define ETP_WORKER_CLEAR(req) \
230 if (wrk->dbuf) \
231 { \
232 free (wrk->dbuf); \
233 wrk->dbuf = 0; \
234 } \
235 \
236 if (wrk->dirp) \
237 { \
238 closedir (wrk->dirp); \
239 wrk->dirp = 0; \
240 }
241
242#define ETP_WORKER_COMMON \
243 void *dbuf; \
244 DIR *dirp;
245
246/*****************************************************************************/ 271/*****************************************************************************/
247 272
248#define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1) 273#define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1)
249 274
250/* calculate time difference in ~1/EIO_TICKS of a second */ 275/* calculate time difference in ~1/EIO_TICKS of a second */
278/* 303/*
279 * make our pread/pwrite emulation safe against themselves, but not against 304 * make our pread/pwrite emulation safe against themselves, but not against
280 * normal read/write by using a mutex. slows down execution a lot, 305 * normal read/write by using a mutex. slows down execution a lot,
281 * but that's your problem, not mine. 306 * but that's your problem, not mine.
282 */ 307 */
283static xmutex_t preadwritelock = X_MUTEX_INIT; 308static xmutex_t preadwritelock;
284#endif 309#endif
285 310
286typedef struct etp_worker 311typedef struct etp_worker
287{ 312{
288 /* locked by wrklock */ 313 /* locked by wrklock */
291 xthread_t tid; 316 xthread_t tid;
292 317
293 /* locked by reslock, reqlock or wrklock */ 318 /* locked by reslock, reqlock or wrklock */
294 ETP_REQ *req; /* currently processed request */ 319 ETP_REQ *req; /* currently processed request */
295 320
321#ifdef ETP_WORKER_COMMON
296 ETP_WORKER_COMMON 322 ETP_WORKER_COMMON
323#endif
297} etp_worker; 324} etp_worker;
298 325
299static etp_worker wrk_first = { &wrk_first, &wrk_first, 0 }; /* NOT etp */ 326static etp_worker wrk_first; /* NOT etp */
300 327
301#define ETP_WORKER_LOCK(wrk) X_LOCK (wrklock) 328#define ETP_WORKER_LOCK(wrk) X_LOCK (wrklock)
302#define ETP_WORKER_UNLOCK(wrk) X_UNLOCK (wrklock) 329#define ETP_WORKER_UNLOCK(wrk) X_UNLOCK (wrklock)
303 330
304/* worker threads management */ 331/* worker threads management */
305 332
306static void ecb_cold 333static void ecb_cold
307etp_worker_clear (etp_worker *wrk) 334etp_worker_clear (etp_worker *wrk)
308{ 335{
309 ETP_WORKER_CLEAR (wrk);
310} 336}
311 337
312static void ecb_cold 338static void ecb_cold
313etp_worker_free (etp_worker *wrk) 339etp_worker_free (etp_worker *wrk)
314{ 340{
375} etp_reqq; 401} etp_reqq;
376 402
377static etp_reqq req_queue; 403static etp_reqq req_queue;
378static etp_reqq res_queue; 404static etp_reqq res_queue;
379 405
406static void ecb_noinline ecb_cold
407reqq_init (etp_reqq *q)
408{
409 int pri;
410
411 for (pri = 0; pri < ETP_NUM_PRI; ++pri)
412 q->qs[pri] = q->qe[pri] = 0;
413
414 q->size = 0;
415}
416
380static int ecb_noinline 417static int ecb_noinline
381reqq_push (etp_reqq *q, ETP_REQ *req) 418reqq_push (etp_reqq *q, ETP_REQ *req)
382{ 419{
383 int pri = req->pri; 420 int pri = req->pri;
384 req->next = 0; 421 req->next = 0;
418 } 455 }
419 456
420 abort (); 457 abort ();
421} 458}
422 459
423static void ecb_cold 460static int ecb_cold
424etp_thread_init (void) 461etp_init (void (*want_poll)(void), void (*done_poll)(void))
425{ 462{
426#if !HAVE_PREADWRITE
427 X_MUTEX_CREATE (preadwritelock);
428#endif
429 X_MUTEX_CREATE (wrklock); 463 X_MUTEX_CREATE (wrklock);
430 X_MUTEX_CREATE (reslock); 464 X_MUTEX_CREATE (reslock);
431 X_MUTEX_CREATE (reqlock); 465 X_MUTEX_CREATE (reqlock);
432 X_COND_CREATE (reqwait); 466 X_COND_CREATE (reqwait);
433}
434 467
435static void ecb_cold 468 reqq_init (&req_queue);
436etp_atfork_prepare (void) 469 reqq_init (&res_queue);
437{
438}
439 470
440static void ecb_cold 471 wrk_first.next =
441etp_atfork_parent (void) 472 wrk_first.prev = &wrk_first;
442{
443}
444
445static void ecb_cold
446etp_atfork_child (void)
447{
448 ETP_REQ *prv;
449
450 while ((prv = reqq_shift (&req_queue)))
451 ETP_DESTROY (prv);
452
453 while ((prv = reqq_shift (&res_queue)))
454 ETP_DESTROY (prv);
455
456 while (wrk_first.next != &wrk_first)
457 {
458 etp_worker *wrk = wrk_first.next;
459
460 if (wrk->req)
461 ETP_DESTROY (wrk->req);
462
463 etp_worker_clear (wrk);
464 etp_worker_free (wrk);
465 }
466 473
467 started = 0; 474 started = 0;
468 idle = 0; 475 idle = 0;
469 nreqs = 0; 476 nreqs = 0;
470 nready = 0; 477 nready = 0;
471 npending = 0; 478 npending = 0;
472
473 etp_thread_init ();
474}
475
476static void ecb_cold
477etp_once_init (void)
478{
479 etp_thread_init ();
480 X_THREAD_ATFORK (etp_atfork_prepare, etp_atfork_parent, etp_atfork_child);
481}
482
483static int ecb_cold
484etp_init (void (*want_poll)(void), void (*done_poll)(void))
485{
486 static pthread_once_t doinit = PTHREAD_ONCE_INIT;
487
488 pthread_once (&doinit, etp_once_init);
489 479
490 want_poll_cb = want_poll; 480 want_poll_cb = want_poll;
491 done_poll_cb = done_poll; 481 done_poll_cb = done_poll;
492 482
493 return 0; 483 return 0;
876# undef pread 866# undef pread
877# undef pwrite 867# undef pwrite
878# define pread eio__pread 868# define pread eio__pread
879# define pwrite eio__pwrite 869# define pwrite eio__pwrite
880 870
881static ssize_t 871static eio_ssize_t
882eio__pread (int fd, void *buf, size_t count, off_t offset) 872eio__pread (int fd, void *buf, size_t count, off_t offset)
883{ 873{
884 ssize_t res; 874 eio_ssize_t res;
885 off_t ooffset; 875 off_t ooffset;
886 876
887 X_LOCK (preadwritelock); 877 X_LOCK (preadwritelock);
888 ooffset = lseek (fd, 0, SEEK_CUR); 878 ooffset = lseek (fd, 0, SEEK_CUR);
889 lseek (fd, offset, SEEK_SET); 879 lseek (fd, offset, SEEK_SET);
892 X_UNLOCK (preadwritelock); 882 X_UNLOCK (preadwritelock);
893 883
894 return res; 884 return res;
895} 885}
896 886
897static ssize_t 887static eio_ssize_t
898eio__pwrite (int fd, void *buf, size_t count, off_t offset) 888eio__pwrite (int fd, void *buf, size_t count, off_t offset)
899{ 889{
900 ssize_t res; 890 eio_ssize_t res;
901 off_t ooffset; 891 off_t ooffset;
902 892
903 X_LOCK (preadwritelock); 893 X_LOCK (preadwritelock);
904 ooffset = lseek (fd, 0, SEEK_CUR); 894 ooffset = lseek (fd, 0, SEEK_CUR);
905 lseek (fd, offset, SEEK_SET); 895 lseek (fd, offset, SEEK_SET);
950 940
951#if !HAVE_FDATASYNC 941#if !HAVE_FDATASYNC
952# undef fdatasync 942# undef fdatasync
953# define fdatasync(fd) fsync (fd) 943# define fdatasync(fd) fsync (fd)
954#endif 944#endif
945
946static int
947eio__syncfs (int fd)
948{
949 int res;
950
951#if HAVE_SYS_SYNCFS
952 res = (int)syscall (__NR_syncfs, (int)(fd));
953#else
954 res = -1;
955 errno = ENOSYS;
956#endif
957
958 if (res < 0 && errno == ENOSYS && fd >= 0)
959 sync ();
960
961 return res;
962}
955 963
956/* sync_file_range always needs emulation */ 964/* sync_file_range always needs emulation */
957static int 965static int
958eio__sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags) 966eio__sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags)
959{ 967{
994 1002
995#if !HAVE_READAHEAD 1003#if !HAVE_READAHEAD
996# undef readahead 1004# undef readahead
997# define readahead(fd,offset,count) eio__readahead (fd, offset, count, self) 1005# define readahead(fd,offset,count) eio__readahead (fd, offset, count, self)
998 1006
999static ssize_t 1007static eio_ssize_t
1000eio__readahead (int fd, off_t offset, size_t count, etp_worker *self) 1008eio__readahead (int fd, off_t offset, size_t count, etp_worker *self)
1001{ 1009{
1002 size_t todo = count; 1010 size_t todo = count;
1003 dBUF; 1011 dBUF;
1004 1012
1009 pread (fd, eio_buf, len, offset); 1017 pread (fd, eio_buf, len, offset);
1010 offset += len; 1018 offset += len;
1011 todo -= len; 1019 todo -= len;
1012 } 1020 }
1013 1021
1022 FUBd;
1023
1014 errno = 0; 1024 errno = 0;
1015 return count; 1025 return count;
1016} 1026}
1017 1027
1018#endif 1028#endif
1019 1029
1020/* sendfile always needs emulation */ 1030/* sendfile always needs emulation */
1021static ssize_t 1031static eio_ssize_t
1022eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) 1032eio__sendfile (int ofd, int ifd, off_t offset, size_t count)
1023{ 1033{
1024 ssize_t written = 0; 1034 eio_ssize_t written = 0;
1025 ssize_t res; 1035 eio_ssize_t res;
1026 1036
1027 if (!count) 1037 if (!count)
1028 return 0; 1038 return 0;
1029 1039
1030 for (;;) 1040 for (;;)
1125 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK 1135 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
1126 /* BSDs */ 1136 /* BSDs */
1127#ifdef ENOTSUP /* sigh, if the steenking pile called openbsd would only try to at least compile posix code... */ 1137#ifdef ENOTSUP /* sigh, if the steenking pile called openbsd would only try to at least compile posix code... */
1128 || errno == ENOTSUP 1138 || errno == ENOTSUP
1129#endif 1139#endif
1140#ifdef EOPNOTSUPP /* windows */
1130 || errno == EOPNOTSUPP /* BSDs */ 1141 || errno == EOPNOTSUPP /* BSDs */
1142#endif
1131#if __solaris 1143#if __solaris
1132 || errno == EAFNOSUPPORT || errno == EPROTOTYPE 1144 || errno == EAFNOSUPPORT || errno == EPROTOTYPE
1133#endif 1145#endif
1134 ) 1146 )
1135 ) 1147 )
1139 1151
1140 res = 0; 1152 res = 0;
1141 1153
1142 while (count) 1154 while (count)
1143 { 1155 {
1144 ssize_t cnt; 1156 eio_ssize_t cnt;
1145 1157
1146 cnt = pread (ifd, eio_buf, count > EIO_BUFSIZE ? EIO_BUFSIZE : count, offset); 1158 cnt = pread (ifd, eio_buf, count > EIO_BUFSIZE ? EIO_BUFSIZE : count, offset);
1147 1159
1148 if (cnt <= 0) 1160 if (cnt <= 0)
1149 { 1161 {
1161 1173
1162 offset += cnt; 1174 offset += cnt;
1163 res += cnt; 1175 res += cnt;
1164 count -= cnt; 1176 count -= cnt;
1165 } 1177 }
1178
1179 FUBd;
1166 } 1180 }
1167 1181
1168 return res; 1182 return res;
1169} 1183}
1170 1184
1197 /* round up length */ 1211 /* round up length */
1198 *length = (*length + mask) & ~mask; 1212 *length = (*length + mask) & ~mask;
1199} 1213}
1200 1214
1201#if !_POSIX_MEMLOCK 1215#if !_POSIX_MEMLOCK
1202# define eio__mlockall(a) eio_nosyscall() 1216# define eio__mlockall(a) EIO_ENOSYS ()
1203#else 1217#else
1204 1218
1205static int 1219static int
1206eio__mlockall (int flags) 1220eio__mlockall (int flags)
1207{ 1221{
1357 res += strlen (res); 1371 res += strlen (res);
1358 } 1372 }
1359 1373
1360 while (*rel) 1374 while (*rel)
1361 { 1375 {
1362 ssize_t len, linklen; 1376 eio_ssize_t len, linklen;
1363 char *beg = rel; 1377 char *beg = rel;
1364 1378
1365 while (*rel && *rel != '/') 1379 while (*rel && *rel != '/')
1366 ++rel; 1380 ++rel;
1367 1381
1460 1474
1461#define EIO_SORT_CUTOFF 30 /* quite high, but performs well on many filesystems */ 1475#define EIO_SORT_CUTOFF 30 /* quite high, but performs well on many filesystems */
1462#define EIO_SORT_FAST 60 /* when to only use insertion sort */ 1476#define EIO_SORT_FAST 60 /* when to only use insertion sort */
1463 1477
1464static void 1478static void
1465eio_dent_radix_sort (eio_dirent *dents, int size, signed char score_bits, ino_t inode_bits) 1479eio_dent_radix_sort (eio_dirent *dents, int size, signed char score_bits, eio_ino_t inode_bits)
1466{ 1480{
1467 unsigned char bits [9 + sizeof (ino_t) * 8]; 1481 unsigned char bits [9 + sizeof (eio_ino_t) * 8];
1468 unsigned char *bit = bits; 1482 unsigned char *bit = bits;
1469 1483
1470 assert (CHAR_BIT == 8); 1484 assert (CHAR_BIT == 8);
1471 assert (sizeof (eio_dirent) * 8 < 256); 1485 assert (sizeof (eio_dirent) * 8 < 256);
1472 assert (offsetof (eio_dirent, inode)); /* we use bit #0 as sentinel */ 1486 assert (offsetof (eio_dirent, inode)); /* we use bit #0 as sentinel */
1474 1488
1475 if (size <= EIO_SORT_FAST) 1489 if (size <= EIO_SORT_FAST)
1476 return; 1490 return;
1477 1491
1478 /* first prepare an array of bits to test in our radix sort */ 1492 /* first prepare an array of bits to test in our radix sort */
1479 /* try to take endianness into account, as well as differences in ino_t sizes */ 1493 /* try to take endianness into account, as well as differences in eio_ino_t sizes */
1480 /* inode_bits must contain all inodes ORed together */ 1494 /* inode_bits must contain all inodes ORed together */
1481 /* which is used to skip bits that are 0 everywhere, which is very common */ 1495 /* which is used to skip bits that are 0 everywhere, which is very common */
1482 { 1496 {
1483 ino_t endianness; 1497 eio_ino_t endianness;
1484 int i, j; 1498 int i, j;
1485 1499
1486 /* we store the byte offset of byte n into byte n of "endianness" */ 1500 /* we store the byte offset of byte n into byte n of "endianness" */
1487 for (i = 0; i < sizeof (ino_t); ++i) 1501 for (i = 0; i < sizeof (eio_ino_t); ++i)
1488 ((unsigned char *)&endianness)[i] = i; 1502 ((unsigned char *)&endianness)[i] = i;
1489 1503
1490 *bit++ = 0; 1504 *bit++ = 0;
1491 1505
1492 for (i = 0; i < sizeof (ino_t); ++i) 1506 for (i = 0; i < sizeof (eio_ino_t); ++i)
1493 { 1507 {
1494 /* shifting off the byte offsets out of "endianness" */ 1508 /* shifting off the byte offsets out of "endianness" */
1495 int offs = (offsetof (eio_dirent, inode) + (endianness & 0xff)) * 8; 1509 int offs = (offsetof (eio_dirent, inode) + (endianness & 0xff)) * 8;
1496 endianness >>= 8; 1510 endianness >>= 8;
1497 1511
1498 for (j = 0; j < 8; ++j) 1512 for (j = 0; j < 8; ++j)
1499 if (inode_bits & (((ino_t)1) << (i * 8 + j))) 1513 if (inode_bits & (((eio_ino_t)1) << (i * 8 + j)))
1500 *bit++ = offs + j; 1514 *bit++ = offs + j;
1501 } 1515 }
1502 1516
1503 for (j = 0; j < 8; ++j) 1517 for (j = 0; j < 8; ++j)
1504 if (score_bits & (1 << j)) 1518 if (score_bits & (1 << j))
1505 *bit++ = offsetof (eio_dirent, score) * 8 + j; 1519 *bit++ = offsetof (eio_dirent, score) * 8 + j;
1506 } 1520 }
1507 1521
1508 /* now actually do the sorting (a variant of MSD radix sort) */ 1522 /* now actually do the sorting (a variant of MSD radix sort) */
1509 { 1523 {
1510 eio_dirent *base_stk [9 + sizeof (ino_t) * 8], *base; 1524 eio_dirent *base_stk [9 + sizeof (eio_ino_t) * 8], *base;
1511 eio_dirent *end_stk [9 + sizeof (ino_t) * 8], *end; 1525 eio_dirent *end_stk [9 + sizeof (eio_ino_t) * 8], *end;
1512 unsigned char *bit_stk [9 + sizeof (ino_t) * 8]; 1526 unsigned char *bit_stk [9 + sizeof (eio_ino_t) * 8];
1513 int stk_idx = 0; 1527 int stk_idx = 0;
1514 1528
1515 base_stk [stk_idx] = dents; 1529 base_stk [stk_idx] = dents;
1516 end_stk [stk_idx] = dents + size; 1530 end_stk [stk_idx] = dents + size;
1517 bit_stk [stk_idx] = bit - 1; 1531 bit_stk [stk_idx] = bit - 1;
1596 } 1610 }
1597 } 1611 }
1598} 1612}
1599 1613
1600static void 1614static void
1601eio_dent_sort (eio_dirent *dents, int size, signed char score_bits, ino_t inode_bits) 1615eio_dent_sort (eio_dirent *dents, int size, signed char score_bits, eio_ino_t inode_bits)
1602{ 1616{
1603 if (size <= 1) 1617 if (size <= 1)
1604 return; /* our insertion sort relies on size > 0 */ 1618 return; /* our insertion sort relies on size > 0 */
1605 1619
1606 /* first we use a radix sort, but only for dirs >= EIO_SORT_FAST */ 1620 /* first we use a radix sort, but only for dirs >= EIO_SORT_FAST */
1614 1628
1615/* read a full directory */ 1629/* read a full directory */
1616static void 1630static void
1617eio__scandir (eio_req *req, etp_worker *self) 1631eio__scandir (eio_req *req, etp_worker *self)
1618{ 1632{
1619 DIR *dirp;
1620 EIO_STRUCT_DIRENT *entp;
1621 char *name, *names; 1633 char *name, *names;
1622 int namesalloc = 4096; 1634 int namesalloc = 4096 - sizeof (void *) * 4;
1623 int namesoffs = 0; 1635 int namesoffs = 0;
1624 int flags = req->int1; 1636 int flags = req->int1;
1625 eio_dirent *dents = 0; 1637 eio_dirent *dents = 0;
1626 int dentalloc = 128; 1638 int dentalloc = 128;
1627 int dentoffs = 0; 1639 int dentoffs = 0;
1628 ino_t inode_bits = 0; 1640 eio_ino_t inode_bits = 0;
1641#ifdef _WIN32
1642 HANDLE dirp;
1643 WIN32_FIND_DATA entp;
1644#else
1645 DIR *dirp;
1646 EIO_STRUCT_DIRENT *entp;
1647#endif
1629 1648
1630 req->result = -1; 1649 req->result = -1;
1631 1650
1632 if (!(flags & EIO_READDIR_DENTS)) 1651 if (!(flags & EIO_READDIR_DENTS))
1633 flags &= ~(EIO_READDIR_DIRS_FIRST | EIO_READDIR_STAT_ORDER); 1652 flags &= ~(EIO_READDIR_DIRS_FIRST | EIO_READDIR_STAT_ORDER);
1634 1653
1635 X_LOCK (wrklock); 1654#ifdef _WIN32
1636 /* the corresponding closedir is in ETP_WORKER_CLEAR */ 1655 {
1656 int len = strlen ((const char *)req->ptr1);
1657 char *path = malloc (MAX_PATH);
1658 const char *fmt;
1659
1660 if (!len)
1661 fmt = "./*";
1662 else if (((const char *)req->ptr1)[len - 1] == '/' || ((const char *)req->ptr1)[len - 1] == '\\')
1663 fmt = "%s*";
1664 else
1665 fmt = "%s/*";
1666
1667 _snprintf (path, MAX_PATH, fmt, (const char *)req->ptr1);
1668 dirp = FindFirstFile (path, &entp);
1669 free (path);
1670
1671 if (dirp == INVALID_HANDLE_VALUE)
1672 {
1673 dirp = 0;
1674
1675 switch (GetLastError ())
1676 {
1677 case ERROR_FILE_NOT_FOUND:
1678 req->result = 0;
1679 break;
1680
1681 case ERROR_INVALID_NAME:
1682 case ERROR_PATH_NOT_FOUND:
1683 case ERROR_NO_MORE_FILES:
1684 errno = ENOENT;
1685 break;
1686
1687 case ERROR_NOT_ENOUGH_MEMORY:
1688 errno = ENOMEM;
1689 break;
1690
1691 default:
1692 errno = EINVAL;
1693 break;
1694 }
1695 }
1696 }
1697#else
1637 self->dirp = dirp = opendir (req->ptr1); 1698 dirp = opendir (req->ptr1);
1699#endif
1638 1700
1639 if (req->flags & EIO_FLAG_PTR1_FREE) 1701 if (req->flags & EIO_FLAG_PTR1_FREE)
1640 free (req->ptr1); 1702 free (req->ptr1);
1641 1703
1642 req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE; 1704 req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE;
1643 req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0; 1705 req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0;
1644 req->ptr2 = names = malloc (namesalloc); 1706 req->ptr2 = names = malloc (namesalloc);
1645 X_UNLOCK (wrklock);
1646 1707
1647 if (dirp && names && (!flags || dents)) 1708 if (dirp && names && (!flags || dents))
1648 for (;;) 1709 for (;;)
1649 { 1710 {
1711 int done;
1712
1713#ifdef _WIN32
1714 done = !dirp;
1715#else
1650 errno = 0; 1716 errno = 0;
1651 entp = readdir (dirp); 1717 entp = readdir (dirp);
1718 done = !entp;
1719#endif
1652 1720
1653 if (!entp) 1721 if (done)
1654 { 1722 {
1723#ifndef _WIN32
1724 int old_errno = errno;
1725 closedir (dirp);
1726 errno = old_errno;
1727
1655 if (errno) 1728 if (errno)
1656 break; 1729 break;
1730#endif
1657 1731
1658 /* sort etc. */ 1732 /* sort etc. */
1659 req->int1 = flags; 1733 req->int1 = flags;
1660 req->result = dentoffs; 1734 req->result = dentoffs;
1661 1735
1690 1764
1691 break; 1765 break;
1692 } 1766 }
1693 1767
1694 /* now add the entry to our list(s) */ 1768 /* now add the entry to our list(s) */
1695 name = entp->d_name; 1769 name = D_NAME (entp);
1696 1770
1697 /* skip . and .. entries */ 1771 /* skip . and .. entries */
1698 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2]))) 1772 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2])))
1699 { 1773 {
1700 int len = D_NAMLEN (entp) + 1; 1774 int len = D_NAMLEN (entp) + 1;
1701 1775
1702 while (ecb_expect_false (namesoffs + len > namesalloc)) 1776 while (ecb_expect_false (namesoffs + len > namesalloc))
1703 { 1777 {
1704 namesalloc *= 2; 1778 namesalloc *= 2;
1705 X_LOCK (wrklock);
1706 req->ptr2 = names = realloc (names, namesalloc); 1779 req->ptr2 = names = realloc (names, namesalloc);
1707 X_UNLOCK (wrklock);
1708 1780
1709 if (!names) 1781 if (!names)
1710 break; 1782 break;
1711 } 1783 }
1712 1784
1717 struct eio_dirent *ent; 1789 struct eio_dirent *ent;
1718 1790
1719 if (ecb_expect_false (dentoffs == dentalloc)) 1791 if (ecb_expect_false (dentoffs == dentalloc))
1720 { 1792 {
1721 dentalloc *= 2; 1793 dentalloc *= 2;
1722 X_LOCK (wrklock);
1723 req->ptr1 = dents = realloc (dents, dentalloc * sizeof (eio_dirent)); 1794 req->ptr1 = dents = realloc (dents, dentalloc * sizeof (eio_dirent));
1724 X_UNLOCK (wrklock);
1725 1795
1726 if (!dents) 1796 if (!dents)
1727 break; 1797 break;
1728 } 1798 }
1729 1799
1809 if (EIO_CANCELLED (req)) 1879 if (EIO_CANCELLED (req))
1810 { 1880 {
1811 errno = ECANCELED; 1881 errno = ECANCELED;
1812 break; 1882 break;
1813 } 1883 }
1884
1885#ifdef _WIN32
1886 if (!FindNextFile (dirp, &entp))
1887 {
1888 FindClose (dirp);
1889 dirp = 0;
1890 }
1891#endif
1814 } 1892 }
1815} 1893}
1816 1894
1817/*****************************************************************************/ 1895/*****************************************************************************/
1818 1896
1834X_THREAD_PROC (etp_proc) 1912X_THREAD_PROC (etp_proc)
1835{ 1913{
1836 ETP_REQ *req; 1914 ETP_REQ *req;
1837 struct timespec ts; 1915 struct timespec ts;
1838 etp_worker *self = (etp_worker *)thr_arg; 1916 etp_worker *self = (etp_worker *)thr_arg;
1839 int timeout;
1840 1917
1841 /* try to distribute timeouts somewhat evenly */ 1918 /* try to distribute timeouts somewhat evenly */
1842 ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); 1919 ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL);
1843 1920
1844 for (;;) 1921 for (;;)
1914/*****************************************************************************/ 1991/*****************************************************************************/
1915 1992
1916int ecb_cold 1993int ecb_cold
1917eio_init (void (*want_poll)(void), void (*done_poll)(void)) 1994eio_init (void (*want_poll)(void), void (*done_poll)(void))
1918{ 1995{
1996#if !HAVE_PREADWRITE
1997 X_MUTEX_CREATE (preadwritelock);
1998#endif
1999
1919 return etp_init (want_poll, done_poll); 2000 return etp_init (want_poll, done_poll);
1920} 2001}
1921 2002
1922ecb_inline void 2003ecb_inline void
1923eio_api_destroy (eio_req *req) 2004eio_api_destroy (eio_req *req)
1968 case EIO_WRITE: req->result = req->offs >= 0 2049 case EIO_WRITE: req->result = req->offs >= 0
1969 ? pwrite (req->int1, req->ptr2, req->size, req->offs) 2050 ? pwrite (req->int1, req->ptr2, req->size, req->offs)
1970 : write (req->int1, req->ptr2, req->size); break; 2051 : write (req->int1, req->ptr2, req->size); break;
1971 2052
1972 case EIO_READAHEAD: req->result = readahead (req->int1, req->offs, req->size); break; 2053 case EIO_READAHEAD: req->result = readahead (req->int1, req->offs, req->size); break;
1973 case EIO_SENDFILE: req->result = eio__sendfile (req->int1, req->int2, req->offs, req->size, self); break; 2054 case EIO_SENDFILE: req->result = eio__sendfile (req->int1, req->int2, req->offs, req->size); break;
1974 2055
1975 case EIO_STAT: ALLOC (sizeof (EIO_STRUCT_STAT)); 2056 case EIO_STAT: ALLOC (sizeof (EIO_STRUCT_STAT));
1976 req->result = stat (req->ptr1, (EIO_STRUCT_STAT *)req->ptr2); break; 2057 req->result = stat (req->ptr1, (EIO_STRUCT_STAT *)req->ptr2); break;
1977 case EIO_LSTAT: ALLOC (sizeof (EIO_STRUCT_STAT)); 2058 case EIO_LSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
1978 req->result = lstat (req->ptr1, (EIO_STRUCT_STAT *)req->ptr2); break; 2059 req->result = lstat (req->ptr1, (EIO_STRUCT_STAT *)req->ptr2); break;
2008 req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break; 2089 req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break;
2009 2090
2010 case EIO_SYNC: req->result = 0; sync (); break; 2091 case EIO_SYNC: req->result = 0; sync (); break;
2011 case EIO_FSYNC: req->result = fsync (req->int1); break; 2092 case EIO_FSYNC: req->result = fsync (req->int1); break;
2012 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break; 2093 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break;
2094 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break;
2095 case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break;
2013 case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break; 2096 case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break;
2014 case EIO_MTOUCH: req->result = eio__mtouch (req); break; 2097 case EIO_MTOUCH: req->result = eio__mtouch (req); break;
2015 case EIO_MLOCK: req->result = eio__mlock (req->ptr2, req->size); break; 2098 case EIO_MLOCK: req->result = eio__mlock (req->ptr2, req->size); break;
2016 case EIO_MLOCKALL: req->result = eio__mlockall (req->int1); break; 2099 case EIO_MLOCKALL: req->result = eio__mlockall (req->int1); break;
2017 case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break;
2018 case EIO_FALLOCATE: req->result = eio__fallocate (req->int1, req->int2, req->offs, req->size); break; 2100 case EIO_FALLOCATE: req->result = eio__fallocate (req->int1, req->int2, req->offs, req->size); break;
2019 2101
2020 case EIO_READDIR: eio__scandir (req, self); break; 2102 case EIO_READDIR: eio__scandir (req, self); break;
2021 2103
2022 case EIO_BUSY: 2104 case EIO_BUSY:
2103eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) 2185eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data)
2104{ 2186{
2105 REQ (EIO_MSYNC); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND; 2187 REQ (EIO_MSYNC); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND;
2106} 2188}
2107 2189
2190eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data)
2191{
2192 REQ (EIO_FDATASYNC); req->int1 = fd; SEND;
2193}
2194
2195eio_req *eio_syncfs (int fd, int pri, eio_cb cb, void *data)
2196{
2197 REQ (EIO_SYNCFS); req->int1 = fd; SEND;
2198}
2199
2200eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data)
2201{
2202 REQ (EIO_SYNC_FILE_RANGE); req->int1 = fd; req->offs = offset; req->size = nbytes; req->int2 = flags; SEND;
2203}
2204
2108eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) 2205eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data)
2109{ 2206{
2110 REQ (EIO_MTOUCH); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND; 2207 REQ (EIO_MTOUCH); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND;
2111} 2208}
2112 2209
2118eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data) 2215eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data)
2119{ 2216{
2120 REQ (EIO_MLOCKALL); req->int1 = flags; SEND; 2217 REQ (EIO_MLOCKALL); req->int1 = flags; SEND;
2121} 2218}
2122 2219
2123eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data)
2124{
2125 REQ (EIO_SYNC_FILE_RANGE); req->int1 = fd; req->offs = offset; req->size = nbytes; req->int2 = flags; SEND;
2126}
2127
2128eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data) 2220eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data)
2129{ 2221{
2130 REQ (EIO_FALLOCATE); req->int1 = fd; req->int2 = mode; req->offs = offset; req->size = len; SEND; 2222 REQ (EIO_FALLOCATE); req->int1 = fd; req->int2 = mode; req->offs = offset; req->size = len; SEND;
2131} 2223}
2132 2224
2133eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data)
2134{
2135 REQ (EIO_FDATASYNC); req->int1 = fd; SEND;
2136}
2137
2138eio_req *eio_close (int fd, int pri, eio_cb cb, void *data) 2225eio_req *eio_close (int fd, int pri, eio_cb cb, void *data)
2139{ 2226{
2140 REQ (EIO_CLOSE); req->int1 = fd; SEND; 2227 REQ (EIO_CLOSE); req->int1 = fd; SEND;
2141} 2228}
2142 2229
2178eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data) 2265eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data)
2179{ 2266{
2180 REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND; 2267 REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND;
2181} 2268}
2182 2269
2183eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) 2270eio_req *eio_fchown (int fd, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data)
2184{ 2271{
2185 REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND; 2272 REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND;
2186} 2273}
2187 2274
2188eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data) 2275eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data)
2208eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data) 2295eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data)
2209{ 2296{
2210 REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND; 2297 REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND;
2211} 2298}
2212 2299
2213eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) 2300eio_req *eio_chown (const char *path, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data)
2214{ 2301{
2215 REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND; 2302 REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND;
2216} 2303}
2217 2304
2218eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data) 2305eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data)
2365} 2452}
2366 2453
2367/*****************************************************************************/ 2454/*****************************************************************************/
2368/* misc garbage */ 2455/* misc garbage */
2369 2456
2370ssize_t 2457eio_ssize_t
2371eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) 2458eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count)
2372{ 2459{
2373 etp_worker wrk;
2374 ssize_t ret;
2375
2376 wrk.dbuf = 0;
2377
2378 ret = eio__sendfile (ofd, ifd, offset, count, &wrk); 2460 return eio__sendfile (ofd, ifd, offset, count);
2379
2380 if (wrk.dbuf)
2381 free (wrk.dbuf);
2382
2383 return ret;
2384} 2461}
2385 2462

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines