|
ginnOS
The reference: libc, the libraries and the kernel
|
librat: transactions. More...
#include "internal.h"#include <errno.h>#include <stdarg.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <unistd.h>Macros | |
| #define | TXN_FILE RAT_DB_DIR "/transaction" |
| #define | TXN_FIRST "rat-transaction 1\n" |
Functions | |
| void | rat_txn_init (rat_txn_t *txn) |
| void | rat_txn_free (rat_txn_t *txn) |
| int | rat_txn_add (rat_txn_t *txn, const char *format,...) |
| int | rat_txn_commit (rat_t *rat, rat_txn_t *txn, const char *note, rat_error_t *err) |
| write the list and do it, then remove the list and the stage folder. | |
| int | rat_recover (rat_t *rat, rat_error_t *err) |
| finish the transaction of an earlier rat that stopped, or remove its stage folder. | |
| bool | rat_txn_pending (const rat_t *rat) |
| true if the list of an interrupted change is there | |
Variables | |
| int | rat_test_stop_after = -1 |
| for the host tests only: when 0 or more, a transaction stops after this number of operations, as if the power went off. | |
librat: transactions.
a change is a list of operations in the file var/lib/rat/transaction, done in order.
the file has one operation on each line, between a first line and an "end" line:
rat-transaction 1 note install lua 5.4.9-1 mkdir 0755 usr/share/lua move f3a9... usr/bin/lua (a file or link of the stage folder) remove usr/bin/old (a file or link) rmdir usr/share/old (only if it is empty) record lua (stage/record replaces installed/lua) unrecord lua (installed/lua is removed) end
each operation gives the same result when it is done again (a move whose source is gone is done, a remove of a missing path is done), so an interrupted list is finished by doing all of it again.
| #define TXN_FILE RAT_DB_DIR "/transaction" |
| #define TXN_FIRST "rat-transaction 1\n" |
| void rat_txn_init | ( | rat_txn_t * | txn | ) |
| void rat_txn_free | ( | rat_txn_t * | txn | ) |
| int rat_txn_add | ( | rat_txn_t * | txn, |
| const char * | format, | ||
| ... ) |
| int rat_txn_commit | ( | rat_t * | rat, |
| rat_txn_t * | txn, | ||
| const char * | note, | ||
| rat_error_t * | err ) |
write the list and do it, then remove the list and the stage folder.
| note | a line that tells what the change is ("install lua 5.4.9-1"). |
| int rat_recover | ( | rat_t * | rat, |
| rat_error_t * | err ) |
finish the transaction of an earlier rat that stopped, or remove its stage folder.
rat->recovered gets a message when there was one.
| int rat_test_stop_after = -1 |
for the host tests only: when 0 or more, a transaction stops after this number of operations, as if the power went off.
-1 normally.