mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
- added tdb_add_flags() and tdb_remove_flags()
- make freelist merging more paranoid - fixed TDB_DATA_STAART() (broken by earlier commit) (This used to be ctdb commit c3be8eb7d1ca316111ec51f45dbca2fa5609cf93)
This commit is contained in:
parent
43aa27c9ee
commit
ff039b405f
@ -138,7 +138,7 @@ left:
|
||||
#endif
|
||||
|
||||
/* Look left */
|
||||
if (offset - sizeof(tdb_off_t) >= TDB_DATA_START(tdb->header.hash_size)) {
|
||||
if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->header.hash_size)) {
|
||||
tdb_off_t left = offset - sizeof(tdb_off_t);
|
||||
struct list_struct l;
|
||||
tdb_off_t leftsize;
|
||||
@ -156,7 +156,8 @@ left:
|
||||
|
||||
left = offset - leftsize;
|
||||
|
||||
if (left < TDB_DATA_START(tdb->header.hash_size)) {
|
||||
if (leftsize > offset ||
|
||||
left < TDB_DATA_START(tdb->header.hash_size)) {
|
||||
goto update;
|
||||
}
|
||||
|
||||
|
@ -666,6 +666,16 @@ int tdb_get_flags(struct tdb_context *tdb)
|
||||
return tdb->flags;
|
||||
}
|
||||
|
||||
void tdb_add_flags(struct tdb_context *tdb, unsigned flags)
|
||||
{
|
||||
tdb->flags |= flags;
|
||||
}
|
||||
|
||||
void tdb_remove_flags(struct tdb_context *tdb, unsigned flags)
|
||||
{
|
||||
tdb->flags &= ~flags;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
enable sequence number handling on an open tdb
|
||||
|
@ -58,7 +58,7 @@ typedef uint32_t tdb_off_t;
|
||||
#define TDB_BAD_MAGIC(r) ((r)->magic != TDB_MAGIC && !TDB_DEAD(r))
|
||||
#define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off_t))
|
||||
#define TDB_HASHTABLE_SIZE(tdb) ((tdb->header.hash_size+1)*sizeof(tdb_off_t))
|
||||
#define TDB_DATA_START(hash_size) TDB_HASH_TOP(hash_size)
|
||||
#define TDB_DATA_START(hash_size) (TDB_HASH_TOP(hash_size-1) + sizeof(tdb_off_t))
|
||||
#define TDB_RECOVERY_HEAD offsetof(struct tdb_header, recovery_start)
|
||||
#define TDB_SEQNUM_OFS offsetof(struct tdb_header, sequence_number)
|
||||
#define TDB_PAD_BYTE 0x42
|
||||
|
@ -135,6 +135,8 @@ int tdb_get_seqnum(struct tdb_context *tdb);
|
||||
int tdb_hash_size(struct tdb_context *tdb);
|
||||
size_t tdb_map_size(struct tdb_context *tdb);
|
||||
int tdb_get_flags(struct tdb_context *tdb);
|
||||
void tdb_add_flags(struct tdb_context *tdb, unsigned flag);
|
||||
void tdb_remove_flags(struct tdb_context *tdb, unsigned flag);
|
||||
void tdb_enable_seqnum(struct tdb_context *tdb);
|
||||
void tdb_increment_seqnum_nonblock(struct tdb_context *tdb);
|
||||
|
||||
@ -153,6 +155,7 @@ void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *sigptr)
|
||||
void tdb_dump_all(struct tdb_context *tdb);
|
||||
int tdb_printfreelist(struct tdb_context *tdb);
|
||||
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
|
||||
int tdb_wipe_all(struct tdb_context *tdb);
|
||||
|
||||
extern TDB_DATA tdb_null;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user