summaryrefslogtreecommitdiff
path: root/tdb/tools/tdbbackup.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-12-22 17:30:41 -0500
committerSimo Sorce <idra@samba.org>2008-12-22 18:52:37 -0500
commit9e1e585aa2740bd55bd60d965bd6c271ee9caa2e (patch)
tree02d225bc01207e2838e056a175d91f14576698dd /tdb/tools/tdbbackup.c
parent6582952ae76c03c53227499028652b47692448e4 (diff)
downloadsssd-9e1e585aa2740bd55bd60d965bd6c271ee9caa2e.tar.gz
sssd-9e1e585aa2740bd55bd60d965bd6c271ee9caa2e.tar.bz2
sssd-9e1e585aa2740bd55bd60d965bd6c271ee9caa2e.zip
Rebase tdb code with all changes in samba master
Diffstat (limited to 'tdb/tools/tdbbackup.c')
-rw-r--r--tdb/tools/tdbbackup.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/tdb/tools/tdbbackup.c b/tdb/tools/tdbbackup.c
index 6f3ca483..83c0e163 100644
--- a/tdb/tools/tdbbackup.c
+++ b/tdb/tools/tdbbackup.c
@@ -126,9 +126,17 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
return 1;
}
- /* lock the old tdb */
- if (tdb_lockall(tdb) != 0) {
- fprintf(stderr,"Failed to lock %s\n", old_name);
+ if (tdb_transaction_start(tdb) != 0) {
+ printf("Failed to start transaction on old tdb\n");
+ tdb_close(tdb);
+ tdb_close(tdb_new);
+ unlink(tmp_name);
+ free(tmp_name);
+ return 1;
+ }
+
+ if (tdb_transaction_start(tdb_new) != 0) {
+ printf("Failed to start transaction on new tdb\n");
tdb_close(tdb);
tdb_close(tdb_new);
unlink(tmp_name);
@@ -152,6 +160,14 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
/* close the old tdb */
tdb_close(tdb);
+ if (tdb_transaction_commit(tdb_new) != 0) {
+ fprintf(stderr, "Failed to commit new tdb\n");
+ tdb_close(tdb_new);
+ unlink(tmp_name);
+ free(tmp_name);
+ return 1;
+ }
+
/* close the new tdb and re-open read-only */
tdb_close(tdb_new);
tdb_new = tdb_open(tmp_name, 0, TDB_DEFAULT, O_RDONLY, 0);
@@ -173,9 +189,6 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
return 1;
}
- /* make sure the new tdb has reached stable storage */
- fsync(tdb_fd(tdb_new));
-
/* close the new tdb and rename it to .bak */
tdb_close(tdb_new);
if (rename(tmp_name, new_name) != 0) {