Fixed 64/32 bit files database issue
This commit is contained in:
parent
fb9122255c
commit
2f779324e2
18
ChangeLog
18
ChangeLog
@ -1,7 +1,25 @@
|
||||
$Id$
|
||||
|
||||
WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
|
||||
|
||||
Users of 64 bit systems should backup the files database and
|
||||
all download directories before attempting to use 0.83.13.
|
||||
This will upgrade the files database on 64 bit systems, but
|
||||
also copied databases from 64 to 32 bit systems.
|
||||
|
||||
Alan and Rolf, please report the results of the upgrade.
|
||||
|
||||
|
||||
v0.83.13 13-Feb-2006
|
||||
|
||||
upgrade:
|
||||
Start mbsetup and leave. If files databases need to be fixed
|
||||
it will then be done.
|
||||
|
||||
mbselib.a:
|
||||
Fixed another 32/64 bit issue in the files databases and added
|
||||
automatic correction if detected.
|
||||
|
||||
mbsebbs:
|
||||
Writes LINES and COLUMNS environment into data.msg so that the
|
||||
joe editor can use that.
|
||||
|
39
lib/dbfdb.c
39
lib/dbfdb.c
@ -42,10 +42,10 @@
|
||||
*/
|
||||
struct _fdbarea *mbsedb_OpenFDB(int Area, int Timeout)
|
||||
{
|
||||
char *temp;
|
||||
char *temp, *temp2;
|
||||
struct _fdbarea *fdb_area = NULL;
|
||||
int Tries = 0;
|
||||
FILE *fp;
|
||||
FILE *fp, *fp2;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
fdb_area = malloc(sizeof(struct _fdbarea)); /* Will be freed by CloseFDB */
|
||||
@ -86,6 +86,36 @@ struct _fdbarea *mbsedb_OpenFDB(int Area, int Timeout)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((fdbhdr.hdrsize == sizeof(fdbhdr)) && (fdbhdr.recsize == (sizeof(fdb) + 4))) {
|
||||
Syslog('+', "Files area %d database 64/32 bit alignment error, fixing...", Area);
|
||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||
snprintf(temp2, PATH_MAX -1, "%s/var/fdb/file%d.temp", getenv("MBSE_ROOT"), Area);
|
||||
if ((fp2 = fopen(temp2, "w+"))) {
|
||||
fdbhdr.recsize = (sizeof(fdb));
|
||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, fp2);
|
||||
fdbhdr.recsize = sizeof(fdb) + 4;
|
||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
||||
/*
|
||||
* Shift 4 bytes
|
||||
*/
|
||||
memmove(&fdb.Crc32, &fdb.Uploader, sizeof(fdb) - 179);
|
||||
fwrite(&fdb, sizeof(fdb), 1, fp2);
|
||||
}
|
||||
fclose(fp2);
|
||||
fclose(fp);
|
||||
unlink(temp);
|
||||
rename(temp2, temp);
|
||||
if ((fp = fopen(temp, "r+"))) {
|
||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
||||
} else {
|
||||
WriteError("$Can't reopen %s", temp);
|
||||
}
|
||||
} else {
|
||||
WriteError("$Can't create %s", temp2);
|
||||
}
|
||||
free(temp2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fix attributes if needed
|
||||
*/
|
||||
@ -93,8 +123,9 @@ struct _fdbarea *mbsedb_OpenFDB(int Area, int Timeout)
|
||||
free(temp);
|
||||
|
||||
if ((fdbhdr.hdrsize != sizeof(fdbhdr)) || (fdbhdr.recsize != sizeof(fdb))) {
|
||||
WriteError("Files database header in area %d is corrupt (%d:%d)", Area, fdbhdr.hdrsize, fdbhdr.recsize);
|
||||
fclose(fdb_area->fp);
|
||||
WriteError("Files database header in area %d is corrupt (%d:%d) [%d:%d]", Area, fdbhdr.hdrsize, fdbhdr.recsize,
|
||||
sizeof(fdbhdr), sizeof(fdb));
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
14
lib/mbse.h
14
lib/mbse.h
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Global variables for MBSE BBS
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2005
|
||||
* Copyright (C) 1997-2006
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -36,12 +36,12 @@
|
||||
|
||||
|
||||
typedef struct _TagRec {
|
||||
int Area; /* File Area number */
|
||||
int Active; /* Not deleted from taglist */
|
||||
int Cost; /* Free download */
|
||||
off_t Size; /* File Size */
|
||||
char SFile[13]; /* Short File Name */
|
||||
char LFile[81]; /* Long FIle Name */
|
||||
int Area; /* File Area number */
|
||||
int Active; /* Not deleted from taglist */
|
||||
int Cost; /* Free download */
|
||||
unsigned int Size; /* File Size */
|
||||
char SFile[13]; /* Short File Name */
|
||||
char LFile[81]; /* Long FIle Name */
|
||||
} _Tag;
|
||||
|
||||
|
||||
|
@ -839,7 +839,7 @@ struct FILE_record {
|
||||
char Name[13]; /* DOS style filename */
|
||||
char LName[81]; /* Long filename */
|
||||
char TicArea[21]; /* Tic area file came in */
|
||||
off_t Size; /* File Size */
|
||||
unsigned int Size; /* File Size */
|
||||
unsigned int Crc32; /* File CRC-32 */
|
||||
char Uploader[36]; /* Uploader name */
|
||||
int32_t UploadDate; /* Date/Time uploaded */
|
||||
@ -865,7 +865,7 @@ struct OldFILERecord {
|
||||
char LName[81]; /* Long filename */
|
||||
char xTicArea[9]; /* Tic area file came in */
|
||||
unsigned int TicAreaCRC; /* CRC of TIC area name */
|
||||
off_t Size; /* File Size */
|
||||
unsigned int Size; /* File Size */
|
||||
unsigned int Crc32; /* File CRC-32 */
|
||||
char Uploader[36]; /* Uploader name */
|
||||
int32_t UploadDate; /* Date/Time uploaded */
|
||||
@ -1979,7 +1979,7 @@ struct _filerecord {
|
||||
char Group[13]; /* Group */
|
||||
char Name[13]; /* File Name */
|
||||
char LName[81]; /* Long FileName */
|
||||
off_t Size; /* File Size */
|
||||
unsigned int Size; /* File Size */
|
||||
unsigned int SizeKb; /* File Size in Kb */
|
||||
int32_t Fdate; /* File Date */
|
||||
char Origin[24]; /* Origin system */
|
||||
|
@ -429,8 +429,14 @@ int EditFileRec(int Area)
|
||||
}
|
||||
if (!area.Available && Available) {
|
||||
area.Available = TRUE;
|
||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30)))
|
||||
Syslog('-', "open");
|
||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
||||
Syslog('-', "is open");
|
||||
mbsedb_CloseFDB(fdb_area);
|
||||
Syslog('-', "closed");
|
||||
} else {
|
||||
Syslog('-', "failed to open");
|
||||
}
|
||||
}
|
||||
free(temp);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user