sget_dev(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ sget_dev(9) ✨

okay so this page lives in the Kernel API Manual, and it's gonna teach you how to find or create a superblock by device number. yes bestie, the superblock. the main character of your filesystem. let's go πŸ’…


🌸 NAME 🌸

sget_dev β€” find or create a superblock by device number

πŸŽ€ SYNOPSIS πŸŽ€

struct super_block *sget_dev (struct fs_context *fc , dev_t dev );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • fc β€” filesystem context. yes, the whole context, she's coming with you.
  • dev β€” device number

πŸ’– DESCRIPTION πŸ’–

okay so the vibe here: sget_dev finds or creates a superblock using the provided device number, and that device number gets stored in fc->sget_key. iykyk πŸ”‘

if an extant superblock is matched, then that one gets returned β€” but heads up, it comes back with an elevated reference count, and the caller must transfer or discard it. that ref is yours now, bestie, you have to deal with it πŸ™ˆ

if no match is made, a brand new superblock gets allocated and basic initialisation is performed β€” specifically s_type, s_fs_info, s_id and s_dev will be set. then the superblock gets published and returned in a partially constructed state, with SB_BORN and SB_ACTIVE as yet unset. so like… she's out there, but she's not fully her yet. not me describing a half-born superblock 😭

πŸ”₯ RETURN πŸ”₯

an existing or newly created superblock on success, an error pointer on failure. that's it, that's the whole return section. slay.

πŸ‘‘ SEE ALSO πŸ‘‘

all of these live in the kernel file ./fs/super.c, and yes, we're listing every single one because we're thorough like that 🫢


and that's the page πŸ’œ this one came from ./fs, it's part of the Kernel API Manual, and it's dated October 2026 β€” so go forth, manage your superblocks, and remember: elevated refcounts are a lifestyle, not a suggestion. periodt. 🌈⭐

πŸ“¦ where this page comes from