sget_fc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… sget_fc β€” the sget_fc(9) glow-up

okay so bestie, we're in the Kernel API Manual today and the star of the show is sget_fc. she finds superblocks, she makes superblocks, she's literally the main character of mounting. let's get into it πŸ¦‹


✨ NAME ✨

sget_fc β€” find a superblock or create one, whichever hits first πŸ’«


🌸 SYNOPSIS 🌸

struct super_block * sget_fc (struct fs_context *fc , int (*test)(struct
super_block *, struct fs_context *) , int (*set)(struct super_block *,
struct fs_context *) );

like literally that's the whole signature, no notes πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • fc β€” the filesystem context. think of her as the vibe brief for what we're trying to mount πŸ’–
  • test β€” the comparison callback. she's the one going "hm, do u match?" πŸ”
  • set β€” the setup callback. she does the actual decorating once we've got a fresh superblock ✨

πŸ’… DESCRIPTION πŸ’…

okay so the whole job here is: create a new superblock or find an existing one. that's it. that's the errand 🫢

the test callback is what we use to hunt down a matching existing superblock. now here's the tea β€” whether the requested parameters in fc even get taken into account is specific to whichever test callback you're using. some of them care. some of them... don't. they may even be completely ignored. no cap, it's giving "we'll see" 😭

if an extant superblock does get matched, she gets returned β€” unless:

  1. the namespace of the filesystem context fc and the extant superblock's namespace differ
  2. the filesystem context fc has requested that reusing an extant superblock is not allowed

and in both of those cases, you get EBUSY back. that's the boundary, periodt πŸ”₯

if no match is made? then we build. a brand new superblock gets allocated and basic initialisation gets performed β€” s_type, s_fs_info and s_id will be set, and the set callback will be invoked. then the superblock gets published and returned to you in a partially constructed state, with SB_BORN and SB_ACTIVE as yet unset πŸ‘€ like she's out in the world but she's not fully her yet, yk? πŸ¦‹

bestie please clock that "partially constructed" line β€” she's published but not born, not active. that's not a bug, that's the whole design. respect it πŸ™ˆ

⭐ RETURN ⭐

on success: an extant or newly created superblock. slay πŸ’– on failure: an error pointer. not slay 😭


🌈 SEE ALSO 🌈

kernel file ./fs/super.c and honestly the whole friend group:


mwah πŸ’‹ this lil page lives in ./fs, stamped October 2026 β€” go read the source bestie, it's giving iconic πŸ‘‘βœ¨

πŸ“¦ where this page comes from