lookup_bdev(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… lookup_bdev(9) β€” the Kernel API Manual, bestie edition πŸŽ€

okay so you're in the lookup_bdev(9) page, part of the Kernel API Manual, and honestly? it's a short one. a lil snack. but it's lowkey iconic for what it does, so let's get into it ✨


🌸 NAME 🌸

lookup_bdev β€” look up a struct block_device by name. that's it, that's the whole vibe. you give it a name, it finds you a block device. match made in heaven fr πŸ’–


⭐ SYNOPSIS ⭐

int lookup_bdev (const char *pathname , dev_t *dev );

yes bestie, it returns an int, takes a const char *pathname and a dev_t *dev. write it down, it's on the test πŸ“


πŸ¦‹ ARGUMENTS πŸ¦‹

  • pathname β€” the name of the block device, in the filesystem. like, where it lives. its address. its home 🏠
  • dev β€” a pointer to the block device's dev_t, if found. note the "if found" β€” it's giving conditional, it's giving "we'll see" πŸ™ˆ

✨ DESCRIPTION ✨

so what does it actually DO? it looks up the block device's dev_t at pathname in the current namespace, if possible, and returns it in dev. that's the whole plot. no cap. 🫢

it's doing the looking-up for you so you don't have to, and honestly? main character energy. we stan a helper function πŸ‘‘


πŸ’€ CONTEXT πŸ’€

May sleep.

that's it. that's the entire section. two words. but they matter!! do NOT call this from a context where sleeping is illegal, bestie, i'm begging 😭 it's not an atomic-safe situation and the kernel will not be cute about it.


🌈 RETURN 🌈

  • 0 if it succeeded β€” slay, we love a zero πŸ’š
  • negative errno otherwise β€” not slay, but at least it tells you why πŸ’”

🧚 SEE ALSO 🧚

like, go read the kernel file ./block/bdev.c if you want the real tea, and also these besties:

a whole friend group honestly. the bd_*_claim* saga alone is a trilogy πŸ”₯


reminder pookie: lookup_bdev can sleep, so keep it out of atomic contexts. the kernel does not accept "but i didn't know" as an excuse πŸ’…

and that's the page!! brought to you by the ./block directory, October 2026 edition β€” go forth and look up those block devices, bestie, you've got this πŸ“πŸ’œ

πŸ“¦ where this page comes from