mirror of
https://github.com/samba-team/samba.git
synced 2025-08-05 12:22:11 +03:00
s3:tdb_validate: clean up leading tabs/spaces and trailing spaces.
Michael
This commit is contained in:
@ -22,8 +22,8 @@
|
|||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "tdb_validate.h"
|
#include "tdb_validate.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* internal validation function, executed by the child.
|
* internal validation function, executed by the child.
|
||||||
*/
|
*/
|
||||||
static int tdb_validate_child(struct tdb_context *tdb,
|
static int tdb_validate_child(struct tdb_context *tdb,
|
||||||
tdb_validate_data_func validate_fn)
|
tdb_validate_data_func validate_fn)
|
||||||
@ -364,46 +364,46 @@ static int rename_file_with_suffix(TALLOC_CTX *ctx, const char *path,
|
|||||||
* do a backup of a tdb, moving the destination out of the way first
|
* do a backup of a tdb, moving the destination out of the way first
|
||||||
*/
|
*/
|
||||||
static int tdb_backup_with_rotate(TALLOC_CTX *ctx, const char *src_path,
|
static int tdb_backup_with_rotate(TALLOC_CTX *ctx, const char *src_path,
|
||||||
const char *dst_path, int hash_size,
|
const char *dst_path, int hash_size,
|
||||||
const char *rotate_suffix,
|
const char *rotate_suffix,
|
||||||
bool retry_norotate_if_nospc,
|
bool retry_norotate_if_nospc,
|
||||||
bool rename_as_last_resort_if_nospc)
|
bool rename_as_last_resort_if_nospc)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
rename_file_with_suffix(ctx, dst_path, rotate_suffix);
|
rename_file_with_suffix(ctx, dst_path, rotate_suffix);
|
||||||
|
|
||||||
ret = tdb_backup(ctx, src_path, dst_path, hash_size);
|
ret = tdb_backup(ctx, src_path, dst_path, hash_size);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DEBUG(10, ("backup of %s failed: %s\n", src_path, strerror(errno)));
|
DEBUG(10, ("backup of %s failed: %s\n", src_path, strerror(errno)));
|
||||||
}
|
}
|
||||||
if ((ret != 0) && (errno == ENOSPC) && retry_norotate_if_nospc)
|
if ((ret != 0) && (errno == ENOSPC) && retry_norotate_if_nospc)
|
||||||
{
|
{
|
||||||
char *rotate_path = talloc_asprintf(ctx, "%s%s", dst_path,
|
char *rotate_path = talloc_asprintf(ctx, "%s%s", dst_path,
|
||||||
rotate_suffix);
|
rotate_suffix);
|
||||||
DEBUG(10, ("backup of %s failed due to lack of space\n",
|
DEBUG(10, ("backup of %s failed due to lack of space\n",
|
||||||
src_path));
|
src_path));
|
||||||
DEBUGADD(10, ("trying to free some space by removing rotated "
|
DEBUGADD(10, ("trying to free some space by removing rotated "
|
||||||
"dst %s\n", rotate_path));
|
"dst %s\n", rotate_path));
|
||||||
if (unlink(rotate_path) == -1) {
|
if (unlink(rotate_path) == -1) {
|
||||||
DEBUG(10, ("unlink of %s failed: %s\n", rotate_path,
|
DEBUG(10, ("unlink of %s failed: %s\n", rotate_path,
|
||||||
strerror(errno)));
|
strerror(errno)));
|
||||||
} else {
|
} else {
|
||||||
ret = tdb_backup(ctx, src_path, dst_path, hash_size);
|
ret = tdb_backup(ctx, src_path, dst_path, hash_size);
|
||||||
}
|
}
|
||||||
TALLOC_FREE(rotate_path);
|
TALLOC_FREE(rotate_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret != 0) && (errno == ENOSPC) && rename_as_last_resort_if_nospc)
|
if ((ret != 0) && (errno == ENOSPC) && rename_as_last_resort_if_nospc)
|
||||||
{
|
{
|
||||||
DEBUG(10, ("backup of %s failed due to lack of space\n",
|
DEBUG(10, ("backup of %s failed due to lack of space\n",
|
||||||
src_path));
|
src_path));
|
||||||
DEBUGADD(10, ("using 'rename' as a last resort\n"));
|
DEBUGADD(10, ("using 'rename' as a last resort\n"));
|
||||||
ret = rename(src_path, dst_path);
|
ret = rename(src_path, dst_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -416,8 +416,8 @@ static int tdb_backup_with_rotate(TALLOC_CTX *ctx, const char *src_path,
|
|||||||
* - if the tdb is corrupt:
|
* - if the tdb is corrupt:
|
||||||
* - move the tdb to "name.corrupt"
|
* - move the tdb to "name.corrupt"
|
||||||
* - check if there is valid backup.
|
* - check if there is valid backup.
|
||||||
* if so, restore the backup.
|
* if so, restore the backup.
|
||||||
* if restore is successful, return 0 (success),
|
* if restore is successful, return 0 (success),
|
||||||
* - otherwise return -1 (failure)
|
* - otherwise return -1 (failure)
|
||||||
*/
|
*/
|
||||||
int tdb_validate_and_backup(const char *tdb_path,
|
int tdb_validate_and_backup(const char *tdb_path,
|
||||||
|
Reference in New Issue
Block a user