… | |
… | |
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 | |