… | |
… | |
54 | #include <stdlib.h> |
54 | #include <stdlib.h> |
55 | #include <string.h> |
55 | #include <string.h> |
56 | #include <errno.h> |
56 | #include <errno.h> |
57 | #include <sys/types.h> |
57 | #include <sys/types.h> |
58 | #include <sys/stat.h> |
58 | #include <sys/stat.h> |
59 | #include <sys/statvfs.h> |
|
|
60 | #include <limits.h> |
59 | #include <limits.h> |
61 | #include <fcntl.h> |
60 | #include <fcntl.h> |
62 | #include <assert.h> |
61 | #include <assert.h> |
63 | |
62 | |
64 | /* intptr_t comes from unistd.h, says POSIX/UNIX/tradition */ |
63 | /* intptr_t comes from unistd.h, says POSIX/UNIX/tradition */ |
… | |
… | |
83 | |
82 | |
84 | #ifndef EIO_FEED |
83 | #ifndef EIO_FEED |
85 | # define EIO_FEED(req) do { if ((req)->feed ) (req)->feed (req); } while (0) |
84 | # define EIO_FEED(req) do { if ((req)->feed ) (req)->feed (req); } while (0) |
86 | #endif |
85 | #endif |
87 | |
86 | |
|
|
87 | #ifndef EIO_FD_TO_WIN32_HANDLE |
|
|
88 | # define EIO_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd) |
|
|
89 | #endif |
|
|
90 | #ifndef EIO_WIN32_HANDLE_TO_FD |
|
|
91 | # define EIO_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (handle, 0) |
|
|
92 | #endif |
|
|
93 | |
|
|
94 | #define EIO_ERRNO(errval,retval) ((errno = errval), retval) |
|
|
95 | |
|
|
96 | #define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1) |
|
|
97 | |
88 | #ifdef _WIN32 |
98 | #ifdef _WIN32 |
89 | |
99 | |
90 | /*doh*/ |
100 | #define PAGESIZE 4096 /* GetSystemInfo? */ |
|
|
101 | |
|
|
102 | #ifdef EIO_STRUCT_STATI64 |
|
|
103 | #define stat(path,buf) _stati64 (path,buf) |
|
|
104 | #define fstat(fd,buf) _fstati64 (path,buf) |
|
|
105 | #endif |
|
|
106 | #define lstat(path,buf) stat (path,buf) |
|
|
107 | #define fsync(fd) (FlushFileBuffers (EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1)) |
|
|
108 | #define mkdir(path,mode) _mkdir (path) |
|
|
109 | #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1)) |
|
|
110 | |
|
|
111 | #define chown(path,uid,gid) EIO_ENOSYS () |
|
|
112 | #define fchown(fd,uid,gid) EIO_ENOSYS () |
|
|
113 | #define truncate(path,offs) EIO_ENOSYS () /* far-miss: SetEndOfFile */ |
|
|
114 | #define ftruncate(fd,offs) EIO_ENOSYS () /* near-miss: SetEndOfFile */ |
|
|
115 | #define mknod(path,mode,dev) EIO_ENOSYS () |
|
|
116 | #define sync() EIO_ENOSYS () |
|
|
117 | |
|
|
118 | /* we could even stat and see if it exists */ |
|
|
119 | static int |
|
|
120 | symlink (const char *old, const char *neu) |
|
|
121 | { |
|
|
122 | if (CreateSymbolicLink (neu, old, 1)) |
|
|
123 | return 0; |
|
|
124 | |
|
|
125 | if (CreateSymbolicLink (neu, old, 0)) |
|
|
126 | return 0; |
|
|
127 | |
|
|
128 | return EIO_ERRNO (ENOENT, -1); |
|
|
129 | } |
|
|
130 | |
91 | #else |
131 | #else |
92 | |
132 | |
93 | # include <sys/time.h> |
133 | #include <sys/time.h> |
94 | # include <sys/select.h> |
134 | #include <sys/select.h> |
|
|
135 | #include <sys/statvfs.h> |
95 | # include <unistd.h> |
136 | #include <unistd.h> |
96 | # include <utime.h> |
137 | #include <utime.h> |
97 | # include <signal.h> |
138 | #include <signal.h> |
98 | # include <dirent.h> |
139 | #include <dirent.h> |
99 | |
140 | |
100 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
141 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
101 | # include <sys/mman.h> |
142 | #include <sys/mman.h> |
102 | #endif |
143 | #endif |
103 | |
144 | |
104 | /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ |
145 | /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ |
105 | # if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ |
146 | #if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ |
106 | # define _DIRENT_HAVE_D_TYPE /* sigh */ |
147 | #define _DIRENT_HAVE_D_TYPE /* sigh */ |
107 | # define D_INO(de) (de)->d_fileno |
148 | #define D_INO(de) (de)->d_fileno |
108 | # define D_NAMLEN(de) (de)->d_namlen |
149 | #define D_NAMLEN(de) (de)->d_namlen |
109 | # elif __linux || defined d_ino || _XOPEN_SOURCE >= 600 |
150 | #elif __linux || defined d_ino || _XOPEN_SOURCE >= 600 |
110 | # define D_INO(de) (de)->d_ino |
151 | #define D_INO(de) (de)->d_ino |
111 | # endif |
152 | #endif |
112 | |
153 | |
113 | #ifdef _D_EXACT_NAMLEN |
154 | #ifdef _D_EXACT_NAMLEN |
114 | # undef D_NAMLEN |
155 | #undef D_NAMLEN |
115 | # define D_NAMLEN(de) _D_EXACT_NAMLEN (de) |
156 | #define D_NAMLEN(de) _D_EXACT_NAMLEN (de) |
116 | #endif |
157 | #endif |
117 | |
158 | |
118 | # ifdef _DIRENT_HAVE_D_TYPE |
159 | #ifdef _DIRENT_HAVE_D_TYPE |
119 | # define D_TYPE(de) (de)->d_type |
160 | #define D_TYPE(de) (de)->d_type |
120 | # endif |
161 | #endif |
121 | |
162 | |
122 | # ifndef EIO_STRUCT_DIRENT |
163 | #ifndef EIO_STRUCT_DIRENT |
123 | # define EIO_STRUCT_DIRENT struct dirent |
164 | #define EIO_STRUCT_DIRENT struct dirent |
124 | # endif |
165 | #endif |
125 | |
166 | |
126 | #endif |
167 | #endif |
127 | |
168 | |
128 | #if HAVE_SENDFILE |
169 | #if HAVE_SENDFILE |
129 | # if __linux |
170 | # if __linux |
… | |
… | |
381 | } |
422 | } |
382 | |
423 | |
383 | static void ecb_cold |
424 | static void ecb_cold |
384 | etp_thread_init (void) |
425 | etp_thread_init (void) |
385 | { |
426 | { |
|
|
427 | #if !HAVE_PREADWRITE |
|
|
428 | X_MUTEX_CREATE (preadwritelock); |
|
|
429 | #endif |
386 | X_MUTEX_CREATE (wrklock); |
430 | X_MUTEX_CREATE (wrklock); |
387 | X_MUTEX_CREATE (reslock); |
431 | X_MUTEX_CREATE (reslock); |
388 | X_MUTEX_CREATE (reqlock); |
432 | X_MUTEX_CREATE (reqlock); |
389 | X_COND_CREATE (reqwait); |
433 | X_COND_CREATE (reqwait); |
390 | } |
434 | } |
391 | |
435 | |
392 | static void ecb_cold |
436 | static void ecb_cold |
393 | etp_atfork_prepare (void) |
437 | etp_atfork_prepare (void) |
394 | { |
438 | { |
395 | X_LOCK (wrklock); |
|
|
396 | X_LOCK (reqlock); |
|
|
397 | X_LOCK (reslock); |
|
|
398 | #if !HAVE_PREADWRITE |
|
|
399 | X_LOCK (preadwritelock); |
|
|
400 | #endif |
|
|
401 | } |
439 | } |
402 | |
440 | |
403 | static void ecb_cold |
441 | static void ecb_cold |
404 | etp_atfork_parent (void) |
442 | etp_atfork_parent (void) |
405 | { |
443 | { |
406 | #if !HAVE_PREADWRITE |
|
|
407 | X_UNLOCK (preadwritelock); |
|
|
408 | #endif |
|
|
409 | X_UNLOCK (reslock); |
|
|
410 | X_UNLOCK (reqlock); |
|
|
411 | X_UNLOCK (wrklock); |
|
|
412 | } |
444 | } |
413 | |
445 | |
414 | static void ecb_cold |
446 | static void ecb_cold |
415 | etp_atfork_child (void) |
447 | etp_atfork_child (void) |
416 | { |
448 | { |
… | |
… | |
589 | } |
621 | } |
590 | |
622 | |
591 | static void |
623 | static void |
592 | etp_cancel (ETP_REQ *req) |
624 | etp_cancel (ETP_REQ *req) |
593 | { |
625 | { |
594 | X_LOCK (wrklock); |
626 | req->cancelled = 1; |
595 | req->flags |= EIO_FLAG_CANCELLED; |
|
|
596 | X_UNLOCK (wrklock); |
|
|
597 | |
627 | |
598 | eio_grp_cancel (req); |
628 | eio_grp_cancel (req); |
599 | } |
629 | } |
600 | |
630 | |
601 | static void |
631 | static void |
… | |
… | |
847 | # undef pread |
877 | # undef pread |
848 | # undef pwrite |
878 | # undef pwrite |
849 | # define pread eio__pread |
879 | # define pread eio__pread |
850 | # define pwrite eio__pwrite |
880 | # define pwrite eio__pwrite |
851 | |
881 | |
852 | static ssize_t |
882 | static eio_ssize_t |
853 | eio__pread (int fd, void *buf, size_t count, off_t offset) |
883 | eio__pread (int fd, void *buf, size_t count, off_t offset) |
854 | { |
884 | { |
855 | ssize_t res; |
885 | eio_ssize_t res; |
856 | off_t ooffset; |
886 | off_t ooffset; |
857 | |
887 | |
858 | X_LOCK (preadwritelock); |
888 | X_LOCK (preadwritelock); |
859 | ooffset = lseek (fd, 0, SEEK_CUR); |
889 | ooffset = lseek (fd, 0, SEEK_CUR); |
860 | lseek (fd, offset, SEEK_SET); |
890 | lseek (fd, offset, SEEK_SET); |
… | |
… | |
863 | X_UNLOCK (preadwritelock); |
893 | X_UNLOCK (preadwritelock); |
864 | |
894 | |
865 | return res; |
895 | return res; |
866 | } |
896 | } |
867 | |
897 | |
868 | static ssize_t |
898 | static eio_ssize_t |
869 | eio__pwrite (int fd, void *buf, size_t count, off_t offset) |
899 | eio__pwrite (int fd, void *buf, size_t count, off_t offset) |
870 | { |
900 | { |
871 | ssize_t res; |
901 | eio_ssize_t res; |
872 | off_t ooffset; |
902 | off_t ooffset; |
873 | |
903 | |
874 | X_LOCK (preadwritelock); |
904 | X_LOCK (preadwritelock); |
875 | ooffset = lseek (fd, 0, SEEK_CUR); |
905 | ooffset = lseek (fd, 0, SEEK_CUR); |
876 | lseek (fd, offset, SEEK_SET); |
906 | lseek (fd, offset, SEEK_SET); |
… | |
… | |
950 | /* even though we could play tricks with the flags, it's better to always |
980 | /* even though we could play tricks with the flags, it's better to always |
951 | * call fdatasync, as that matches the expectation of its users best */ |
981 | * call fdatasync, as that matches the expectation of its users best */ |
952 | return fdatasync (fd); |
982 | return fdatasync (fd); |
953 | } |
983 | } |
954 | |
984 | |
|
|
985 | static int |
|
|
986 | eio__fallocate (int fd, int mode, off_t offset, size_t len) |
|
|
987 | { |
|
|
988 | #if HAVE_FALLOCATE |
|
|
989 | return fallocate (fd, mode, offset, len); |
|
|
990 | #else |
|
|
991 | errno = ENOSYS; |
|
|
992 | return -1; |
|
|
993 | #endif |
|
|
994 | } |
|
|
995 | |
955 | #if !HAVE_READAHEAD |
996 | #if !HAVE_READAHEAD |
956 | # undef readahead |
997 | # undef readahead |
957 | # define readahead(fd,offset,count) eio__readahead (fd, offset, count, self) |
998 | # define readahead(fd,offset,count) eio__readahead (fd, offset, count, self) |
958 | |
999 | |
959 | static ssize_t |
1000 | static eio_ssize_t |
960 | eio__readahead (int fd, off_t offset, size_t count, etp_worker *self) |
1001 | eio__readahead (int fd, off_t offset, size_t count, etp_worker *self) |
961 | { |
1002 | { |
962 | size_t todo = count; |
1003 | size_t todo = count; |
963 | dBUF; |
1004 | dBUF; |
964 | |
1005 | |
… | |
… | |
976 | } |
1017 | } |
977 | |
1018 | |
978 | #endif |
1019 | #endif |
979 | |
1020 | |
980 | /* sendfile always needs emulation */ |
1021 | /* sendfile always needs emulation */ |
981 | static ssize_t |
1022 | static eio_ssize_t |
982 | eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) |
1023 | eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) |
983 | { |
1024 | { |
984 | ssize_t written = 0; |
1025 | eio_ssize_t written = 0; |
985 | ssize_t res; |
1026 | eio_ssize_t res; |
986 | |
1027 | |
987 | if (!count) |
1028 | if (!count) |
988 | return 0; |
1029 | return 0; |
989 | |
1030 | |
990 | for (;;) |
1031 | for (;;) |
991 | { |
1032 | { |
|
|
1033 | #ifdef __APPLE__ |
|
|
1034 | # undef HAVE_SENDFILE /* broken, as everything on os x */ |
|
|
1035 | #endif |
992 | #if HAVE_SENDFILE |
1036 | #if HAVE_SENDFILE |
993 | # if __linux |
1037 | # if __linux |
994 | off_t soffset = offset; |
1038 | off_t soffset = offset; |
995 | res = sendfile (ofd, ifd, &soffset, count); |
1039 | res = sendfile (ofd, ifd, &soffset, count); |
996 | |
1040 | |
… | |
… | |
1012 | |
1056 | |
1013 | /* according to source inspection, this is correct, and useful behaviour */ |
1057 | /* according to source inspection, this is correct, and useful behaviour */ |
1014 | if (sbytes) |
1058 | if (sbytes) |
1015 | res = sbytes; |
1059 | res = sbytes; |
1016 | |
1060 | |
1017 | # elif defined (__APPLE__) && 0 /* broken, as everything on os x */ |
1061 | # elif defined (__APPLE__) |
1018 | off_t sbytes = count; |
1062 | off_t sbytes = count; |
1019 | res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); |
1063 | res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); |
1020 | |
1064 | |
1021 | /* according to the manpage, sbytes is always valid */ |
1065 | /* according to the manpage, sbytes is always valid */ |
1022 | if (sbytes) |
1066 | if (sbytes) |
… | |
… | |
1039 | if (res < 0 && sbytes) |
1083 | if (res < 0 && sbytes) |
1040 | res = sbytes; |
1084 | res = sbytes; |
1041 | |
1085 | |
1042 | # endif |
1086 | # endif |
1043 | |
1087 | |
1044 | #elif defined (_WIN32) |
1088 | #elif defined (_WIN32) && 0 |
1045 | /* does not work, just for documentation of what would need to be done */ |
1089 | /* does not work, just for documentation of what would need to be done */ |
1046 | /* actually, cannot be done like this, as TransmitFile changes the file offset, */ |
1090 | /* actually, cannot be done like this, as TransmitFile changes the file offset, */ |
1047 | /* libeio guarantees that the file offset does not change, and windows */ |
1091 | /* libeio guarantees that the file offset does not change, and windows */ |
1048 | /* has no way to get an independent handle to the same file description */ |
1092 | /* has no way to get an independent handle to the same file description */ |
1049 | HANDLE h = TO_SOCKET (ifd); |
1093 | HANDLE h = TO_SOCKET (ifd); |
… | |
… | |
1096 | |
1140 | |
1097 | res = 0; |
1141 | res = 0; |
1098 | |
1142 | |
1099 | while (count) |
1143 | while (count) |
1100 | { |
1144 | { |
1101 | ssize_t cnt; |
1145 | eio_ssize_t cnt; |
1102 | |
1146 | |
1103 | cnt = pread (ifd, eio_buf, count > EIO_BUFSIZE ? EIO_BUFSIZE : count, offset); |
1147 | cnt = pread (ifd, eio_buf, count > EIO_BUFSIZE ? EIO_BUFSIZE : count, offset); |
1104 | |
1148 | |
1105 | if (cnt <= 0) |
1149 | if (cnt <= 0) |
1106 | { |
1150 | { |
… | |
… | |
1154 | /* round up length */ |
1198 | /* round up length */ |
1155 | *length = (*length + mask) & ~mask; |
1199 | *length = (*length + mask) & ~mask; |
1156 | } |
1200 | } |
1157 | |
1201 | |
1158 | #if !_POSIX_MEMLOCK |
1202 | #if !_POSIX_MEMLOCK |
1159 | # define eio__mlockall(a) ((errno = ENOSYS), -1) |
1203 | # define eio__mlockall(a) EIO_ENOSYS () |
1160 | #else |
1204 | #else |
1161 | |
1205 | |
1162 | static int |
1206 | static int |
1163 | eio__mlockall (int flags) |
1207 | eio__mlockall (int flags) |
1164 | { |
1208 | { |
… | |
… | |
1178 | return mlockall (flags); |
1222 | return mlockall (flags); |
1179 | } |
1223 | } |
1180 | #endif |
1224 | #endif |
1181 | |
1225 | |
1182 | #if !_POSIX_MEMLOCK_RANGE |
1226 | #if !_POSIX_MEMLOCK_RANGE |
1183 | # define eio__mlock(a,b) ((errno = ENOSYS), -1) |
1227 | # define eio__mlock(a,b) EIO_ENOSYS () |
1184 | #else |
1228 | #else |
1185 | |
1229 | |
1186 | static int |
1230 | static int |
1187 | eio__mlock (void *addr, size_t length) |
1231 | eio__mlock (void *addr, size_t length) |
1188 | { |
1232 | { |
… | |
… | |
1192 | } |
1236 | } |
1193 | |
1237 | |
1194 | #endif |
1238 | #endif |
1195 | |
1239 | |
1196 | #if !(_POSIX_MAPPED_FILES && _POSIX_SYNCHRONIZED_IO) |
1240 | #if !(_POSIX_MAPPED_FILES && _POSIX_SYNCHRONIZED_IO) |
1197 | # define eio__msync(a,b,c) ((errno = ENOSYS), -1) |
1241 | # define eio__msync(a,b,c) EIO_ENOSYS () |
1198 | #else |
1242 | #else |
1199 | |
1243 | |
1200 | static int |
1244 | static int |
1201 | eio__msync (void *mem, size_t len, int flags) |
1245 | eio__msync (void *mem, size_t len, int flags) |
1202 | { |
1246 | { |
… | |
… | |
1314 | res += strlen (res); |
1358 | res += strlen (res); |
1315 | } |
1359 | } |
1316 | |
1360 | |
1317 | while (*rel) |
1361 | while (*rel) |
1318 | { |
1362 | { |
1319 | ssize_t len, linklen; |
1363 | eio_ssize_t len, linklen; |
1320 | char *beg = rel; |
1364 | char *beg = rel; |
1321 | |
1365 | |
1322 | while (*rel && *rel != '/') |
1366 | while (*rel && *rel != '/') |
1323 | ++rel; |
1367 | ++rel; |
1324 | |
1368 | |
… | |
… | |
1791 | X_THREAD_PROC (etp_proc) |
1835 | X_THREAD_PROC (etp_proc) |
1792 | { |
1836 | { |
1793 | ETP_REQ *req; |
1837 | ETP_REQ *req; |
1794 | struct timespec ts; |
1838 | struct timespec ts; |
1795 | etp_worker *self = (etp_worker *)thr_arg; |
1839 | etp_worker *self = (etp_worker *)thr_arg; |
|
|
1840 | int timeout; |
1796 | |
1841 | |
1797 | /* try to distribute timeouts somewhat randomly */ |
1842 | /* try to distribute timeouts somewhat evenly */ |
1798 | ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); |
1843 | ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); |
1799 | |
1844 | |
1800 | for (;;) |
1845 | for (;;) |
1801 | { |
1846 | { |
|
|
1847 | ts.tv_sec = 0; |
|
|
1848 | |
1802 | X_LOCK (reqlock); |
1849 | X_LOCK (reqlock); |
1803 | |
1850 | |
1804 | for (;;) |
1851 | for (;;) |
1805 | { |
1852 | { |
1806 | self->req = req = reqq_shift (&req_queue); |
1853 | self->req = req = reqq_shift (&req_queue); |
1807 | |
1854 | |
1808 | if (req) |
1855 | if (req) |
1809 | break; |
1856 | break; |
1810 | |
1857 | |
|
|
1858 | if (ts.tv_sec == 1) /* no request, but timeout detected, let's quit */ |
|
|
1859 | { |
|
|
1860 | X_UNLOCK (reqlock); |
|
|
1861 | X_LOCK (wrklock); |
|
|
1862 | --started; |
|
|
1863 | X_UNLOCK (wrklock); |
|
|
1864 | goto quit; |
|
|
1865 | } |
|
|
1866 | |
1811 | ++idle; |
1867 | ++idle; |
1812 | |
1868 | |
1813 | ts.tv_sec = time (0) + idle_timeout; |
1869 | if (idle <= max_idle) |
1814 | if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) == ETIMEDOUT) |
1870 | /* we are allowed to idle, so do so without any timeout */ |
|
|
1871 | X_COND_WAIT (reqwait, reqlock); |
|
|
1872 | else |
1815 | { |
1873 | { |
1816 | if (idle > max_idle) |
1874 | /* initialise timeout once */ |
1817 | { |
1875 | if (!ts.tv_sec) |
1818 | --idle; |
1876 | ts.tv_sec = time (0) + idle_timeout; |
1819 | X_UNLOCK (reqlock); |
|
|
1820 | X_LOCK (wrklock); |
|
|
1821 | --started; |
|
|
1822 | X_UNLOCK (wrklock); |
|
|
1823 | goto quit; |
|
|
1824 | } |
|
|
1825 | |
1877 | |
1826 | /* we are allowed to idle, so do so without any timeout */ |
|
|
1827 | X_COND_WAIT (reqwait, reqlock); |
1878 | if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) == ETIMEDOUT) |
|
|
1879 | ts.tv_sec = 1; /* assuming this is not a value computed above.,.. */ |
1828 | } |
1880 | } |
1829 | |
1881 | |
1830 | --idle; |
1882 | --idle; |
1831 | } |
1883 | } |
1832 | |
1884 | |
… | |
… | |
1962 | case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break; |
2014 | case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break; |
1963 | case EIO_MTOUCH: req->result = eio__mtouch (req); break; |
2015 | case EIO_MTOUCH: req->result = eio__mtouch (req); break; |
1964 | case EIO_MLOCK: req->result = eio__mlock (req->ptr2, req->size); break; |
2016 | case EIO_MLOCK: req->result = eio__mlock (req->ptr2, req->size); break; |
1965 | case EIO_MLOCKALL: req->result = eio__mlockall (req->int1); break; |
2017 | case EIO_MLOCKALL: req->result = eio__mlockall (req->int1); break; |
1966 | case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break; |
2018 | case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break; |
|
|
2019 | case EIO_FALLOCATE: req->result = eio__fallocate (req->int1, req->int2, req->offs, req->size); break; |
1967 | |
2020 | |
1968 | case EIO_READDIR: eio__scandir (req, self); break; |
2021 | case EIO_READDIR: eio__scandir (req, self); break; |
1969 | |
2022 | |
1970 | case EIO_BUSY: |
2023 | case EIO_BUSY: |
1971 | #ifdef _WIN32 |
2024 | #ifdef _WIN32 |
… | |
… | |
2071 | eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data) |
2124 | eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data) |
2072 | { |
2125 | { |
2073 | REQ (EIO_SYNC_FILE_RANGE); req->int1 = fd; req->offs = offset; req->size = nbytes; req->int2 = flags; SEND; |
2126 | REQ (EIO_SYNC_FILE_RANGE); req->int1 = fd; req->offs = offset; req->size = nbytes; req->int2 = flags; SEND; |
2074 | } |
2127 | } |
2075 | |
2128 | |
|
|
2129 | eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data) |
|
|
2130 | { |
|
|
2131 | REQ (EIO_FALLOCATE); req->int1 = fd; req->int2 = mode; req->offs = offset; req->size = len; SEND; |
|
|
2132 | } |
|
|
2133 | |
2076 | eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data) |
2134 | eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data) |
2077 | { |
2135 | { |
2078 | REQ (EIO_FDATASYNC); req->int1 = fd; SEND; |
2136 | REQ (EIO_FDATASYNC); req->int1 = fd; SEND; |
2079 | } |
2137 | } |
2080 | |
2138 | |
… | |
… | |
2121 | eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data) |
2179 | eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data) |
2122 | { |
2180 | { |
2123 | REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND; |
2181 | REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND; |
2124 | } |
2182 | } |
2125 | |
2183 | |
2126 | eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) |
2184 | eio_req *eio_fchown (int fd, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data) |
2127 | { |
2185 | { |
2128 | REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND; |
2186 | REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND; |
2129 | } |
2187 | } |
2130 | |
2188 | |
2131 | eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data) |
2189 | eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data) |
… | |
… | |
2151 | eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data) |
2209 | eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data) |
2152 | { |
2210 | { |
2153 | REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND; |
2211 | REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND; |
2154 | } |
2212 | } |
2155 | |
2213 | |
2156 | eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) |
2214 | eio_req *eio_chown (const char *path, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data) |
2157 | { |
2215 | { |
2158 | REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND; |
2216 | REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND; |
2159 | } |
2217 | } |
2160 | |
2218 | |
2161 | eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data) |
2219 | eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data) |
… | |
… | |
2308 | } |
2366 | } |
2309 | |
2367 | |
2310 | /*****************************************************************************/ |
2368 | /*****************************************************************************/ |
2311 | /* misc garbage */ |
2369 | /* misc garbage */ |
2312 | |
2370 | |
2313 | ssize_t |
2371 | eio_ssize_t |
2314 | eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) |
2372 | eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) |
2315 | { |
2373 | { |
2316 | etp_worker wrk; |
2374 | etp_worker wrk; |
2317 | ssize_t ret; |
2375 | eio_ssize_t ret; |
2318 | |
2376 | |
2319 | wrk.dbuf = 0; |
2377 | wrk.dbuf = 0; |
2320 | |
2378 | |
2321 | ret = eio__sendfile (ofd, ifd, offset, count, &wrk); |
2379 | ret = eio__sendfile (ofd, ifd, offset, count, &wrk); |
2322 | |
2380 | |