/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
+#include <roken.h>
-#include <stdio.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#else
-#include <netinet/in.h>
-#include <netdb.h>
-#endif
-#include <string.h>
-#include <afs/stds.h>
-#include <sys/types.h>
#include <lock.h>
#include <ubik.h>
+#include <afs/cellconfig.h>
+#include <afs/audit.h>
+
#include "database.h"
#include "error_macros.h"
#include "budb_errs.h"
#include "budb_internal.h"
-#include <afs/cellconfig.h>
-#include "afs/audit.h"
#undef min
#undef max
/* notes
* 1) volInfo structures refering to a volume of the same name are
* chained together, i.e. the volumes described differ in volid, partition
- * etc. The structure at the head of this list (the sameNameChain) is
- * treated specially. When a delete volInfo request is processed, heads
+ * etc. The structure at the head of this list (the sameNameChain) is
+ * treated specially. When a delete volInfo request is processed, heads
* are not deleted unless all other items on the sameNameChain are gone.
*
* The result is that volInfo (head) structures may be present
* is only for the off-line case.
*/
-/* flags associated with each structure. These are set and checked in
+/* flags associated with each structure. These are set and checked in
* the blockMap entries
*/
extern int sizeFunctions[];
extern int nHTBuckets;
-afs_int32 DbVerify(struct rx_call *call, afs_int32 *status,
+afs_int32 DbVerify(struct rx_call *call, afs_int32 *status,
afs_int32 *orphans, afs_int32 *host);
afs_int32 verifyTextChain(struct ubik_trans *ut, struct textBlock *tbPtr);
-
+
#define DBBAD BUDB_DATABASEINCONSISTENT
*/
afs_int32
-checkDiskAddress(unsigned long address, int type, int *blockIndexPtr,
+checkDiskAddress(unsigned long address, int type, int *blockIndexPtr,
int *entryIndexPtr)
{
int index, offset;
*/
/* verifyDumpEntry
- * Follow the tapes entries hanging off of a dump and verify they belong
+ * Follow the tapes entries hanging off of a dump and verify they belong
* to the dump.
*/
afs_int32
void *param)
{
struct dump *dumpPtr = (struct dump *)param;
-
+
struct tape tape;
afs_int32 tapeAddr, tapeCount = 0, volCount = 0, appDumpCount = 0;
afs_int32 appDumpAddr, appDumpIndex, appDumpOffset;
/*
* verifyTapeEntry
- * Follw the volume fragments hanging off of a tape entry and verify
+ * Follw the volume fragments hanging off of a tape entry and verify
* they belong to the tape.
*/
afs_int32
* also verify all entries are also on the chain.
*/
afs_int32
-verifyVolInfoEntry(struct ubik_trans *ut, afs_int32 volInfoAddr, int ai,
+verifyVolInfoEntry(struct ubik_trans *ut, afs_int32 volInfoAddr, int ai,
int ao, void *param)
{
struct volInfo *volInfo = (struct volInfo *) param;
-
+
int volCount = 0, ccheck = 1;
afs_int32 volFragAddr;
int blockIndex, entryIndex;
if (volCount > misc->maxVolsPerVolInfo)
misc->maxVolsPerVolInfo = volCount;
- /* Check that all volInfo structures with same name point to the same
+ /* Check that all volInfo structures with same name point to the same
* head. If sameNameHead == 0, this is the head structure so we check,
* otherwise ignore
*/
*/
/* verifyBlocks
- * Read each block header of every 2K block and remember it in our global
+ * Read each block header of every 2K block and remember it in our global
* blockMap array. Also check that the type of block is good.
*/
afs_int32
bmsize =
sizeof(*ablockMap) + (blockEntries[blocktype] -
1) * sizeof(ablockMap->entries[0]);
- ablockMap = (struct blockMap *)malloc(bmsize);
+ ablockMap = calloc(1, bmsize);
if (!ablockMap)
ERROR(BUDB_NOMEM);
- memset(ablockMap, 0, bmsize);
ablockMap->nEntries = blockEntries[blocktype];
/* verifyHashTableBlock
* Take a 2K hash table block and traverse its entries. Make sure each entry
- * is of the correct type for the hash table, is hashed into the correct
+ * is of the correct type for the hash table, is hashed into the correct
* entry and is not threaded on multiple lists.
*/
afs_int32
}
/* verifyHashTable
- * Read each 2K block a hashtable has (both its old hastable and
+ * Read each 2K block a hashtable has (both its old hastable and
* new hashtable) and verify the block has not been read before.
* Will also make call to verify entries within each 2K block of
* the hash table.
*/
afs_int32
-verifyHashTable(struct ubik_trans *ut, struct memoryHashTable *mhtPtr,
+verifyHashTable(struct ubik_trans *ut, struct memoryHashTable *mhtPtr,
int mapBit)
{
struct hashTable *htPtr = mhtPtr->ht;
{
afs_int32 code;
afs_int32 offset;
+ afs_int32 start;
int blockIndex, entryIndex;
char entry[sizeof(struct block)];
int entrySize;
int type;
int nFree;
- static afs_int32(*checkEntry[NBLOCKTYPES]) (struct ubik_trans *,
+ static afs_int32(*checkEntry[NBLOCKTYPES]) (struct ubik_trans *,
afs_int32, int, int, void *)
= {
/* FIXME: this list does not match typeName[] and may be incorrect */
return BUDB_IO;
/* check if entry is free by looking at the first "afs_int32" of the structure */
- if (*((afs_int32 *) & entry[0]) == 0) { /* zero is free */
+ memcpy(&start, entry, sizeof(start));
+ if (start == 0) { /* zero is free */
/* Is it on any hash chain? */
if (blockMap[blockIndex]->entries[entryIndex] & MAP_HASHES) {
Log("Entry: blockindex %d, entryindex %d - marked free but hashed 0x%x\n", blockIndex, entryIndex, blockMap[blockIndex]->entries[entryIndex]);
Log(" Skipping remainder of free chain\n");
if (BumpErrors())
return (DBBAD);
- code = 0;
break;
}
for (new = 0; new < 2; new++) {
size = 0;
- blockAddr = ntohl(tbPtr->textAddr);
for (blockAddr =
(new ? ntohl(tbPtr->newTextAddr) : ntohl(tbPtr->textAddr));
/* construct block map - first level is the array of pointers */
bmsize = nBlocks * sizeof(struct blockMap *);
- blockMap = (struct blockMap **)malloc(bmsize);
+ blockMap = calloc(1, bmsize);
if (!blockMap)
ERROR(BUDB_NOMEM);
- memset(blockMap, 0, bmsize);
/* verify blocks and construct the block map */
Log("Read header of every block\n");
}
afs_int32
-DbVerify(struct rx_call *call, afs_int32 *status, afs_int32 *orphans,
+DbVerify(struct rx_call *call, afs_int32 *status, afs_int32 *orphans,
afs_int32 *host)
{
struct ubik_trans *ut = 0;