Gets us one extra ccanlint point, too.
- /*
+ /*
Trivial Database 2: free list/block handling
Copyright (C) Rusty Russell 2010
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
if (is_subhash(group[b])) {
uint64_t subprefix;
- subprefix = (hprefix
+ subprefix = (hprefix
<< (group_bits + TDB_HASH_GROUP_BITS))
+ g * (1 << TDB_HASH_GROUP_BITS) + b;
}
return true;
}
-
+
static bool check_free_table(struct tdb_context *tdb,
tdb_off_t ftable_off,
unsigned ftable_num,
- /*
+ /*
Trivial Database 2: free list/block handling
Copyright (C) Rusty Russell 2010
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- /*
+ /*
Trivial Database 2: hash handling
Copyright (C) Rusty Russell 2010
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
tinfo->toplevel_group = group;
tinfo->num_levels = 1;
tinfo->levels[0].entry = 0;
- tinfo->levels[0].hashtable = hashtable
+ tinfo->levels[0].hashtable = hashtable
+ (group << TDB_HASH_GROUP_BITS) * sizeof(tdb_off_t);
tinfo->levels[0].total_buckets = 1 << TDB_HASH_GROUP_BITS;
}
<< TDB_OFF_HASH_EXTRA_BIT);
}
-/* Simply overwrite the hash entry we found before. */
+/* Simply overwrite the hash entry we found before. */
int replace_in_hash(struct tdb_context *tdb,
struct hash_info *h,
tdb_off_t new_off)
/* They want data as well? */
if (dlen) {
*dlen = rec_data_length(&rec);
- kbuf->dptr = tdb_alloc_read(tdb,
+ kbuf->dptr = tdb_alloc_read(tdb,
off + sizeof(rec),
kbuf->dsize
+ *dlen);
} else {
- kbuf->dptr = tdb_alloc_read(tdb,
+ kbuf->dptr = tdb_alloc_read(tdb,
off + sizeof(rec),
kbuf->dsize);
}
- /*
+ /*
Unix SMB/CIFS implementation.
trivial database library
/* check for an out of bounds access - if it is out of bounds then
see if the database has been expanded by someone else and expand
- if necessary
+ if necessary
note that "len" is the minimum length needed for the db
*/
static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, bool probe)
}
/* write a lump of data at a specified offset */
-static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
+static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
const void *buf, tdb_len_t len)
{
if (tdb->read_only) {
const void *tdb_access_read(struct tdb_context *tdb,
tdb_off_t off, tdb_len_t len, bool convert)
{
- const void *ret = NULL;
+ const void *ret = NULL;
if (likely(!(tdb->flags & TDB_CONVERT)))
ret = tdb->methods->direct(tdb, off, len, false);
- /*
+ /*
Unix SMB/CIFS implementation.
trivial database library
upgrade a read lock to a write lock. This needs to be handled in a
special way as some OSes (such as solaris) have too conservative
deadlock detection and claim a deadlock when progress can be
- made. For those OSes we may loop for a while.
+ made. For those OSes we may loop for a while.
*/
int tdb_allrecord_upgrade(struct tdb_context *tdb)
{
tdb_logerr(tdb, tdb->ecode, TDB_DEBUG_ERROR,
"tdb_allrecord_lock freetables failed");
}
- tdb_brunlock(tdb, ltype, TDB_HASH_LOCK_START,
+ tdb_brunlock(tdb, ltype, TDB_HASH_LOCK_START,
TDB_HASH_LOCK_RANGE);
return -1;
}
tdb_allrecord_unlock(tdb, ltype);
if (tdb_lock_and_recover(tdb) == -1) {
return -1;
- }
+ }
goto again;
}
#ifndef TDB_PRIVATE_H
#define TDB_PRIVATE_H
- /*
+ /*
Trivial Database 2: private types and prototypes
Copyright (C) Rusty Russell 2010
int mmap_flags;
/* Error code for last tdb error. */
- enum TDB_ERROR ecode;
+ enum TDB_ERROR ecode;
/* the flags passed to tdb_open, for tdb_reopen. */
uint32_t flags;
/* Single list of all TDBs, to avoid multiple opens. */
struct tdb_context *next;
- dev_t device;
+ dev_t device;
ino_t inode;
};
- /*
+ /*
Trivial Database 2: human-readable summary code
Copyright (C) Rusty Russell 2010
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
#ifndef CCAN_TDB2_H
#define CCAN_TDB2_H
-/*
+/*
Unix SMB/CIFS implementation.
trivial database library
Copyright (C) Andrew Tridgell 1999-2004
-
+
** NOTE! The following LGPL license applies to the tdb
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
#define TDB_ALLOW_NESTING 512 /* Allow transactions to nest */
/* error codes */
-enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
+enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOEXIST,
TDB_ERR_EINVAL, TDB_ERR_RDONLY, TDB_ERR_NESTING };
enum tdb_summary_flags { TDB_SUMMARY_HISTOGRAMS = 1 };
/* logging uses one of the following levels */
-enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR,
+enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR,
TDB_DEBUG_WARNING, TDB_DEBUG_TRACE};
typedef struct tdb_data {
- /*
+ /*
Trivial Database 2: traverse function.
Copyright (C) Rusty Russell 2010
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
default:
return tdb_null;
}
-}
+}
/* We lock twice, not very efficient. We could keep last key & tinfo cached. */
TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key)
default:
return tdb_null;
}
-}
+}