… | |
… | |
19 | |
19 | |
20 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
20 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
21 | # include <sys/mman.h> |
21 | # include <sys/mman.h> |
22 | #endif |
22 | #endif |
23 | |
23 | |
24 | #if __linux__ |
24 | /* the incompetent fool that created musl keeps __linux__, refuses |
|
|
25 | * to implement any linux standard apis, and also has no way to test |
|
|
26 | * for his broken iplementation. on't complain if this fails for you. |
|
|
27 | */ |
|
|
28 | #if __linux__ && (defined __GLIBC__ || defined __UCLIBC__) |
25 | # include <linux/fs.h> |
29 | # include <linux/fs.h> |
26 | # ifdef FS_IOC_FIEMAP |
30 | # ifdef FS_IOC_FIEMAP |
27 | # include <linux/types.h> |
31 | # include <linux/types.h> |
28 | # include <linux/fiemap.h> |
32 | # include <linux/fiemap.h> |
29 | # define HAVE_FIEMAP 1 |
33 | # define HAVE_FIEMAP 1 |
… | |
… | |
198 | || !fiemap->fm_mapped_extents /* no more extents */ |
202 | || !fiemap->fm_mapped_extents /* no more extents */ |
199 | || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) |
203 | || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) |
200 | goto done; |
204 | goto done; |
201 | |
205 | |
202 | /* else we have to loop - |
206 | /* else we have to loop - |
203 | * it would be tempting (atcually I tried that first) to just query the |
207 | * 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 |
208 | * number of extents needed, but linux often feels like not returning all |
205 | * extents, without telling us it left any out. this complicates |
209 | * extents, without telling us it left any out. this complicates |
206 | * this quite a bit. |
210 | * this quite a bit. |
207 | */ |
211 | */ |
208 | |
212 | |
… | |
… | |
220 | incmap->fm_flags = fiemap->fm_flags; |
224 | incmap->fm_flags = fiemap->fm_flags; |
221 | incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); |
225 | incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); |
222 | |
226 | |
223 | if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) |
227 | if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) |
224 | return; |
228 | return; |
|
|
229 | |
|
|
230 | if (!incmap->fm_mapped_extents) |
|
|
231 | goto done; |
225 | |
232 | |
226 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
233 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
227 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
234 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
228 | errno = ENOMEM; |
235 | errno = ENOMEM; |
229 | if (!fiemap) |
236 | if (!fiemap) |
… | |
… | |
1613 | { |
1620 | { |
1614 | dREQ; |
1621 | dREQ; |
1615 | |
1622 | |
1616 | req->type = EIO_GROUP; |
1623 | req->type = EIO_GROUP; |
1617 | |
1624 | |
|
|
1625 | PUTBACK; |
1618 | req_submit (req); |
1626 | req_submit (req); |
|
|
1627 | SPAGAIN; |
|
|
1628 | |
1619 | XPUSHs (req_sv (req, aio_grp_stash)); |
1629 | XPUSHs (req_sv (req, aio_grp_stash)); |
1620 | } |
1630 | } |
1621 | |
1631 | |
1622 | void |
1632 | void |
1623 | aio_nop (SV *callback=&PL_sv_undef) |
1633 | aio_nop (SV *callback=&PL_sv_undef) |
… | |
… | |
1865 | RETVAL = tee (rfh, wfh, length, flags); |
1875 | RETVAL = tee (rfh, wfh, length, flags); |
1866 | #else |
1876 | #else |
1867 | RETVAL = EIO_ENOSYS (); |
1877 | RETVAL = EIO_ENOSYS (); |
1868 | #endif |
1878 | #endif |
1869 | OUTPUT: |
1879 | OUTPUT: |
|
|
1880 | RETVAL |
|
|
1881 | |
|
|
1882 | int |
|
|
1883 | pipesize (aio_rfd rfh, int new_size = -1) |
|
|
1884 | PROTOTYPE: $;$ |
|
|
1885 | CODE: |
|
|
1886 | #if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ) |
|
|
1887 | if (new_size >= 0) |
|
|
1888 | RETVAL = fcntl (rfh, F_SETPIPE_SZ, new_size); |
|
|
1889 | else |
|
|
1890 | RETVAL = fcntl (rfh, F_GETPIPE_SZ); |
|
|
1891 | #else |
|
|
1892 | errno = ENOSYS; |
|
|
1893 | RETVAL = -1; |
|
|
1894 | #endif |
|
|
1895 | OUTPUT: |
1870 | RETVAL |
1896 | RETVAL |
1871 | |
1897 | |
1872 | void _on_next_submit (SV *cb) |
1898 | void _on_next_submit (SV *cb) |
1873 | CODE: |
1899 | CODE: |
1874 | SvREFCNT_dec (on_next_submit); |
1900 | SvREFCNT_dec (on_next_submit); |