… | |
… | |
167 | req->result = -1; |
167 | req->result = -1; |
168 | |
168 | |
169 | #if HAVE_FIEMAP |
169 | #if HAVE_FIEMAP |
170 | int count = req->int3; |
170 | int count = req->int3; |
171 | |
171 | |
172 | /* heuristic: first try with 64 extents if we don't know how many, */ |
172 | /* heuristic: first try with 72 extents if we don't know how many, */ |
173 | /* as most files have (hopefully) fewer than this many extents */ |
173 | /* as most files have (hopefully) fewer than this many extents */ |
174 | /* in fact, most should have <= 2, so maybe the 72 below is probably overkill */ |
174 | /* in fact, most should have <= 2, so the 72 below is probably overkill */ |
175 | if (count < 0) |
175 | if (count < 0) |
176 | count = 72; /* for what it's worth, 72 extents fit nicely into 4kb */ |
176 | count = 72; /* for what it's worth, 72 extents fit nicely into 4kb */ |
177 | |
177 | |
178 | for (;;) |
178 | for (;;) |
179 | { |
179 | { |
… | |
… | |
193 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
193 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
194 | return; |
194 | return; |
195 | |
195 | |
196 | if (req->int3 >= 0) |
196 | if (req->int3 >= 0) |
197 | break; /* when not autosizing we are done */ |
197 | break; /* when not autosizing we are done */ |
|
|
198 | |
|
|
199 | if (!fiemap->fm_mapped_extents) |
|
|
200 | break; /* if file has no segments, we are done */ |
198 | |
201 | |
199 | if (fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST) |
202 | if (fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST) |
200 | break; /* autosizing successful, we are done */ |
203 | break; /* autosizing successful, we are done */ |
201 | |
204 | |
202 | fiemap->fm_flags = req->int2; |
205 | fiemap->fm_flags = req->int2; |
… | |
… | |
983 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
986 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
984 | const_eio (SYNC_FILE_RANGE_WRITE) |
987 | const_eio (SYNC_FILE_RANGE_WRITE) |
985 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
988 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
986 | |
989 | |
987 | const_eio (FALLOC_FL_KEEP_SIZE) |
990 | const_eio (FALLOC_FL_KEEP_SIZE) |
|
|
991 | const_eio (FALLOC_FL_PUNCH_HOLE) |
988 | |
992 | |
989 | const_eio (READDIR_DENTS) |
993 | const_eio (READDIR_DENTS) |
990 | const_eio (READDIR_DIRS_FIRST) |
994 | const_eio (READDIR_DIRS_FIRST) |
991 | const_eio (READDIR_STAT_ORDER) |
995 | const_eio (READDIR_STAT_ORDER) |
992 | const_eio (READDIR_FOUND_UNKNOWN) |
996 | const_eio (READDIR_FOUND_UNKNOWN) |
… | |
… | |
1215 | } |
1219 | } |
1216 | else |
1220 | else |
1217 | { |
1221 | { |
1218 | /* read: check type and grow scalar as necessary */ |
1222 | /* read: check type and grow scalar as necessary */ |
1219 | SvUPGRADE (data, SVt_PV); |
1223 | SvUPGRADE (data, SVt_PV); |
|
|
1224 | if (SvLEN (data) >= SvCUR (data)) |
1220 | svptr = SvGROW (data, len + dataoffset + 1); |
1225 | svptr = SvGROW (data, len + dataoffset + 1); |
|
|
1226 | else if (SvCUR (data) < len + dataoffset) |
|
|
1227 | croak ("length + dataoffset outside of scalar, and cannot grow"); |
1221 | } |
1228 | } |
1222 | |
1229 | |
1223 | { |
1230 | { |
1224 | dREQ; |
1231 | dREQ; |
1225 | |
1232 | |
… | |
… | |
1528 | |
1535 | |
1529 | void |
1536 | void |
1530 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1537 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1531 | PPCODE: |
1538 | PPCODE: |
1532 | { |
1539 | { |
1533 | int fd = s_fileno_croak (fh, 0); |
1540 | int fd = s_fileno_croak (fh, 0); |
1534 | dREQ; |
1541 | dREQ; |
1535 | |
1542 | |
1536 | req->type = EIO_CUSTOM; |
1543 | req->type = EIO_CUSTOM; |
1537 | req->sv1 = newSVsv (fh); |
1544 | req->sv1 = newSVsv (fh); |
1538 | req->int1 = fd; |
1545 | req->int1 = fd; |
… | |
… | |
1686 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1693 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1687 | OUTPUT: |
1694 | OUTPUT: |
1688 | RETVAL |
1695 | RETVAL |
1689 | |
1696 | |
1690 | void |
1697 | void |
1691 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1698 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) |
1692 | PPCODE: |
1699 | PPCODE: |
1693 | sv_unmagic (scalar, MMAP_MAGIC); |
1700 | sv_unmagic (scalar, MMAP_MAGIC); |
1694 | { |
1701 | { |
1695 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1702 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1696 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1703 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1729 | ALIAS: |
1736 | ALIAS: |
1730 | mprotect = 1 |
1737 | mprotect = 1 |
1731 | CODE: |
1738 | CODE: |
1732 | { |
1739 | { |
1733 | STRLEN svlen; |
1740 | STRLEN svlen; |
1734 | void *addr = SvPVbyte (scalar, svlen); |
1741 | void *addr = SvPVbyte (scalar, svlen); |
1735 | size_t len = SvUV (length); |
1742 | size_t len = SvUV (length); |
1736 | |
1743 | |
1737 | if (offset < 0) |
1744 | if (offset < 0) |
1738 | offset += svlen; |
1745 | offset += svlen; |
1739 | |
1746 | |