Updates for new fdb code

This commit is contained in:
Michiel Broek
2004-05-05 11:40:10 +00:00
parent 75b991af56
commit 7aa6f678c2
2 changed files with 336 additions and 264 deletions

View File

@@ -39,7 +39,7 @@
/*
* Open files database Area number, with path. Do some checks and abort
* Open files database Area number. Do some checks and abort
* if they fail.
*/
struct _fdbarea *mbsedb_OpenFDB(long Area, int Timeout)
@@ -68,12 +68,27 @@ struct _fdbarea *mbsedb_OpenFDB(long Area, int Timeout)
msleep(250);
Syslog('f', "Open file area %ld, try %d", Area, Tries);
}
if (fp == NULL) {
if (errno == ENOENT) {
Syslog('+', "Create empty FDB for area %ld", Area);
fdbhdr.hdrsize = sizeof(fdbhdr);
fdbhdr.recsize = sizeof(fdb);
if ((fp = fopen(temp, "w+"))) {
fwrite(&fdbhdr, sizeof(fdbhdr), 1, fp);
}
}
} else {
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
}
/*
* If still not open, it's fatal.
*/
if (fp == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
return NULL;
}
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
/*
* Fix attributes if needed