lookup_bdev(9)
π 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'sdev_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 π
0if it succeeded β slay, we love a zero π- negative
errnootherwise β 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:
bdev_validate_blocksize(9)bdev_freeze(9)bdev_thaw(9)bdev_deny_freeze(9)bdev_allow_freeze(9)bd_may_claim(9)bd_prepare_to_claim(9)bd_finish_claiming(9)bd_abort_claiming(9)bdev_open(9)bdev_yield_claim(9)bdev_fput(9)bdev_mark_dead(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms