A simple transaction mechanism for atfs
#include <atfs.h>
int af_transaction (void)
int af_commit (void)
int af_abort (void)
These functions implement a simple transaction mechanism for AtFS. A transaction starts with calling af_transaction. All changes to existing ASOs performed hereafter have no immediate permanent effect. They rather get into effect, when the transaction is ended. Calling af_commit ends the transactions and causes all changes to be saved to disk. af_abort aborts the transaction without saving the changes. These will then be discarded.
Only modification of the state of existing source ASOs will be deferred. Creation or deletion of ASOs have immediate effect, regardless if a transaction is in effect or not. Additionally, all operations on derived ASOs (all operations on the derived object cache) are not affected by the transaction.
All archive files that are to be changed when the transaction is finished are locked until the end of the transaction. The lock prevents all other applications to perform any modifications on the archive file. You should make sure, that ending a transaction should never be dependent on the successful termination of another application (deadlock danger).
Upon error, -1 is returned and af_errno is set to the corresponding error number.
Changes to the contents of busy versions have immediate effect.