… | |
… | |
22 | #endif |
22 | #endif |
23 | |
23 | |
24 | #if __linux__ |
24 | #if __linux__ |
25 | # include <linux/fs.h> |
25 | # include <linux/fs.h> |
26 | # ifdef FS_IOC_FIEMAP |
26 | # ifdef FS_IOC_FIEMAP |
|
|
27 | # include <linux/types.h> |
27 | # include <linux/fiemap.h> |
28 | # include <linux/fiemap.h> |
28 | # define HAVE_FIEMAP 1 |
29 | # define HAVE_FIEMAP 1 |
29 | # endif |
30 | # endif |
30 | #endif |
31 | #endif |
31 | |
32 | |
… | |
… | |
152 | #endif |
153 | #endif |
153 | #ifndef minor |
154 | #ifndef minor |
154 | # define minor(dev) ((dev) & 0xff) |
155 | # define minor(dev) ((dev) & 0xff) |
155 | #endif |
156 | #endif |
156 | |
157 | |
157 | #ifndef PAGESIZE |
158 | #if PAGESIZE <= 0 |
158 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
159 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
159 | #endif |
160 | #endif |
160 | |
161 | |
161 | /*****************************************************************************/ |
162 | /*****************************************************************************/ |
162 | |
163 | |
… | |
… | |
164 | fiemap (eio_req *req) |
165 | fiemap (eio_req *req) |
165 | { |
166 | { |
166 | req->result = -1; |
167 | req->result = -1; |
167 | |
168 | |
168 | #if HAVE_FIEMAP |
169 | #if HAVE_FIEMAP |
|
|
170 | /* assume some c99 */ |
|
|
171 | struct fiemap *fiemap = 0; |
|
|
172 | size_t end_offset; |
|
|
173 | int count = req->int3; |
|
|
174 | |
|
|
175 | req->flags |= EIO_FLAG_PTR1_FREE; |
|
|
176 | |
|
|
177 | /* heuristic: start with 512 bytes (8 extents), and if that isn't enough, */ |
|
|
178 | /* increase in 3.5kb steps */ |
|
|
179 | if (count < 0) |
|
|
180 | count = 8; |
|
|
181 | |
|
|
182 | fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
|
|
183 | errno = ENOMEM; |
|
|
184 | if (!fiemap) |
|
|
185 | return; |
|
|
186 | |
|
|
187 | req->ptr1 = fiemap; |
|
|
188 | |
|
|
189 | fiemap->fm_start = req->offs; |
|
|
190 | fiemap->fm_length = req->size; |
|
|
191 | fiemap->fm_flags = req->int2; |
|
|
192 | fiemap->fm_extent_count = count; |
|
|
193 | |
|
|
194 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap) < 0) |
|
|
195 | return; |
|
|
196 | |
|
|
197 | if (req->int3 >= 0 /* not autosizing */ |
|
|
198 | || !fiemap->fm_mapped_extents /* no more extents */ |
|
|
199 | || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) |
|
|
200 | goto done; |
|
|
201 | |
|
|
202 | /* else we have to loop - |
|
|
203 | * it would be tempting (actually I tried that first) to just query the |
|
|
204 | * number of extents needed, but linux often feels like not returning all |
|
|
205 | * extents, without telling us it left any out. this complicates |
|
|
206 | * this quite a bit. |
|
|
207 | */ |
|
|
208 | |
|
|
209 | end_offset = fiemap->fm_length + (fiemap->fm_length == FIEMAP_MAX_OFFSET ? 0 : fiemap->fm_start); |
|
|
210 | |
169 | for (;;) |
211 | for (;;) |
170 | { |
212 | { |
171 | int count = req->int3; |
213 | /* we go in 54 extent steps - 3kb, in the hope that this fits nicely on the eio stack (normally 16+ kb) */ |
|
|
214 | char scratch[3072]; |
|
|
215 | struct fiemap *incmap = (struct fiemap *)scratch; |
172 | |
216 | |
173 | if (count < 0) |
217 | incmap->fm_start = fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_logical |
174 | { |
218 | + fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_length; |
175 | struct fiemap fiemap; |
219 | incmap->fm_length = fiemap->fm_length - (incmap->fm_start - fiemap->fm_start); |
|
|
220 | incmap->fm_flags = fiemap->fm_flags; |
|
|
221 | incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); |
176 | |
222 | |
177 | fiemap.fm_start = req->offs; |
|
|
178 | fiemap.fm_length = req->size; |
|
|
179 | fiemap.fm_flags = req->int2; |
|
|
180 | fiemap.fm_extent_count = 0; |
|
|
181 | |
|
|
182 | if (ioctl (req->int1, FS_IOC_FIEMAP, &fiemap)) |
223 | if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) |
183 | return; |
224 | return; |
184 | |
225 | |
185 | count = fiemap.fm_mapped_extents; |
226 | if (!incmap->fm_mapped_extents) |
186 | } |
227 | goto done; |
187 | |
228 | |
|
|
229 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
188 | struct fiemap *fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
230 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
189 | errno = ENOMEM; |
231 | errno = ENOMEM; |
190 | if (!fiemap) |
232 | if (!fiemap) |
191 | return; |
233 | return; |
192 | |
234 | |
193 | req->ptr1 = fiemap; |
235 | req->ptr1 = fiemap; |
194 | req->flags |= EIO_FLAG_PTR1_FREE; |
|
|
195 | |
236 | |
196 | fiemap->fm_start = req->offs; |
237 | for (count = 0; count < incmap->fm_mapped_extents; ++count) |
197 | fiemap->fm_length = req->size; |
238 | { |
198 | fiemap->fm_flags = req->int2; |
239 | struct fiemap_extent *e = incmap->fm_extents + count; |
199 | fiemap->fm_extent_count = count; |
|
|
200 | |
240 | |
201 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
241 | if (e->fe_logical + e->fe_length >= end_offset) |
202 | return; |
242 | goto done; |
203 | |
243 | |
204 | if (req->int3 >= 0) |
244 | fiemap->fm_extents [fiemap->fm_mapped_extents++] = *e; |
205 | break; /* when not autosizing we are done */ |
|
|
206 | |
245 | |
207 | if (fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST) |
246 | if (e->fe_flags & FIEMAP_EXTENT_LAST) |
208 | break; /* autosizing successful, we are done */ |
247 | goto done; |
209 | |
248 | |
210 | free (fiemap); |
249 | } |
211 | } |
250 | } |
212 | |
251 | |
|
|
252 | done: |
213 | req->result = 0; |
253 | req->result = 0; |
214 | |
254 | |
215 | #else |
255 | #else |
216 | errno = ENOSYS; |
256 | errno = ENOSYS; |
217 | #endif |
257 | #endif |
… | |
… | |
470 | #ifndef _WIN32 |
510 | #ifndef _WIN32 |
471 | if (req->result >= 0) |
511 | if (req->result >= 0) |
472 | { |
512 | { |
473 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
513 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
474 | HV *hv = newHV (); |
514 | HV *hv = newHV (); |
|
|
515 | /* POSIX requires fsid to be unsigned long, but AIX in its infinite wisdom |
|
|
516 | * chooses to make it a struct. |
|
|
517 | */ |
|
|
518 | unsigned long fsid = 0; |
|
|
519 | memcpy (&fsid, &f->f_fsid, sizeof (unsigned long) < sizeof (f->f_fsid) ? sizeof (unsigned long) : sizeof (f->f_fsid)); |
475 | |
520 | |
476 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
521 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
477 | |
522 | |
478 | hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0); |
523 | hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0); |
479 | hv_store (hv, "frsize" , sizeof ("frsize" ) - 1, newSVval64 (f->f_frsize ), 0); |
524 | hv_store (hv, "frsize" , sizeof ("frsize" ) - 1, newSVval64 (f->f_frsize ), 0); |
… | |
… | |
481 | hv_store (hv, "bfree" , sizeof ("bfree" ) - 1, newSVval64 (f->f_bfree ), 0); |
526 | hv_store (hv, "bfree" , sizeof ("bfree" ) - 1, newSVval64 (f->f_bfree ), 0); |
482 | hv_store (hv, "bavail" , sizeof ("bavail" ) - 1, newSVval64 (f->f_bavail ), 0); |
527 | hv_store (hv, "bavail" , sizeof ("bavail" ) - 1, newSVval64 (f->f_bavail ), 0); |
483 | hv_store (hv, "files" , sizeof ("files" ) - 1, newSVval64 (f->f_files ), 0); |
528 | hv_store (hv, "files" , sizeof ("files" ) - 1, newSVval64 (f->f_files ), 0); |
484 | hv_store (hv, "ffree" , sizeof ("ffree" ) - 1, newSVval64 (f->f_ffree ), 0); |
529 | hv_store (hv, "ffree" , sizeof ("ffree" ) - 1, newSVval64 (f->f_ffree ), 0); |
485 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
530 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
486 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
531 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (fsid ), 0); |
487 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
532 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
488 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
533 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
489 | } |
534 | } |
490 | #endif |
535 | #endif |
491 | |
536 | |
… | |
… | |
545 | break; |
590 | break; |
546 | |
591 | |
547 | case EIO_CUSTOM: |
592 | case EIO_CUSTOM: |
548 | if (req->feed == fiemap) |
593 | if (req->feed == fiemap) |
549 | { |
594 | { |
|
|
595 | #if HAVE_FIEMAP |
550 | if (!req->result) |
596 | if (!req->result) |
551 | { |
597 | { |
552 | struct fiemap *fiemap = (struct fiemap *)req->ptr1; |
598 | struct fiemap *fiemap = (struct fiemap *)req->ptr1; |
553 | |
599 | |
554 | if (fiemap->fm_extent_count) |
600 | if (fiemap->fm_extent_count) |
… | |
… | |
575 | { |
621 | { |
576 | SvIV_set (sv_result, fiemap->fm_mapped_extents); |
622 | SvIV_set (sv_result, fiemap->fm_mapped_extents); |
577 | PUSHs (sv_result); |
623 | PUSHs (sv_result); |
578 | } |
624 | } |
579 | } |
625 | } |
|
|
626 | #endif |
580 | } |
627 | } |
581 | else |
628 | else |
582 | PUSHs (sv_result); |
629 | PUSHs (sv_result); |
583 | break; |
630 | break; |
584 | |
631 | |
… | |
… | |
696 | } |
743 | } |
697 | |
744 | |
698 | /*****************************************************************************/ |
745 | /*****************************************************************************/ |
699 | |
746 | |
700 | #if !_POSIX_MAPPED_FILES |
747 | #if !_POSIX_MAPPED_FILES |
701 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
748 | # define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS () |
702 | # define munmap(addr,length) (errno = ENOSYS, -1) |
749 | # define munmap(addr,length) EIO_ENOSYS () |
703 | #endif |
750 | #endif |
704 | |
751 | |
705 | #if !_POSIX_MEMORY_PROTECTION |
752 | #if !_POSIX_MEMORY_PROTECTION |
706 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
753 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
707 | # define PROT_NONE 0 |
754 | # define PROT_NONE 0 |
708 | # define PROT_WRITE 0 |
755 | # define PROT_WRITE 0 |
709 | # define MAP_PRIVATE 0 |
756 | # define MAP_PRIVATE 0 |
710 | # define MAP_SHARED 0 |
757 | # define MAP_SHARED 0 |
711 | # define MAP_FIXED 0 |
758 | # define MAP_FIXED 0 |
… | |
… | |
954 | const_iv (FIEMAP_EXTENT_DATA_TAIL) |
1001 | const_iv (FIEMAP_EXTENT_DATA_TAIL) |
955 | const_iv (FIEMAP_EXTENT_UNWRITTEN) |
1002 | const_iv (FIEMAP_EXTENT_UNWRITTEN) |
956 | const_iv (FIEMAP_EXTENT_MERGED) |
1003 | const_iv (FIEMAP_EXTENT_MERGED) |
957 | const_iv (FIEMAP_EXTENT_SHARED) |
1004 | const_iv (FIEMAP_EXTENT_SHARED) |
958 | |
1005 | |
|
|
1006 | const_iv (SPLICE_F_MOVE) |
|
|
1007 | const_iv (SPLICE_F_NONBLOCK) |
|
|
1008 | const_iv (SPLICE_F_MORE) |
|
|
1009 | const_iv (SPLICE_F_GIFT) |
|
|
1010 | |
|
|
1011 | const_iv (SEEK_DATA) |
|
|
1012 | const_iv (SEEK_HOLE) |
|
|
1013 | |
|
|
1014 | /* libeio constants */ |
959 | const_eio (SEEK_SET) |
1015 | const_eio (SEEK_SET) |
960 | const_eio (SEEK_CUR) |
1016 | const_eio (SEEK_CUR) |
961 | const_eio (SEEK_END) |
1017 | const_eio (SEEK_END) |
962 | |
1018 | |
963 | const_eio (MCL_FUTURE) |
1019 | const_eio (MCL_FUTURE) |
… | |
… | |
972 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
1028 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
973 | const_eio (SYNC_FILE_RANGE_WRITE) |
1029 | const_eio (SYNC_FILE_RANGE_WRITE) |
974 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
1030 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
975 | |
1031 | |
976 | const_eio (FALLOC_FL_KEEP_SIZE) |
1032 | const_eio (FALLOC_FL_KEEP_SIZE) |
|
|
1033 | const_eio (FALLOC_FL_PUNCH_HOLE) |
977 | |
1034 | |
978 | const_eio (READDIR_DENTS) |
1035 | const_eio (READDIR_DENTS) |
979 | const_eio (READDIR_DIRS_FIRST) |
1036 | const_eio (READDIR_DIRS_FIRST) |
980 | const_eio (READDIR_STAT_ORDER) |
1037 | const_eio (READDIR_STAT_ORDER) |
981 | const_eio (READDIR_FOUND_UNKNOWN) |
1038 | const_eio (READDIR_FOUND_UNKNOWN) |
… | |
… | |
1082 | aio_fsync = EIO_FSYNC |
1139 | aio_fsync = EIO_FSYNC |
1083 | aio_fdatasync = EIO_FDATASYNC |
1140 | aio_fdatasync = EIO_FDATASYNC |
1084 | aio_syncfs = EIO_SYNCFS |
1141 | aio_syncfs = EIO_SYNCFS |
1085 | PPCODE: |
1142 | PPCODE: |
1086 | { |
1143 | { |
1087 | int fd = s_fileno_croak (fh, 0); |
1144 | int fd = s_fileno_croak (fh, 0); |
1088 | dREQ; |
1145 | dREQ; |
1089 | |
1146 | |
1090 | req->type = ix; |
1147 | req->type = ix; |
1091 | req->sv1 = newSVsv (fh); |
1148 | req->sv1 = newSVsv (fh); |
1092 | req->int1 = fd; |
1149 | req->int1 = fd; |
… | |
… | |
1096 | |
1153 | |
1097 | void |
1154 | void |
1098 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1155 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1099 | PPCODE: |
1156 | PPCODE: |
1100 | { |
1157 | { |
1101 | int fd = s_fileno_croak (fh, 0); |
1158 | int fd = s_fileno_croak (fh, 0); |
1102 | dREQ; |
1159 | dREQ; |
1103 | |
1160 | |
1104 | req->type = EIO_SYNC_FILE_RANGE; |
1161 | req->type = EIO_SYNC_FILE_RANGE; |
1105 | req->sv1 = newSVsv (fh); |
1162 | req->sv1 = newSVsv (fh); |
1106 | req->int1 = fd; |
1163 | req->int1 = fd; |
… | |
… | |
1110 | |
1167 | |
1111 | REQ_SEND; |
1168 | REQ_SEND; |
1112 | } |
1169 | } |
1113 | |
1170 | |
1114 | void |
1171 | void |
1115 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1172 | aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1116 | PPCODE: |
1173 | PPCODE: |
1117 | { |
1174 | { |
1118 | int fd = s_fileno_croak (fh, 0); |
1175 | int fd = s_fileno_croak (fh, 0); |
1119 | dREQ; |
1176 | dREQ; |
1120 | |
1177 | |
1121 | req->type = EIO_FALLOCATE; |
1178 | req->type = EIO_FALLOCATE; |
1122 | req->sv1 = newSVsv (fh); |
1179 | req->sv1 = newSVsv (fh); |
1123 | req->int1 = fd; |
1180 | req->int1 = fd; |
… | |
… | |
1131 | void |
1188 | void |
1132 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1189 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1133 | PPCODE: |
1190 | PPCODE: |
1134 | { |
1191 | { |
1135 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
1192 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
1136 | int fd = s_fileno_croak (fh, 0); |
1193 | int fd = s_fileno_croak (fh, 0); |
1137 | dREQ; |
1194 | dREQ; |
1138 | |
1195 | |
1139 | if (expect_false (close_fd < 0)) |
1196 | if (expect_false (close_fd < 0)) |
1140 | { |
1197 | { |
1141 | int pipefd [2]; |
1198 | int pipefd [2]; |
… | |
… | |
1164 | |
1221 | |
1165 | void |
1222 | void |
1166 | aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) |
1223 | aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) |
1167 | PPCODE: |
1224 | PPCODE: |
1168 | { |
1225 | { |
1169 | STRLEN svlen; |
|
|
1170 | int fd = s_fileno_croak (fh, 0); |
1226 | int fd = s_fileno_croak (fh, 0); |
1171 | dREQ; |
1227 | dREQ; |
1172 | |
1228 | |
1173 | req->type = EIO_SEEK; |
1229 | req->type = EIO_SEEK; |
1174 | req->sv1 = newSVsv (fh); |
1230 | req->sv1 = newSVsv (fh); |
… | |
… | |
1205 | } |
1261 | } |
1206 | else |
1262 | else |
1207 | { |
1263 | { |
1208 | /* read: check type and grow scalar as necessary */ |
1264 | /* read: check type and grow scalar as necessary */ |
1209 | SvUPGRADE (data, SVt_PV); |
1265 | SvUPGRADE (data, SVt_PV); |
|
|
1266 | if (SvLEN (data) >= SvCUR (data)) |
1210 | svptr = SvGROW (data, len + dataoffset + 1); |
1267 | svptr = SvGROW (data, len + dataoffset + 1); |
|
|
1268 | else if (SvCUR (data) < len + dataoffset) |
|
|
1269 | croak ("length + dataoffset outside of scalar, and cannot grow"); |
1211 | } |
1270 | } |
1212 | |
1271 | |
1213 | { |
1272 | { |
1214 | dREQ; |
1273 | dREQ; |
1215 | |
1274 | |
… | |
… | |
1249 | |
1308 | |
1250 | void |
1309 | void |
1251 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1310 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1252 | PPCODE: |
1311 | PPCODE: |
1253 | { |
1312 | { |
1254 | int ifd = s_fileno_croak (in_fh , 0); |
1313 | int ifd = s_fileno_croak (in_fh , 0); |
1255 | int ofd = s_fileno_croak (out_fh, 1); |
1314 | int ofd = s_fileno_croak (out_fh, 1); |
1256 | dREQ; |
1315 | dREQ; |
1257 | |
1316 | |
1258 | req->type = EIO_SENDFILE; |
1317 | req->type = EIO_SENDFILE; |
1259 | req->sv1 = newSVsv (out_fh); |
1318 | req->sv1 = newSVsv (out_fh); |
1260 | req->int1 = ofd; |
1319 | req->int1 = ofd; |
… | |
… | |
1268 | |
1327 | |
1269 | void |
1328 | void |
1270 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1329 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1271 | PPCODE: |
1330 | PPCODE: |
1272 | { |
1331 | { |
1273 | int fd = s_fileno_croak (fh, 0); |
1332 | int fd = s_fileno_croak (fh, 0); |
1274 | dREQ; |
1333 | dREQ; |
1275 | |
1334 | |
1276 | req->type = EIO_READAHEAD; |
1335 | req->type = EIO_READAHEAD; |
1277 | req->sv1 = newSVsv (fh); |
1336 | req->sv1 = newSVsv (fh); |
1278 | req->int1 = fd; |
1337 | req->int1 = fd; |
… | |
… | |
1518 | |
1577 | |
1519 | void |
1578 | void |
1520 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1579 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1521 | PPCODE: |
1580 | PPCODE: |
1522 | { |
1581 | { |
1523 | int fd = s_fileno_croak (fh, 0); |
1582 | int fd = s_fileno_croak (fh, 0); |
1524 | dREQ; |
1583 | dREQ; |
1525 | |
1584 | |
1526 | req->type = EIO_CUSTOM; |
1585 | req->type = EIO_CUSTOM; |
1527 | req->sv1 = newSVsv (fh); |
1586 | req->sv1 = newSVsv (fh); |
1528 | req->int1 = fd; |
1587 | req->int1 = fd; |
1529 | |
1588 | |
1530 | req->feed = fiemap; |
1589 | req->feed = fiemap; |
|
|
1590 | #if HAVE_FIEMAP |
1531 | /* keep our fingers crossed that the next two types are 64 bit */ |
1591 | /* keep our fingers crossed that the next two types are 64 bit */ |
1532 | req->offs = start; |
1592 | req->offs = start; |
1533 | req->size = SvOK (length) ? SvVAL64 (length) : ~0ULL; |
1593 | req->size = SvOK (length) ? SvVAL64 (length) : ~0ULL; |
1534 | req->int2 = flags; |
1594 | req->int2 = flags; |
1535 | req->int3 = SvOK (count) ? SvIV (count) : -1; |
1595 | req->int3 = SvOK (count) ? SvIV (count) : -1; |
|
|
1596 | #endif |
1536 | |
1597 | |
1537 | REQ_SEND; |
1598 | REQ_SEND; |
1538 | } |
1599 | } |
1539 | |
1600 | |
1540 | void |
1601 | void |
… | |
… | |
1674 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1735 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1675 | OUTPUT: |
1736 | OUTPUT: |
1676 | RETVAL |
1737 | RETVAL |
1677 | |
1738 | |
1678 | void |
1739 | void |
1679 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1740 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) |
1680 | PPCODE: |
1741 | PPCODE: |
1681 | sv_unmagic (scalar, MMAP_MAGIC); |
1742 | sv_unmagic (scalar, MMAP_MAGIC); |
1682 | { |
1743 | { |
1683 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1744 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1684 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1745 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1717 | ALIAS: |
1778 | ALIAS: |
1718 | mprotect = 1 |
1779 | mprotect = 1 |
1719 | CODE: |
1780 | CODE: |
1720 | { |
1781 | { |
1721 | STRLEN svlen; |
1782 | STRLEN svlen; |
1722 | void *addr = SvPVbyte (scalar, svlen); |
1783 | void *addr = SvPVbyte (scalar, svlen); |
1723 | size_t len = SvUV (length); |
1784 | size_t len = SvUV (length); |
1724 | |
1785 | |
1725 | if (offset < 0) |
1786 | if (offset < 0) |
1726 | offset += svlen; |
1787 | offset += svlen; |
1727 | |
1788 | |
… | |
… | |
1746 | int |
1807 | int |
1747 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1808 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1748 | CODE: |
1809 | CODE: |
1749 | { |
1810 | { |
1750 | STRLEN svlen; |
1811 | STRLEN svlen; |
1751 | void *addr = SvPVbyte (scalar, svlen); |
1812 | void *addr = SvPVbyte (scalar, svlen); |
1752 | size_t len = SvUV (length); |
1813 | size_t len = SvUV (length); |
1753 | |
1814 | |
1754 | if (offset < 0) |
1815 | if (offset < 0) |
1755 | offset += svlen; |
1816 | offset += svlen; |
1756 | |
1817 | |
… | |
… | |
1763 | addr = (void *)(((intptr_t)addr) + offset); |
1824 | addr = (void *)(((intptr_t)addr) + offset); |
1764 | eio_page_align (&addr, &len); |
1825 | eio_page_align (&addr, &len); |
1765 | #if _POSIX_MEMLOCK_RANGE |
1826 | #if _POSIX_MEMLOCK_RANGE |
1766 | RETVAL = munlock (addr, len); |
1827 | RETVAL = munlock (addr, len); |
1767 | #else |
1828 | #else |
1768 | RETVAL = ((errno = ENOSYS), -1); |
1829 | RETVAL = EIO_ENOSYS (); |
1769 | #endif |
1830 | #endif |
1770 | } |
1831 | } |
1771 | OUTPUT: |
1832 | OUTPUT: |
1772 | RETVAL |
1833 | RETVAL |
1773 | |
1834 | |
… | |
… | |
1775 | munlockall () |
1836 | munlockall () |
1776 | CODE: |
1837 | CODE: |
1777 | #if _POSIX_MEMLOCK |
1838 | #if _POSIX_MEMLOCK |
1778 | munlockall (); |
1839 | munlockall (); |
1779 | #else |
1840 | #else |
|
|
1841 | RETVAL = EIO_ENOSYS (); |
|
|
1842 | #endif |
|
|
1843 | OUTPUT: |
|
|
1844 | RETVAL |
|
|
1845 | |
|
|
1846 | int |
|
|
1847 | splice (aio_rfd rfh, SV *off_in, aio_wfd wfh, SV *off_out, size_t length, unsigned int flags) |
|
|
1848 | CODE: |
|
|
1849 | { |
|
|
1850 | #if HAVE_LINUX_SPLICE |
|
|
1851 | loff_t off_in_, off_out_; |
|
|
1852 | RETVAL = splice ( |
|
|
1853 | rfh, SvOK (off_in ) ? (off_in_ = SvVAL64 (off_in )), &off_in_ : 0, |
|
|
1854 | wfh, SvOK (off_out) ? (off_out_ = SvVAL64 (off_out)), &off_out_ : 0, |
|
|
1855 | length, flags |
|
|
1856 | ); |
|
|
1857 | #else |
|
|
1858 | RETVAL = EIO_ENOSYS (); |
|
|
1859 | #endif |
|
|
1860 | } |
|
|
1861 | OUTPUT: |
|
|
1862 | RETVAL |
|
|
1863 | |
|
|
1864 | int |
|
|
1865 | tee (aio_rfd rfh, aio_wfd wfh, size_t length, unsigned int flags) |
|
|
1866 | CODE: |
|
|
1867 | #if HAVE_LINUX_SPLICE |
|
|
1868 | RETVAL = tee (rfh, wfh, length, flags); |
|
|
1869 | #else |
|
|
1870 | RETVAL = EIO_ENOSYS (); |
|
|
1871 | #endif |
|
|
1872 | OUTPUT: |
|
|
1873 | RETVAL |
|
|
1874 | |
|
|
1875 | int |
|
|
1876 | pipesize (aio_rfd rfh, int new_size = -1) |
|
|
1877 | PROTOTYPE: $;$ |
|
|
1878 | CODE: |
|
|
1879 | #if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ) |
|
|
1880 | if (new_size >= 0) |
|
|
1881 | RETVAL = fcntl (rfh, F_SETPIPE_SZ, new_size); |
|
|
1882 | else |
|
|
1883 | RETVAL = fcntl (rfh, F_GETPIPE_SZ); |
|
|
1884 | #else |
|
|
1885 | errno = ENOSYS; |
1780 | RETVAL = -1; |
1886 | RETVAL = -1; |
1781 | errno = ENOSYS; |
|
|
1782 | #endif |
1887 | #endif |
1783 | OUTPUT: |
1888 | OUTPUT: |
1784 | RETVAL |
1889 | RETVAL |
1785 | |
1890 | |
1786 | void _on_next_submit (SV *cb) |
1891 | void _on_next_submit (SV *cb) |