gfs2_dir_add(9)
π 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 π
0on 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 π
- Kernel file
./fs/gfs2/dir.c gfs2_dir_write_data(9)gfs2_dir_read_data(9)gfs2_dir_get_hash_table(9)gfs2_dir_hash_inval(9)dirent_next(9)dirent_del(9)get_leaf_nr(9)dir_make_exhash(9)dir_split_leaf(9)dir_double_exhash(9)compare_dents(9)do_filldir_main(9)gfs2_dir_readahead(9)dir_e_read(9)gfs2_dir_search(9)dir_new_leaf(9)gfs2_dir_del(9)gfs2_dir_mvino(9)leaf_dealloc(9)gfs2_dir_exhash_dealloc(9)gfs2_diradd_alloc_required(9)
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
- 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