Licensing Information

Open Source Used In Cisco FXOS 1.1(4) 953
/*
 the following union is implied
 union {
char record[rec_len];
 struct {
 char key[key_len];
char data[data_len];
 }
}
*/
};
/* a null data record - useful for error returns */
static TDB_DATA null_data;
/* a byte range locking function - return 0 on success
this functions locks/unlocks 1 byte at the specified offset */
static int tdb_brlock(TDB_CONTEXT *tdb, tdb_off offset,
 int set, int rw_type, int lck_type)
{
#if NOLOCK
return 0;
#else
struct flock fl;
if (tdb->fd == -1) return 0; /* for in memory tdb */
if (tdb->read_only) return -1;
fl.l_type = set==LOCK_SET?rw_type:F_UNLCK;
fl.l_whence = SEEK_SET;
fl.l_start = offset;
fl.l_len = 1;
fl.l_pid = 0;
if (fcntl(tdb->fd, lck_type, &fl) != 0) {
#if TDB_DEBUG
if (lck_type == F_SETLKW) {
printf("lock %d failed at %d (%s)\n",
 set, offset, strerror(errno));
}
#endif
tdb->ecode = TDB_ERR_LOCK;
return -1;
}
return 0;
#endif
}