… | |
… | |
189 | fiemap->fm_start = req->offs; |
189 | fiemap->fm_start = req->offs; |
190 | fiemap->fm_length = req->size; |
190 | fiemap->fm_length = req->size; |
191 | fiemap->fm_flags = req->int2; |
191 | fiemap->fm_flags = req->int2; |
192 | fiemap->fm_extent_count = count; |
192 | fiemap->fm_extent_count = count; |
193 | |
193 | |
194 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
194 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap) < 0) |
195 | return; |
195 | return; |
196 | |
196 | |
197 | if (req->int3 >= 0 /* not autosizing */ |
197 | if (req->int3 >= 0 /* not autosizing */ |
198 | || !fiemap->fm_mapped_extents /* no more extents */ |
198 | || !fiemap->fm_mapped_extents /* no more extents */ |
199 | || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) |
199 | || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) |
… | |
… | |
218 | + fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_length; |
218 | + fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_length; |
219 | incmap->fm_length = fiemap->fm_length - (incmap->fm_start - fiemap->fm_start); |
219 | incmap->fm_length = fiemap->fm_length - (incmap->fm_start - fiemap->fm_start); |
220 | incmap->fm_flags = fiemap->fm_flags; |
220 | incmap->fm_flags = fiemap->fm_flags; |
221 | incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); |
221 | incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); |
222 | |
222 | |
223 | if (ioctl (req->int1, FS_IOC_FIEMAP, incmap)) |
223 | if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) |
224 | return; |
224 | return; |
225 | |
225 | |
226 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
226 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
227 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
227 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
228 | errno = ENOMEM; |
228 | errno = ENOMEM; |
… | |
… | |
507 | #ifndef _WIN32 |
507 | #ifndef _WIN32 |
508 | if (req->result >= 0) |
508 | if (req->result >= 0) |
509 | { |
509 | { |
510 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
510 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
511 | 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)); |
512 | |
517 | |
513 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
518 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
514 | |
519 | |
515 | 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); |
516 | 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); |
… | |
… | |
518 | 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); |
519 | 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); |
520 | 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); |
521 | 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); |
522 | 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); |
523 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
528 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (fsid ), 0); |
524 | 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); |
525 | 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); |
526 | } |
531 | } |
527 | #endif |
532 | #endif |
528 | |
533 | |
… | |
… | |
1131 | aio_fsync = EIO_FSYNC |
1136 | aio_fsync = EIO_FSYNC |
1132 | aio_fdatasync = EIO_FDATASYNC |
1137 | aio_fdatasync = EIO_FDATASYNC |
1133 | aio_syncfs = EIO_SYNCFS |
1138 | aio_syncfs = EIO_SYNCFS |
1134 | PPCODE: |
1139 | PPCODE: |
1135 | { |
1140 | { |
1136 | int fd = s_fileno_croak (fh, 0); |
1141 | int fd = s_fileno_croak (fh, 0); |
1137 | dREQ; |
1142 | dREQ; |
1138 | |
1143 | |
1139 | req->type = ix; |
1144 | req->type = ix; |
1140 | req->sv1 = newSVsv (fh); |
1145 | req->sv1 = newSVsv (fh); |
1141 | req->int1 = fd; |
1146 | req->int1 = fd; |
… | |
… | |
1145 | |
1150 | |
1146 | void |
1151 | void |
1147 | 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) |
1148 | PPCODE: |
1153 | PPCODE: |
1149 | { |
1154 | { |
1150 | int fd = s_fileno_croak (fh, 0); |
1155 | int fd = s_fileno_croak (fh, 0); |
1151 | dREQ; |
1156 | dREQ; |
1152 | |
1157 | |
1153 | req->type = EIO_SYNC_FILE_RANGE; |
1158 | req->type = EIO_SYNC_FILE_RANGE; |
1154 | req->sv1 = newSVsv (fh); |
1159 | req->sv1 = newSVsv (fh); |
1155 | req->int1 = fd; |
1160 | req->int1 = fd; |
… | |
… | |
1159 | |
1164 | |
1160 | REQ_SEND; |
1165 | REQ_SEND; |
1161 | } |
1166 | } |
1162 | |
1167 | |
1163 | void |
1168 | void |
1164 | 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) |
1165 | PPCODE: |
1170 | PPCODE: |
1166 | { |
1171 | { |
1167 | int fd = s_fileno_croak (fh, 0); |
1172 | int fd = s_fileno_croak (fh, 0); |
1168 | dREQ; |
1173 | dREQ; |
1169 | |
1174 | |
1170 | req->type = EIO_FALLOCATE; |
1175 | req->type = EIO_FALLOCATE; |
1171 | req->sv1 = newSVsv (fh); |
1176 | req->sv1 = newSVsv (fh); |
1172 | req->int1 = fd; |
1177 | req->int1 = fd; |
… | |
… | |
1180 | void |
1185 | void |
1181 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1186 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1182 | PPCODE: |
1187 | PPCODE: |
1183 | { |
1188 | { |
1184 | 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 */ |
1185 | int fd = s_fileno_croak (fh, 0); |
1190 | int fd = s_fileno_croak (fh, 0); |
1186 | dREQ; |
1191 | dREQ; |
1187 | |
1192 | |
1188 | if (expect_false (close_fd < 0)) |
1193 | if (expect_false (close_fd < 0)) |
1189 | { |
1194 | { |
1190 | int pipefd [2]; |
1195 | int pipefd [2]; |
… | |
… | |
1300 | |
1305 | |
1301 | void |
1306 | void |
1302 | 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) |
1303 | PPCODE: |
1308 | PPCODE: |
1304 | { |
1309 | { |
1305 | int ifd = s_fileno_croak (in_fh , 0); |
1310 | int ifd = s_fileno_croak (in_fh , 0); |
1306 | int ofd = s_fileno_croak (out_fh, 1); |
1311 | int ofd = s_fileno_croak (out_fh, 1); |
1307 | dREQ; |
1312 | dREQ; |
1308 | |
1313 | |
1309 | req->type = EIO_SENDFILE; |
1314 | req->type = EIO_SENDFILE; |
1310 | req->sv1 = newSVsv (out_fh); |
1315 | req->sv1 = newSVsv (out_fh); |
1311 | req->int1 = ofd; |
1316 | req->int1 = ofd; |
… | |
… | |
1319 | |
1324 | |
1320 | void |
1325 | void |
1321 | 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) |
1322 | PPCODE: |
1327 | PPCODE: |
1323 | { |
1328 | { |
1324 | int fd = s_fileno_croak (fh, 0); |
1329 | int fd = s_fileno_croak (fh, 0); |
1325 | dREQ; |
1330 | dREQ; |
1326 | |
1331 | |
1327 | req->type = EIO_READAHEAD; |
1332 | req->type = EIO_READAHEAD; |
1328 | req->sv1 = newSVsv (fh); |
1333 | req->sv1 = newSVsv (fh); |
1329 | req->int1 = fd; |
1334 | req->int1 = fd; |
… | |
… | |
1799 | int |
1804 | int |
1800 | 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) |
1801 | CODE: |
1806 | CODE: |
1802 | { |
1807 | { |
1803 | STRLEN svlen; |
1808 | STRLEN svlen; |
1804 | void *addr = SvPVbyte (scalar, svlen); |
1809 | void *addr = SvPVbyte (scalar, svlen); |
1805 | size_t len = SvUV (length); |
1810 | size_t len = SvUV (length); |
1806 | |
1811 | |
1807 | if (offset < 0) |
1812 | if (offset < 0) |
1808 | offset += svlen; |
1813 | offset += svlen; |
1809 | |
1814 | |