mapping_seek_hole_data(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

okay so this is the Kernel API Manual entry for mapping_seek_hole_data(9), and it is lowkey iconic. πŸ’…

  • mapping_seek_hole_data β€” seek for SEEK_DATA / SEEK_HOLE in the page cache. bestie, that's the whole vibe. ✨

🌸 SYNOPSIS 🌸

the signature is giving main character energy, fr fr:

loff_t mapping_seek_hole_data (struct address_space *mapping , loff_t
start , loff_t end , int whence );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • mapping β€” the address space to search. that's the zone you're snooping around in. πŸ”
  • start β€” first byte to consider. the starting line, no cap.
  • end β€” limit of search, and yes it's exclusive. do not forget, bestie. πŸ™ˆ
  • whence β€” either SEEK_HOLE or SEEK_DATA. pick your fighter. βš”οΈ

πŸ’– DESCRIPTION πŸ’–

so if the page cache knows which blocks contain holes and which blocks contain data, your filesystem can use this function to implement SEEK_HOLE and SEEK_DATA. that's the whole point, and it ate. πŸ”₯

this is useful for filesystems that are entirely memory-based β€” such as tmpfs β€” and for filesystems that support unwritten extents. yep, both of those girlies get to use it. 🫢


⭐ RETURN ⭐

on success you get the requested offset back. slay. ✨

but if whence specifies SEEK_DATA and there is no data after start, you get -ENXIO. that's the "no data here, bestie" signal. πŸ’€

also, there is an implicit hole after end - 1, so SEEK_HOLE returns end if all the bytes between start and end contain data. literally important, don't skip it. πŸ‘‘


🌈 SEE ALSO 🌈

Kernel file ./mm/filemap.c is the homebase, and the whole SEE ALSO crew is right here β€” go say hi:


that's the page, bestie β€” source/version ./mm, dated October 2026, and yes she ate. mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from