… | |
… | |
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 (atcually 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 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
186 | } |
|
|
187 | |
|
|
188 | struct fiemap *fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
227 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
189 | errno = ENOMEM; |
228 | errno = ENOMEM; |
190 | if (!fiemap) |
229 | if (!fiemap) |
191 | return; |
230 | return; |
192 | |
231 | |
193 | req->ptr1 = fiemap; |
232 | req->ptr1 = fiemap; |
194 | req->flags |= EIO_FLAG_PTR1_FREE; |
|
|
195 | |
233 | |
196 | fiemap->fm_start = req->offs; |
234 | for (count = 0; count < incmap->fm_mapped_extents; ++count) |
197 | fiemap->fm_length = req->size; |
235 | { |
198 | fiemap->fm_flags = req->int2; |
236 | struct fiemap_extent *e = incmap->fm_extents + count; |
199 | fiemap->fm_extent_count = count; |
|
|
200 | |
237 | |
201 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
238 | if (e->fe_logical + e->fe_length >= end_offset) |
202 | return; |
239 | goto done; |
203 | |
240 | |
204 | if (req->int3 >= 0) |
241 | fiemap->fm_extents [fiemap->fm_mapped_extents++] = *e; |
205 | break; /* when not autosizing we are done */ |
|
|
206 | |
242 | |
207 | if (fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST) |
243 | if (e->fe_flags & FIEMAP_EXTENT_LAST) |
208 | break; /* autosizing successful, we are done */ |
244 | goto done; |
209 | |
245 | |
210 | free (fiemap); |
246 | } |
211 | } |
247 | } |
212 | |
248 | |
|
|
249 | done: |
213 | req->result = 0; |
250 | req->result = 0; |
214 | |
251 | |
215 | #else |
252 | #else |
216 | errno = ENOSYS; |
253 | errno = ENOSYS; |
217 | #endif |
254 | #endif |
… | |
… | |
470 | #ifndef _WIN32 |
507 | #ifndef _WIN32 |
471 | if (req->result >= 0) |
508 | if (req->result >= 0) |
472 | { |
509 | { |
473 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
510 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
474 | HV *hv = newHV (); |
511 | HV *hv = newHV (); |
|
|
512 | /* POSIX requires fsid to be unsigned long, but AIX in its infinite wisdom |
|
|
513 | * chooses to make it a struct. |
|
|
514 | */ |
|
|
515 | unsigned long fsid = 0; |
|
|
516 | memcpy (&fsid, &f->f_fsid, sizeof (unsigned long) < sizeof (f->f_fsid) ? sizeof (unsigned long) : sizeof (f->f_fsid)); |
475 | |
517 | |
476 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
518 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
477 | |
519 | |
478 | hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0); |
520 | 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); |
521 | 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); |
523 | 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); |
524 | 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); |
525 | 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); |
526 | 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); |
527 | 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); |
528 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (fsid ), 0); |
487 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
529 | 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); |
530 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
489 | } |
531 | } |
490 | #endif |
532 | #endif |
491 | |
533 | |
… | |
… | |
545 | break; |
587 | break; |
546 | |
588 | |
547 | case EIO_CUSTOM: |
589 | case EIO_CUSTOM: |
548 | if (req->feed == fiemap) |
590 | if (req->feed == fiemap) |
549 | { |
591 | { |
|
|
592 | #if HAVE_FIEMAP |
550 | if (!req->result) |
593 | if (!req->result) |
551 | { |
594 | { |
552 | struct fiemap *fiemap = (struct fiemap *)req->ptr1; |
595 | struct fiemap *fiemap = (struct fiemap *)req->ptr1; |
553 | |
596 | |
554 | if (fiemap->fm_extent_count) |
597 | if (fiemap->fm_extent_count) |
… | |
… | |
575 | { |
618 | { |
576 | SvIV_set (sv_result, fiemap->fm_mapped_extents); |
619 | SvIV_set (sv_result, fiemap->fm_mapped_extents); |
577 | PUSHs (sv_result); |
620 | PUSHs (sv_result); |
578 | } |
621 | } |
579 | } |
622 | } |
|
|
623 | #endif |
580 | } |
624 | } |
581 | else |
625 | else |
582 | PUSHs (sv_result); |
626 | PUSHs (sv_result); |
583 | break; |
627 | break; |
584 | |
628 | |
… | |
… | |
696 | } |
740 | } |
697 | |
741 | |
698 | /*****************************************************************************/ |
742 | /*****************************************************************************/ |
699 | |
743 | |
700 | #if !_POSIX_MAPPED_FILES |
744 | #if !_POSIX_MAPPED_FILES |
701 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
745 | # define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS () |
702 | # define munmap(addr,length) (errno = ENOSYS, -1) |
746 | # define munmap(addr,length) EIO_ENOSYS () |
703 | #endif |
747 | #endif |
704 | |
748 | |
705 | #if !_POSIX_MEMORY_PROTECTION |
749 | #if !_POSIX_MEMORY_PROTECTION |
706 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
750 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
707 | # define PROT_NONE 0 |
751 | # define PROT_NONE 0 |
708 | # define PROT_WRITE 0 |
752 | # define PROT_WRITE 0 |
709 | # define MAP_PRIVATE 0 |
753 | # define MAP_PRIVATE 0 |
710 | # define MAP_SHARED 0 |
754 | # define MAP_SHARED 0 |
711 | # define MAP_FIXED 0 |
755 | # define MAP_FIXED 0 |
… | |
… | |
954 | const_iv (FIEMAP_EXTENT_DATA_TAIL) |
998 | const_iv (FIEMAP_EXTENT_DATA_TAIL) |
955 | const_iv (FIEMAP_EXTENT_UNWRITTEN) |
999 | const_iv (FIEMAP_EXTENT_UNWRITTEN) |
956 | const_iv (FIEMAP_EXTENT_MERGED) |
1000 | const_iv (FIEMAP_EXTENT_MERGED) |
957 | const_iv (FIEMAP_EXTENT_SHARED) |
1001 | const_iv (FIEMAP_EXTENT_SHARED) |
958 | |
1002 | |
|
|
1003 | const_iv (SPLICE_F_MOVE) |
|
|
1004 | const_iv (SPLICE_F_NONBLOCK) |
|
|
1005 | const_iv (SPLICE_F_MORE) |
|
|
1006 | const_iv (SPLICE_F_GIFT) |
|
|
1007 | |
|
|
1008 | const_iv (SEEK_DATA) |
|
|
1009 | const_iv (SEEK_HOLE) |
|
|
1010 | |
|
|
1011 | /* libeio constants */ |
959 | const_eio (SEEK_SET) |
1012 | const_eio (SEEK_SET) |
960 | const_eio (SEEK_CUR) |
1013 | const_eio (SEEK_CUR) |
961 | const_eio (SEEK_END) |
1014 | const_eio (SEEK_END) |
962 | |
1015 | |
963 | const_eio (MCL_FUTURE) |
1016 | const_eio (MCL_FUTURE) |
… | |
… | |
972 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
1025 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
973 | const_eio (SYNC_FILE_RANGE_WRITE) |
1026 | const_eio (SYNC_FILE_RANGE_WRITE) |
974 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
1027 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
975 | |
1028 | |
976 | const_eio (FALLOC_FL_KEEP_SIZE) |
1029 | const_eio (FALLOC_FL_KEEP_SIZE) |
|
|
1030 | const_eio (FALLOC_FL_PUNCH_HOLE) |
977 | |
1031 | |
978 | const_eio (READDIR_DENTS) |
1032 | const_eio (READDIR_DENTS) |
979 | const_eio (READDIR_DIRS_FIRST) |
1033 | const_eio (READDIR_DIRS_FIRST) |
980 | const_eio (READDIR_STAT_ORDER) |
1034 | const_eio (READDIR_STAT_ORDER) |
981 | const_eio (READDIR_FOUND_UNKNOWN) |
1035 | const_eio (READDIR_FOUND_UNKNOWN) |
… | |
… | |
1082 | aio_fsync = EIO_FSYNC |
1136 | aio_fsync = EIO_FSYNC |
1083 | aio_fdatasync = EIO_FDATASYNC |
1137 | aio_fdatasync = EIO_FDATASYNC |
1084 | aio_syncfs = EIO_SYNCFS |
1138 | aio_syncfs = EIO_SYNCFS |
1085 | PPCODE: |
1139 | PPCODE: |
1086 | { |
1140 | { |
1087 | int fd = s_fileno_croak (fh, 0); |
1141 | int fd = s_fileno_croak (fh, 0); |
1088 | dREQ; |
1142 | dREQ; |
1089 | |
1143 | |
1090 | req->type = ix; |
1144 | req->type = ix; |
1091 | req->sv1 = newSVsv (fh); |
1145 | req->sv1 = newSVsv (fh); |
1092 | req->int1 = fd; |
1146 | req->int1 = fd; |
… | |
… | |
1096 | |
1150 | |
1097 | void |
1151 | void |
1098 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1152 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1099 | PPCODE: |
1153 | PPCODE: |
1100 | { |
1154 | { |
1101 | int fd = s_fileno_croak (fh, 0); |
1155 | int fd = s_fileno_croak (fh, 0); |
1102 | dREQ; |
1156 | dREQ; |
1103 | |
1157 | |
1104 | req->type = EIO_SYNC_FILE_RANGE; |
1158 | req->type = EIO_SYNC_FILE_RANGE; |
1105 | req->sv1 = newSVsv (fh); |
1159 | req->sv1 = newSVsv (fh); |
1106 | req->int1 = fd; |
1160 | req->int1 = fd; |
… | |
… | |
1110 | |
1164 | |
1111 | REQ_SEND; |
1165 | REQ_SEND; |
1112 | } |
1166 | } |
1113 | |
1167 | |
1114 | void |
1168 | void |
1115 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1169 | aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1116 | PPCODE: |
1170 | PPCODE: |
1117 | { |
1171 | { |
1118 | int fd = s_fileno_croak (fh, 0); |
1172 | int fd = s_fileno_croak (fh, 0); |
1119 | dREQ; |
1173 | dREQ; |
1120 | |
1174 | |
1121 | req->type = EIO_FALLOCATE; |
1175 | req->type = EIO_FALLOCATE; |
1122 | req->sv1 = newSVsv (fh); |
1176 | req->sv1 = newSVsv (fh); |
1123 | req->int1 = fd; |
1177 | req->int1 = fd; |
… | |
… | |
1131 | void |
1185 | void |
1132 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1186 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1133 | PPCODE: |
1187 | PPCODE: |
1134 | { |
1188 | { |
1135 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
1189 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
1136 | int fd = s_fileno_croak (fh, 0); |
1190 | int fd = s_fileno_croak (fh, 0); |
1137 | dREQ; |
1191 | dREQ; |
1138 | |
1192 | |
1139 | if (expect_false (close_fd < 0)) |
1193 | if (expect_false (close_fd < 0)) |
1140 | { |
1194 | { |
1141 | int pipefd [2]; |
1195 | int pipefd [2]; |
… | |
… | |
1164 | |
1218 | |
1165 | void |
1219 | void |
1166 | aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) |
1220 | aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) |
1167 | PPCODE: |
1221 | PPCODE: |
1168 | { |
1222 | { |
1169 | STRLEN svlen; |
|
|
1170 | int fd = s_fileno_croak (fh, 0); |
1223 | int fd = s_fileno_croak (fh, 0); |
1171 | dREQ; |
1224 | dREQ; |
1172 | |
1225 | |
1173 | req->type = EIO_SEEK; |
1226 | req->type = EIO_SEEK; |
1174 | req->sv1 = newSVsv (fh); |
1227 | req->sv1 = newSVsv (fh); |
… | |
… | |
1205 | } |
1258 | } |
1206 | else |
1259 | else |
1207 | { |
1260 | { |
1208 | /* read: check type and grow scalar as necessary */ |
1261 | /* read: check type and grow scalar as necessary */ |
1209 | SvUPGRADE (data, SVt_PV); |
1262 | SvUPGRADE (data, SVt_PV); |
|
|
1263 | if (SvLEN (data) >= SvCUR (data)) |
1210 | svptr = SvGROW (data, len + dataoffset + 1); |
1264 | svptr = SvGROW (data, len + dataoffset + 1); |
|
|
1265 | else if (SvCUR (data) < len + dataoffset) |
|
|
1266 | croak ("length + dataoffset outside of scalar, and cannot grow"); |
1211 | } |
1267 | } |
1212 | |
1268 | |
1213 | { |
1269 | { |
1214 | dREQ; |
1270 | dREQ; |
1215 | |
1271 | |
… | |
… | |
1249 | |
1305 | |
1250 | void |
1306 | void |
1251 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1307 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1252 | PPCODE: |
1308 | PPCODE: |
1253 | { |
1309 | { |
1254 | int ifd = s_fileno_croak (in_fh , 0); |
1310 | int ifd = s_fileno_croak (in_fh , 0); |
1255 | int ofd = s_fileno_croak (out_fh, 1); |
1311 | int ofd = s_fileno_croak (out_fh, 1); |
1256 | dREQ; |
1312 | dREQ; |
1257 | |
1313 | |
1258 | req->type = EIO_SENDFILE; |
1314 | req->type = EIO_SENDFILE; |
1259 | req->sv1 = newSVsv (out_fh); |
1315 | req->sv1 = newSVsv (out_fh); |
1260 | req->int1 = ofd; |
1316 | req->int1 = ofd; |
… | |
… | |
1268 | |
1324 | |
1269 | void |
1325 | void |
1270 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1326 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1271 | PPCODE: |
1327 | PPCODE: |
1272 | { |
1328 | { |
1273 | int fd = s_fileno_croak (fh, 0); |
1329 | int fd = s_fileno_croak (fh, 0); |
1274 | dREQ; |
1330 | dREQ; |
1275 | |
1331 | |
1276 | req->type = EIO_READAHEAD; |
1332 | req->type = EIO_READAHEAD; |
1277 | req->sv1 = newSVsv (fh); |
1333 | req->sv1 = newSVsv (fh); |
1278 | req->int1 = fd; |
1334 | req->int1 = fd; |
… | |
… | |
1518 | |
1574 | |
1519 | void |
1575 | void |
1520 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1576 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1521 | PPCODE: |
1577 | PPCODE: |
1522 | { |
1578 | { |
1523 | int fd = s_fileno_croak (fh, 0); |
1579 | int fd = s_fileno_croak (fh, 0); |
1524 | dREQ; |
1580 | dREQ; |
1525 | |
1581 | |
1526 | req->type = EIO_CUSTOM; |
1582 | req->type = EIO_CUSTOM; |
1527 | req->sv1 = newSVsv (fh); |
1583 | req->sv1 = newSVsv (fh); |
1528 | req->int1 = fd; |
1584 | req->int1 = fd; |
1529 | |
1585 | |
1530 | req->feed = fiemap; |
1586 | req->feed = fiemap; |
|
|
1587 | #if HAVE_FIEMAP |
1531 | /* keep our fingers crossed that the next two types are 64 bit */ |
1588 | /* keep our fingers crossed that the next two types are 64 bit */ |
1532 | req->offs = start; |
1589 | req->offs = start; |
1533 | req->size = SvOK (length) ? SvVAL64 (length) : ~0ULL; |
1590 | req->size = SvOK (length) ? SvVAL64 (length) : ~0ULL; |
1534 | req->int2 = flags; |
1591 | req->int2 = flags; |
1535 | req->int3 = SvOK (count) ? SvIV (count) : -1; |
1592 | req->int3 = SvOK (count) ? SvIV (count) : -1; |
|
|
1593 | #endif |
1536 | |
1594 | |
1537 | REQ_SEND; |
1595 | REQ_SEND; |
1538 | } |
1596 | } |
1539 | |
1597 | |
1540 | void |
1598 | void |
… | |
… | |
1674 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1732 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1675 | OUTPUT: |
1733 | OUTPUT: |
1676 | RETVAL |
1734 | RETVAL |
1677 | |
1735 | |
1678 | void |
1736 | void |
1679 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1737 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) |
1680 | PPCODE: |
1738 | PPCODE: |
1681 | sv_unmagic (scalar, MMAP_MAGIC); |
1739 | sv_unmagic (scalar, MMAP_MAGIC); |
1682 | { |
1740 | { |
1683 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1741 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1684 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1742 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1717 | ALIAS: |
1775 | ALIAS: |
1718 | mprotect = 1 |
1776 | mprotect = 1 |
1719 | CODE: |
1777 | CODE: |
1720 | { |
1778 | { |
1721 | STRLEN svlen; |
1779 | STRLEN svlen; |
1722 | void *addr = SvPVbyte (scalar, svlen); |
1780 | void *addr = SvPVbyte (scalar, svlen); |
1723 | size_t len = SvUV (length); |
1781 | size_t len = SvUV (length); |
1724 | |
1782 | |
1725 | if (offset < 0) |
1783 | if (offset < 0) |
1726 | offset += svlen; |
1784 | offset += svlen; |
1727 | |
1785 | |
… | |
… | |
1746 | int |
1804 | int |
1747 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1805 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1748 | CODE: |
1806 | CODE: |
1749 | { |
1807 | { |
1750 | STRLEN svlen; |
1808 | STRLEN svlen; |
1751 | void *addr = SvPVbyte (scalar, svlen); |
1809 | void *addr = SvPVbyte (scalar, svlen); |
1752 | size_t len = SvUV (length); |
1810 | size_t len = SvUV (length); |
1753 | |
1811 | |
1754 | if (offset < 0) |
1812 | if (offset < 0) |
1755 | offset += svlen; |
1813 | offset += svlen; |
1756 | |
1814 | |
… | |
… | |
1763 | addr = (void *)(((intptr_t)addr) + offset); |
1821 | addr = (void *)(((intptr_t)addr) + offset); |
1764 | eio_page_align (&addr, &len); |
1822 | eio_page_align (&addr, &len); |
1765 | #if _POSIX_MEMLOCK_RANGE |
1823 | #if _POSIX_MEMLOCK_RANGE |
1766 | RETVAL = munlock (addr, len); |
1824 | RETVAL = munlock (addr, len); |
1767 | #else |
1825 | #else |
1768 | RETVAL = ((errno = ENOSYS), -1); |
1826 | RETVAL = EIO_ENOSYS (); |
1769 | #endif |
1827 | #endif |
1770 | } |
1828 | } |
1771 | OUTPUT: |
1829 | OUTPUT: |
1772 | RETVAL |
1830 | RETVAL |
1773 | |
1831 | |
… | |
… | |
1775 | munlockall () |
1833 | munlockall () |
1776 | CODE: |
1834 | CODE: |
1777 | #if _POSIX_MEMLOCK |
1835 | #if _POSIX_MEMLOCK |
1778 | munlockall (); |
1836 | munlockall (); |
1779 | #else |
1837 | #else |
1780 | RETVAL = -1; |
1838 | RETVAL = EIO_ENOSYS (); |
1781 | errno = ENOSYS; |
|
|
1782 | #endif |
1839 | #endif |
1783 | OUTPUT: |
1840 | OUTPUT: |
|
|
1841 | RETVAL |
|
|
1842 | |
|
|
1843 | int |
|
|
1844 | splice (aio_rfd rfh, SV *off_in, aio_wfd wfh, SV *off_out, size_t length, unsigned int flags) |
|
|
1845 | CODE: |
|
|
1846 | { |
|
|
1847 | #if HAVE_LINUX_SPLICE |
|
|
1848 | loff_t off_in_, off_out_; |
|
|
1849 | RETVAL = splice ( |
|
|
1850 | rfh, SvOK (off_in ) ? (off_in_ = SvVAL64 (off_in )), &off_in_ : 0, |
|
|
1851 | wfh, SvOK (off_out) ? (off_out_ = SvVAL64 (off_out)), &off_out_ : 0, |
|
|
1852 | length, flags |
|
|
1853 | ); |
|
|
1854 | #else |
|
|
1855 | RETVAL = EIO_ENOSYS (); |
|
|
1856 | #endif |
|
|
1857 | } |
|
|
1858 | OUTPUT: |
|
|
1859 | RETVAL |
|
|
1860 | |
|
|
1861 | int |
|
|
1862 | tee (aio_rfd rfh, aio_wfd wfh, size_t length, unsigned int flags) |
|
|
1863 | CODE: |
|
|
1864 | #if HAVE_LINUX_SPLICE |
|
|
1865 | RETVAL = tee (rfh, wfh, length, flags); |
|
|
1866 | #else |
|
|
1867 | RETVAL = EIO_ENOSYS (); |
|
|
1868 | #endif |
|
|
1869 | OUTPUT: |
1784 | RETVAL |
1870 | RETVAL |
1785 | |
1871 | |
1786 | void _on_next_submit (SV *cb) |
1872 | void _on_next_submit (SV *cb) |
1787 | CODE: |
1873 | CODE: |
1788 | SvREFCNT_dec (on_next_submit); |
1874 | SvREFCNT_dec (on_next_submit); |