Lines Matching refs:fiemap
235 _cleanup_free_ struct fiemap *fiemap = NULL; in calculate_swap_file_offset() local
259 r = read_fiemap(fd, &fiemap); in calculate_swap_file_offset()
263 *ret_offset = fiemap->fm_extents[0].fe_physical / page_size(); in calculate_swap_file_offset()
514 int read_fiemap(int fd, struct fiemap **ret) { in read_fiemap()
515 _cleanup_free_ struct fiemap *fiemap = NULL, *result_fiemap = NULL; in read_fiemap() local
519 const size_t n_extra = DIV_ROUND_UP(sizeof(struct fiemap), sizeof(struct fiemap_extent)); in read_fiemap()
528 fiemap = calloc(n_extra, sizeof(struct fiemap_extent)); in read_fiemap()
529 if (!fiemap) in read_fiemap()
542 *fiemap = (struct fiemap) { in read_fiemap()
549 if (ioctl(fd, FS_IOC_FIEMAP, fiemap) < 0) in read_fiemap()
553 if (fiemap->fm_mapped_extents == 0) in read_fiemap()
558 …if (!greedy_realloc0((void**) &fiemap, n_extra + fiemap->fm_mapped_extents, sizeof(struct fiemap_e… in read_fiemap()
561 fiemap->fm_extent_count = fiemap->fm_mapped_extents; in read_fiemap()
562 fiemap->fm_mapped_extents = 0; in read_fiemap()
564 if (ioctl(fd, FS_IOC_FIEMAP, fiemap) < 0) in read_fiemap()
569 … n_extra + result_extents + fiemap->fm_mapped_extents, sizeof(struct fiemap_extent))) in read_fiemap()
573 fiemap->fm_extents, in read_fiemap()
574 sizeof(struct fiemap_extent) * fiemap->fm_mapped_extents); in read_fiemap()
576 result_extents += fiemap->fm_mapped_extents; in read_fiemap()
579 if (_likely_(fiemap->fm_mapped_extents > 0)) { in read_fiemap()
580 uint32_t i = fiemap->fm_mapped_extents - 1; in read_fiemap()
582 fiemap_start = fiemap->fm_extents[i].fe_logical + in read_fiemap()
583 fiemap->fm_extents[i].fe_length; in read_fiemap()
585 if (fiemap->fm_extents[i].fe_flags & FIEMAP_EXTENT_LAST) in read_fiemap()
590 memcpy(result_fiemap, fiemap, sizeof(struct fiemap)); in read_fiemap()