r23930: Introduce tdb_validate_and_backup:
authorMichael Adam <obnox@samba.org>
Tue, 17 Jul 2007 12:49:22 +0000 (12:49 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:28:46 +0000 (12:28 -0500)
commitca63a99b6188c0976603dc2852e478cc7a6b2f8b
tree7255299cd6845b175ea694eb5c0e14a2c47b8db5
parent465c89ee4a0c287203121037052c875b1c6ca41e
r23930: Introduce tdb_validate_and_backup:
This is a wrapper around tdb_validate, that does backup handling:

* if the given tdb is valid, a backup is created (name.bak)
* if the tdb is invalid, if a valid bakup is found (validated
  with the same validation function) under the name "name.bak"
  the orignal tdb is moved to name.corrupt and the backup
  is restored.

For the backup handling, a variant of the backup_tdb function
from lib/tdb/tools/tdbbackup.c is included in lib/util_tdb.c.
The copy function for the traverse action eliminates the need
to maintain a global success state by using a struct wrapping
the target tdb and a success flag as the private data.

Michael
source/lib/util_tdb.c