… | |
… | |
208 | #endif |
208 | #endif |
209 | |
209 | |
210 | #define D_NAME(entp) entp->d_name |
210 | #define D_NAME(entp) entp->d_name |
211 | |
211 | |
212 | /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ |
212 | /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ |
213 | #if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ |
213 | #if __FreeBSD__ || __NetBSD__ || __OpenBSD__ |
214 | #define _DIRENT_HAVE_D_TYPE /* sigh */ |
214 | #define _DIRENT_HAVE_D_TYPE /* sigh */ |
215 | #define D_INO(de) (de)->d_fileno |
215 | #define D_INO(de) (de)->d_fileno |
216 | #define D_NAMLEN(de) (de)->d_namlen |
216 | #define D_NAMLEN(de) (de)->d_namlen |
217 | #elif __linux || defined d_ino || _XOPEN_SOURCE >= 600 |
217 | #elif __linux || defined d_ino || _XOPEN_SOURCE >= 600 |
218 | #define D_INO(de) (de)->d_ino |
218 | #define D_INO(de) (de)->d_ino |
… | |
… | |
1032 | int res; |
1032 | int res; |
1033 | |
1033 | |
1034 | #if HAVE_SYS_SYNCFS |
1034 | #if HAVE_SYS_SYNCFS |
1035 | res = (int)syscall (__NR_syncfs, (int)(fd)); |
1035 | res = (int)syscall (__NR_syncfs, (int)(fd)); |
1036 | #else |
1036 | #else |
1037 | res = -1; |
1037 | res = EIO_ENOSYS (); |
1038 | errno = ENOSYS; |
|
|
1039 | #endif |
1038 | #endif |
1040 | |
1039 | |
1041 | if (res < 0 && errno == ENOSYS && fd >= 0) |
1040 | if (res < 0 && errno == ENOSYS && fd >= 0) |
1042 | sync (); |
1041 | sync (); |
1043 | |
1042 | |
… | |
… | |
1073 | } |
1072 | } |
1074 | |
1073 | |
1075 | static int |
1074 | static int |
1076 | eio__fallocate (int fd, int mode, off_t offset, size_t len) |
1075 | eio__fallocate (int fd, int mode, off_t offset, size_t len) |
1077 | { |
1076 | { |
1078 | #if HAVE_FALLOCATE |
1077 | #if HAVE_LINUX_FALLOCATE |
1079 | return fallocate (fd, mode, offset, len); |
1078 | return fallocate (fd, mode, offset, len); |
1080 | #else |
1079 | #else |
1081 | errno = ENOSYS; |
1080 | return EIO_ENOSYS (); |
1082 | return -1; |
|
|
1083 | #endif |
1081 | #endif |
1084 | } |
1082 | } |
1085 | |
1083 | |
1086 | #if !HAVE_READAHEAD |
1084 | #if !HAVE_READAHEAD |
1087 | # undef readahead |
1085 | # undef readahead |
… | |
… | |
1149 | |
1147 | |
1150 | /* according to source inspection, this is correct, and useful behaviour */ |
1148 | /* according to source inspection, this is correct, and useful behaviour */ |
1151 | if (sbytes) |
1149 | if (sbytes) |
1152 | res = sbytes; |
1150 | res = sbytes; |
1153 | |
1151 | |
1154 | # elif defined (__APPLE__) |
1152 | # elif defined __APPLE__ |
1155 | off_t sbytes = count; |
1153 | off_t sbytes = count; |
1156 | res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); |
1154 | res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); |
1157 | |
1155 | |
1158 | /* according to the manpage, sbytes is always valid */ |
1156 | /* according to the manpage, sbytes is always valid */ |
1159 | if (sbytes) |
1157 | if (sbytes) |
… | |
… | |
1186 | HANDLE h = TO_SOCKET (ifd); |
1184 | HANDLE h = TO_SOCKET (ifd); |
1187 | SetFilePointer (h, offset, 0, FILE_BEGIN); |
1185 | SetFilePointer (h, offset, 0, FILE_BEGIN); |
1188 | res = TransmitFile (TO_SOCKET (ofd), h, count, 0, 0, 0, 0); |
1186 | res = TransmitFile (TO_SOCKET (ofd), h, count, 0, 0, 0, 0); |
1189 | |
1187 | |
1190 | #else |
1188 | #else |
1191 | res = -1; |
1189 | res = EIO_ENOSYS (); |
1192 | errno = ENOSYS; |
|
|
1193 | #endif |
1190 | #endif |
1194 | |
1191 | |
1195 | /* we assume sendfile can copy at least 128mb in one go */ |
1192 | /* we assume sendfile can copy at least 128mb in one go */ |
1196 | if (res <= 128 * 1024 * 1024) |
1193 | if (res <= 128 * 1024 * 1024) |
1197 | { |
1194 | { |
… | |
… | |
2243 | free (req); |
2240 | free (req); |
2244 | |
2241 | |
2245 | X_LOCK (wrklock); |
2242 | X_LOCK (wrklock); |
2246 | etp_worker_free (self); |
2243 | etp_worker_free (self); |
2247 | X_UNLOCK (wrklock); |
2244 | X_UNLOCK (wrklock); |
2248 | |
|
|
2249 | return 0; |
|
|
2250 | } |
2245 | } |
2251 | |
2246 | |
2252 | /*****************************************************************************/ |
2247 | /*****************************************************************************/ |
2253 | |
2248 | |
2254 | int ecb_cold |
2249 | int ecb_cold |
… | |
… | |
2495 | case EIO_CUSTOM: |
2490 | case EIO_CUSTOM: |
2496 | req->feed (req); |
2491 | req->feed (req); |
2497 | break; |
2492 | break; |
2498 | |
2493 | |
2499 | default: |
2494 | default: |
2500 | errno = ENOSYS; |
|
|
2501 | req->result = -1; |
2495 | req->result = EIO_ENOSYS (); |
2502 | break; |
2496 | break; |
2503 | } |
2497 | } |
2504 | |
2498 | |
2505 | req->errorno = errno; |
2499 | req->errorno = errno; |
2506 | } |
2500 | } |