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