VOP_BMAP(9)

πŸ’– VOP_BMAP β€” the manual page, but make it make sense πŸ’–

okay bestie, so this is VOP_BMAP(9) from the Kernel Developer's Manual, and it's literally the glow-up of logical-to-physical block number conversion. iykyk. let's get into it ✨


✨ NAME ✨

VOP_BMAP β€” Logical to physical block number conversion πŸ¦‹


🌸 SYNOPSIS 🌸

no cap, this is exactly how you call it:

#include <sys/param.h>
#include <sys/vnode.h>

int
VOP_BMAP(struct vnode *vp, daddr_t bn, struct bufobj **bop,
    daddr_t *bnp, int *runp, int *runb);

πŸ’… DESCRIPTION πŸ’…

so this vnode call is the moment where you find out the physical block number of the file system's underlying device where a given logical block of a file is actually stored. it's giving "where does this data LIVE, actually". main character energy fr fr.

and here's every single argument, because we don't gatekeep:

  • vp β€” the vnode of the file. your file's whole identity, honestly πŸ‘‘
  • bn β€” the logical block number within the file identified by vp. the vibe-check location you're asking about.
  • bop β€” return storage for the buffer object associated with the file system's underlying device. like, the device's bufobj goes here πŸ’–
  • bnp β€” return storage for the physical block number. the actual answer, periodt.
  • runp β€” return storage for the number of succeeding logical blocks that may be efficiently read at the same time as the requested block. usually this is the number of logical blocks whose physical blocks are contiguously allocated. BUT β€” and this is important β€” a file system is free to define "efficient" as it sees fit. so it's a vibe, not a promise 😭
  • runb β€” like runp but for preceding rather than succeeding blocks. same energy, opposite direction πŸ¦‹

and here's the tea: any of the return arguments may be NULL to indicate that the caller does not care about that information. not me being allowed to just... not care. iconic.


πŸ”’ LOCKS πŸ”’

the vnode will be locked on entry and should remain locked on return. do not let go of the lock bestie, it's holding the whole situation together πŸ™ˆ


⭐ RETURN VALUES ⭐

zero is returned on success, otherwise an error code is returned. that's it, that's the whole thing. zero = slay, anything else = something went wrong πŸ’€


🌈 SEE ALSO 🌈

(and that's the whole list, no crumbs left behind πŸ“)


πŸ“œ HISTORY πŸ“œ

a bmap() function first appeared in 4.2BSD. a true elder, we respect the ancestry πŸ’œ


🫢 AUTHORS 🫢

this manual page was written by Alan Somers. thank you for your service, king πŸ‘‘


and that's the whole page, bestie β€” brought to you by Debian, dated June 19, 2019. go forth and convert those blocks logically AND physically. mwah πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from