• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asus-wl-520gu-7.0.1.45/src/router/e2fsprogs-1.40.8/lib/ext2fs/

Lines Matching refs:key

173 	tdb_len_t key_len; /* byte length of key */
175 u32 full_hash; /* the full 32 bit hash of the key */
181 char key[key_len];
242 unsigned int (*hash_fn)(TDB_DATA *key);
279 static int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key,
281 int (*parser)(TDB_DATA key, TDB_DATA data,
284 static tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash, int locktype,
745 int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key)
747 return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK);
753 int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key)
755 return tdb_lock_nonblock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK);
759 int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key)
761 return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK | TDB_MARK_LOCK);
765 int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key)
767 return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK | TDB_MARK_LOCK);
770 int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key)
772 return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK);
775 int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key)
777 return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_RDLCK);
780 int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key)
782 return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_RDLCK);
1160 int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key,
1162 int (*parser)(TDB_DATA key, TDB_DATA data,
1180 return parser(key, data, private_data);
1187 result = parser(key, data, private_data);
2571 TDB_DATA key, data;
2574 key.dptr = (unsigned char *)&rec_ptr;
2575 key.dsize = sizeof(rec_ptr);
2576 return tdb_store(mem_tdb, key, data, TDB_INSERT);
2747 /* traverse the entire database - calling fn(tdb, key, data) on each element.
2756 TDB_DATA key, dbuf;
2772 key.dptr = tdb_alloc_read(tdb, tl->off + sizeof(rec),
2774 if (!key.dptr) {
2779 TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_traverse: key.dptr == NULL and unlock_record failed!\n"));
2782 key.dsize = rec.key_len;
2783 dbuf.dptr = key.dptr + rec.key_len;
2789 SAFE_FREE(key.dptr);
2792 if (fn && fn(tdb, key, dbuf, private_data)) {
2799 SAFE_FREE(key.dptr);
2802 SAFE_FREE(key.dptr);
2863 /* find the first entry in the database and return its key */
2866 TDB_DATA key;
2878 /* now read the key */
2879 key.dsize = rec.key_len;
2880 key.dptr =tdb_alloc_read(tdb,tdb->travlocks.off+sizeof(rec),key.dsize);
2885 return key;
2888 /* find the next entry in the database, returning its key */
2892 TDB_DATA key = tdb_null;
2896 /* Is locked key the old key? If so, traverse will be reliable. */
2935 key.dsize = rec.key_len;
2936 key.dptr = tdb_alloc_read(tdb, tdb->travlocks.off+sizeof(rec),
2937 key.dsize);
2945 return key;
3101 static int tdb_key_compare(TDB_DATA key, TDB_DATA data, void *private_data)
3103 return memcmp(data.dptr, key.dptr, data.dsize);
3108 static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, u32 hash,
3123 && key.dsize==r->key_len
3124 && tdb_parse_data(tdb, key, rec_ptr + sizeof(*r),
3135 tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash, int locktype,
3142 if (!(rec_ptr = tdb_find(tdb, key, hash, rec)))
3149 is <= the old data size and the key exists.
3152 static int tdb_update_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash, TDB_DATA dbuf)
3158 if (!(rec_ptr = tdb_find(tdb, key, hash, &rec)))
3161 /* must be long enough key, data and tailer */
3162 if (rec.rec_len < key.dsize + dbuf.dsize + sizeof(tdb_off_t)) {
3180 /* find an entry in the database given a key */
3182 * TDB_ERR_NOEXIST. If a key has no data attached
3186 TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key)
3194 hash = tdb->hash_fn(&key);
3195 if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec)))
3221 int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
3222 int (*parser)(TDB_DATA key, TDB_DATA data,
3232 hash = tdb->hash_fn(&key);
3234 if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec))) {
3238 ret = tdb_parse_data(tdb, key, rec_ptr + sizeof(rec) + rec.key_len,
3248 note that 1 is returned if the key is found and 0 is returned if not found
3252 static int tdb_exists_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash)
3256 if (tdb_find_lock_hash(tdb, key, hash, F_RDLCK, &rec) == 0)
3262 int tdb_exists(struct tdb_context *tdb, TDB_DATA key)
3264 u32 hash = tdb->hash_fn(&key);
3265 return tdb_exists_hash(tdb, key, hash);
3363 /* delete an entry in the database given a key */
3364 static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash)
3388 if (!(rec_ptr = tdb_find(tdb, key, hash, &rec))) {
3400 if (!(rec_ptr = tdb_find_lock_hash(tdb, key, hash, F_WRLCK,
3416 int tdb_delete(struct tdb_context *tdb, TDB_DATA key)
3418 u32 hash = tdb->hash_fn(&key);
3419 return tdb_delete_hash(tdb, key, hash);
3452 with the same key
3456 int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
3470 hash = tdb->hash_fn(&key);
3476 if (tdb_exists_hash(tdb, key, hash)) {
3482 if (tdb_update_hash(tdb, key, hash, dbuf) == 0) {
3499 tdb_delete_hash(tdb, key, hash);
3501 /* Copy key+value *before* allocating free space in case malloc
3504 if (!(p = (char *)malloc(key.dsize + dbuf.dsize))) {
3509 memcpy(p, key.dptr, key.dsize);
3511 memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize);
3517 * for key, data and tailer. If we find one, we don't have to
3522 key.dsize + dbuf.dsize + sizeof(tdb_off_t));
3525 rec.key_len = key.dsize;
3532 p, key.dsize + dbuf.dsize) == -1) {
3556 rec_ptr = tdb_allocate(tdb, key.dsize + dbuf.dsize, &rec);
3568 rec.key_len = key.dsize;
3575 || tdb->methods->tdb_write(tdb, rec_ptr+sizeof(rec), p, key.dsize+dbuf.dsize)==-1
3595 int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf)
3602 hash = tdb->hash_fn(&key);
3606 dbuf = tdb_fetch(tdb, key);
3627 ret = tdb_store(tdb, key, dbuf, 0);
3714 static unsigned int default_tdb_hash(TDB_DATA *key)
3719 /* Set the initial value from the key size. */
3720 for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++)
3721 value = (value + (key->dptr[i] << (i*5 % 24)));