af_lock(3)
π af_lock β bestie, it's the AtFS lock situation π
okay so this is af_lock(3) from the Attribute Filesystem (AtFS) manual, and we're about to talk about reserving update rights, which is lowkey the most main-character thing you can do in a filesystem. sit down, grab a strawberry π, let's go.
β¨ NAME β¨
af_lock, af_unlock, af_testlock β the whole mechanism for reserving update rights in AtFS, no cap π
π SYNOPSIS π
#include <atfs.h>
Af_user *af_lock (Af_key *aso, Af_user *locker)
Af_user *af_unlock (Af_key *aso)
Af_user *af_testlock (Af_key *aso)
like look at these signatures. they're giving elegant. π
π¦ DESCRIPTION π¦
This page is your full tour of the AtFS locking interface, bestie. Locks exist so that two people don't both go "hehe let me update this" at the same time and cause conflicting updates to one object history. that would be chaos, and not the fun kind. π
Once a user has reserved the update rights, no other user may add new versions to the reserved history. periodt. and the way you reserve those update rights is by locking the most recent version of the history.
Here's the cute part: AtFS lets you add new versions to each generation in a history, so each generation can be locked separately. π§ if you wanna reserve update rights for an old generation (one whose generation number is smaller than the newest generation), you do it by locking the most recent version of that corresponding generation. yes queen, per-generation locking.
Also also β and this is important β removing an ASO (af_rm, see the manual page af_files(3)) and changing an ASO's version number (af_svnum, see the manual page af_version(3)) also require a lock on the corresponding ASO. so no sneaky deleting or renumbering without the lock. nope. π
π₯ the three functions, one by one π₯
af_lockβ reserves the update permission for the user identified bylocker. on successful completion you get back a buffer identical tolocker, and otherwise you get aNULLpointer. that's it, that's the vibe.af_unlockβ cancels a formerly established reservation of update rights. only the owner or the locker of an ASO are allowed to do this, and the locker is identified by theAf_userstructure that was given to the corresponding call ofaf_lock. on successful completion,af_unlockreturns a buffer containing the identification of the former locker. this may be empty if the ASO was not locked. upon error, aNULLpointer is returned. πaf_testlockβ returns a buffer containing an identification of the current locker of the specified ASO. it returns an empty buffer if no lock is set. so basically it's the gossip function, it tells you who's holding the lock rn. π
π SEE ALSO π
go read those too, bestie, they're connected, iykyk.
π DIAGNOSTICS π
af_lock and af_unlock return -1 on error, and af_errno is set to indicate the error number. so if something's wrong, check af_errno β it's literally telling you what happened. π
not me being emotionally invested in a C library from 1993 but here we are, obsessed. π«Ά
and that's the whole page, bestie! this was AtFS-1.71, dated Fri Jun 25 14:33:11 1993 β iconic vintage behavior, we love her, mwah πβ¨πΈ
π¦ where this page comes from
- debian bookworm: atfs-dev 1.4pl6-15+b1
- ubuntu jammy: atfs-dev 1.4pl6-15
- ubuntu noble: atfs-dev 1.4pl6-16.1build1
- ubuntu resolute: atfs-dev 1.4pl6-17
- ubuntu stonking: atfs-dev 1.4pl6-17
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms