af_transact(3)

πŸ’– af_transact β€” bestie edition πŸ’–

okay so this is af_transact(3), a page from the Attribute Filesystem (AtFS) manual, section 3. it's all about af_transaction, af_commit and af_abort β€” a lil transaction system that's giving undo button energy ✨


🌸 NAME 🌸

af_transaction, af_commit, af_abort β€” a simple transaction mechanism for AtFS. yes bestie, simple. we love a low-drama API πŸ’…


✨ SYNOPSIS ✨

#include <atfs.h>

int af_transaction (void)

int af_commit (void)

int af_abort (void)

three functions, zero arguments, so much power. iconique πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so these functions implement a simple transaction mechanism for AtFS, and honestly? it's the group-chat "hold on lemme think" of filesystems.

a transaction starts when you call af_transaction. from that moment on, all changes to existing ASOs performed afterwards have no immediate permanent effect. like, they're in the drafts folder. they only get into effect when the transaction is ended.

  • calling af_commit ends the transaction and causes all changes to be saved to disk πŸ’Ύ
  • af_abort aborts the transaction without saving the changes β€” those changes then get discarded. not me ghosting my own edits 😭

now the important tea β˜• β€” the deferral is selective, and this is where people get caught out:

  • only modification of the state of existing source ASOs will be deferred.
  • creation or deletion of ASOs has immediate effect, regardless of whether a transaction is in effect or not. no take-backs on those, periodt.
  • additionally, all operations on derived ASOs (all operations on the derived object cache) are not affected by the transaction. they do their own thing, main character energy, no transaction holding them back.

also, and this is lowkey crucial: all archive files that are to be changed when the transaction is finished are locked until the end of the transaction. that lock prevents all other applications from performing any modifications on the archive file.

🫢 bestie pls make sure that ending a transaction should never be dependent on the successful termination of another application. that's a deadlock danger and we do not stan. deadlocks are not it.

🩺 DIAGNOSTICS 🩺

upon error, -1 is returned and af_errno is set to the corresponding error number. classic. check your af_errno babes, it's always telling you something πŸ™ˆ


πŸ’€ BUGS πŸ’€

changes to the contents of busy versions have immediate effect. yeah. no deferred vibe check for those. it's giving "we tried" 😭


that's the whole page fr fr. this was AtFS-1.71, dated Fri Jun 25 14:33:21 1993 β€” yes it's vintage, yes it still ate, and yes the source is AtFS version 1.71 πŸ’œ stay safe out there, commit responsibly, and don't deadlock your besties πŸŒˆπŸ‘‘β­

πŸ“¦ where this page comes from