gfs2_dir_add(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– gfs2_dir_add(9) πŸ’–

okay so this is gfs2_dir_add from the Kernel API Manual β€” yes it's a kernel function manual page, yes we're reading it for fun, no I will not be explaining myself πŸ’…


✨ NAME ✨

gfs2_dir_add β€” drop a brand-new filename into a directory, slay


🌸 SYNOPSIS 🌸

int gfs2_dir_add (struct inode *inode , const struct qstr *name , const
       struct gfs2_inode *nip , struct gfs2_diradd *da );

like, it returns an int, and it takes four things. four! we love a four-arg situation 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • inode β€” the directory inode. this is the directory we're adding into, bestie. the main character of the whole operation πŸ‘‘
  • name β€” the new name. the fresh little string that's about to become ✨real✨
  • nip β€” the GFS2 inode that's getting linked in to the directory. the new kid being introduced to the group chat πŸ’–
  • da β€” the directory addition info. this is the little info bundle that carries all the context, ok? very important errand-runner energy 🧚

⭐ DESCRIPTION ⭐

ok so here's the tea β˜• β€” if the call to gfs2_diradd_alloc_required already worked out that there's no need to allocate any new directory blocks, then da will already be holding a pointer to the directory entry and the bh in which it resides. iconic. efficient. we love her.

and because we already have that, we can just use it β€” no need to go back and repeat the whole search again. lowkey the best shortcut ever, ngl. why do the work twice when past-you already did it πŸ’…

but if there was no free space? then bestie, we're doing the thing: we must now create more space. no free real estate means we build some. periodt πŸ”₯

no cap, that's the whole vibe of this function β€” reuse the answer if you've got it, otherwise make room 🌈

πŸŽ€ RETURN πŸŽ€

  • 0 on success πŸ₯³
  • error code on failure 😭

that's it. that's the returns. zero means we ate and left no crumbs; anything else is a vibe check that failed πŸ’€


πŸ’œ SEE ALSO πŸ’œ

like literally the entire directory-ops friend group, all linked up 🫢 iykyk


and that's the whole page bestie!! πŸŽ€ this lil icon comes courtesy of ./fs/gfs2, dated October 2026, and it lives in the Kernel API Manual alongside all her sisters πŸ’– go read the source, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from