STRUCT FIEMAP(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 NAME 🌸

struct fiemap β€” file extent mappings, aka the literal blueprint for asking the kernel "bestie, where does this file actually live on disk?" πŸ’–

So this manual page is from the Kernel API Manual, and it's all about one iconic little struct. Periodt.


✨ SYNOPSIS ✨

struct fiemap {
    __u64 fm_start;
    __u64 fm_length;
    __u32 fm_flags;
    __u32 fm_mapped_extents;
    __u32 fm_extent_count;
    struct fiemap_extent fm_extents[];
 };

No cap, that's the whole shape of it. The fm_extents[] at the end is a flexible array β€” it's giving "the party's just getting started" energy πŸŽ€


πŸ’… MEMBERS πŸ’…

Ok so here's the breakdown of every single field, and whether you're the one filling it in or the kernel's handing it back to you. Pay attention to the (in) and (out) bestie, that's the whole vibe check πŸ‘‘

  • fm_start β€” byte offset (inclusive, so like, include it) where the mapping kicks off. You set this one, it's (in) πŸ’–
  • fm_length β€” the logical length of the mapping that userspace is asking for. Also yours to fill in, (in) ✨
  • fm_flags β€” the FIEMAP_FLAG_* flags for this request. This one's a two-way street β€” (in/out) πŸ¦‹
  • fm_mapped_extents β€” how many extents actually got mapped. The kernel tells you this one, so it's (out) 🌸
  • fm_extent_count β€” the size of the fm_extents array. You declare it, (in) 🫢
  • fm_extents β€” the array of mapped extents. The kernel fills this bad boy in for you, (out) 😭
Lowkey important: the (in) / (out) labels are the main character here. Getting them backwards means you're writing into a field the kernel owns, and that's not the slay you think it is πŸ’€

🌈 SEE ALSO 🌈

  • Kernel file ./include/uapi/linux/fiemap.h
  • struct fiemap_extent(9) β€” the sequel, and honestly you will need to read it, iykyk πŸ‘‘

Alright babes, that's the whole page πŸŽ€ This was struct fiemap(9) from the Kernel API Manual, living its best life over at ./include/uapi/linux, dated October 2026. Go forth and map those extents, you absolute icon β­πŸ’œ

πŸ“¦ where this page comes from