get_anon_bdev(9)
π get_anon_bdev π
okay so bestie, welcome to the Kernel API Manual β¨ β today's main character is get_anon_bdev(9), and she's literally the friend who hooks you up when you don't have your own block device. let's get into it π«Ά
β¨ NAME β¨
get_anon_bdev β allocate a block device for filesystems which don't have one. no cap, that's the whole job π
π SYNOPSIS π
int get_anon_bdev (dev_t *p );
π¦ ARGUMENTS π¦
pβ a pointer to adev_t. that's it, that's the argument. she takes one (1) pointer and she takes it seriously β¨
πΈ DESCRIPTION πΈ
so like, some filesystems don't use real block devices β they're doing their own thing, living their truth π β and those filesystems can call this function to allocate a virtual block device.
that's the vibe. no physical hardware required, just a cute little virtual bdev to call your own π
π CONTEXT π
Any context. literally any. she's flexible like that π§
though highkey, she's frequently called while holding sb_lock β so like, know that going in, iykyk π
β RETURN β
here's the vibe check on what you get back:
0β slay, success π-EMFILEβ no anonymous bdevs left π they're all taken, the shelf is empty-ENOMEMβ memory allocation failed π the malloc said no
π SEE ALSO π
buckle up bestie, this is a whole friend group β all from the kernel file ./fs/super.c:
super_lock(9), alloc_super(9), deactivate_locked_super(9), deactivate_super(9), grab_super(9), retire_super(9), generic_shutdown_super(9), sget_fc(9), iterate_supers_type(9), reconfigure_super(9), emergency_thaw_all(9), sget_dev(9), fs_bdev_freeze(9), fs_bdev_thaw(9), fs_bdev_file_open_by_dev(9), fs_bdev_file_open_by_path(9), fs_bdev_unregister(9), fs_bdev_file_release(9), get_tree_bdev_flags(9), get_tree_bdev(9), vfs_get_tree(9), sb_wait_write(9), freeze_super(9), thaw_super(9)
like i said. a whole friend group. go say hi ππ
remembe: virtual bdevs are a limited resource, so when -EMFILE hits, that's your sign to actually clean up after yourself. be the friend who returns the tupperware π
okay that's the page!! this one lives in ./fs and it's dated October 2026 β so like, mark your calendar, she's a whole era πβ¨ bye bestie, go allocate responsibly π
π
π¦ 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