As you do not correctly set the parameters fiemap_buf.fbefore the call ioctl(), it is likely that it EINVALcomes from invalid content fiemapthan from the support of the request identifier itself FS_IOC_FIEMAP.
, ioctl_fiemap() ( ) fiemap.fm_extent_count, , , FIEMAP_MAX_EXTENTS -EINVAL . fiemap reset , , , .
, coreutils, , fiemap ioctl():
fiemap->fm_start = scan->scan_start;
fiemap->fm_flags = scan->fm_flags;
fiemap->fm_extent_count = count;
fiemap->fm_length = FIEMAP_MAX_OFFSET - scan->scan_start;