Updates for new fdb code

This commit is contained in:
Michiel Broek 2004-05-07 14:31:47 +00:00
parent 17ab344dee
commit b10f7ae4c0
5 changed files with 84 additions and 11 deletions

View File

@ -63,12 +63,16 @@ v0.51.4 11-Apr-2004
Reading news works, no posts yet. Reading news works, no posts yet.
mbsebbs: mbsebbs:
Added loging of virus scanner results. Added logging of virus scanner results.
Patches for offline reader programs that create messages with Patches for offline reader programs that create messages with
wrong line terminaters (Sempoint). wrong line terminaters (Sempoint).
Added new experimental files database code which will only be Added new experimental files database code which will only be
used if configured with --enable-experiment. used if configured with --enable-experiment.
mball:
Added new experimental files database code which will only be
used if configured with --enable-experiment.
mbsetup: mbsetup:
Added auto setup for message area creation date. Also creates Added auto setup for message area creation date. Also creates
a faked newsgroup name in echomail areas. Both settings are a faked newsgroup name in echomail areas. Both settings are
@ -78,6 +82,8 @@ v0.51.4 11-Apr-2004
Fixed a header include. Fixed a header include.
Fixed an error where new created file areas were created Fixed an error where new created file areas were created
without a file header. without a file header.
Added new experimental files database code which will only be
used if configured with --enable-experiment.
mbtask: mbtask:
Removed debug logging for the disk thread. Removed debug logging for the disk thread.

View File

@ -268,16 +268,23 @@ void BotBox(FILE *fp, int doit)
void Masterlist() void Masterlist()
{ {
FILE *fp, *np, *pAreas, *pFile, *pHeader; FILE *fp, *np, *pAreas, *pHeader;
int AreaNr = 0, z, x = 0, New; int AreaNr = 0, z, x = 0, New;
unsigned long AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0; unsigned long AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0;
unsigned long AllAreaFiles, AllAreaBytes, popdown, down; unsigned long AllAreaFiles, AllAreaBytes, popdown, down;
unsigned long NewAreaFiles, NewAreaBytes; unsigned long NewAreaFiles, NewAreaBytes;
char *sAreas, *fAreas; char *sAreas;
char temp[81], pop[81]; char temp[81], pop[81];
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
char *fAreas;
fAreas = calloc(PATH_MAX, sizeof(char));
#endif
sAreas = calloc(PATH_MAX, sizeof(char)); sAreas = calloc(PATH_MAX, sizeof(char));
fAreas = calloc(PATH_MAX, sizeof(char));
IsDoing("Create Allfiles list"); IsDoing("Create Allfiles list");
@ -334,14 +341,24 @@ void Masterlist()
if (area.Available && (area.LTSec.level <= CFG.security.level)) { if (area.Available && (area.LTSec.level <= CFG.security.level)) {
Nopper(); Nopper();
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), AreaNr);
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)) == 0) {
#else
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), AreaNr);
if ((pFile = fopen (fAreas, "r")) == NULL) { if ((pFile = fopen (fAreas, "r")) == NULL) {
#endif
WriteError("$Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name); WriteError("$Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name);
} else { } else {
#ifndef USE_EXPERIMENT
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile); fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
#endif
popdown = 0; popdown = 0;
#ifdef USE_EXPERIMENT
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
if (!fdb.Deleted) { if (!fdb.Deleted) {
/* /*
* The next is to reduce system load. * The next is to reduce system load.
@ -395,8 +412,13 @@ void Masterlist()
BotBox(fp, TRUE); BotBox(fp, TRUE);
BotBox(np, NewAreaFiles); BotBox(np, NewAreaFiles);
#ifdef USE_EXPERIMENT
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
fseek(pFile, fdbhdr.hdrsize, SEEK_SET); fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
if (!fdb.Deleted) { if (!fdb.Deleted) {
New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays); New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays);
sprintf(temp, "%-12s%10lu K %s [%04ld] Uploader: %s", sprintf(temp, "%-12s%10lu K %s [%04ld] Uploader: %s",
@ -427,8 +449,12 @@ void Masterlist()
} }
} }
} }
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
} #endif
}
} }
} /* End of While Loop Checking for Areas Done */ } /* End of While Loop Checking for Areas Done */
@ -474,7 +500,9 @@ void Masterlist()
Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024); Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024);
Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024); Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024);
free(sAreas); free(sAreas);
#ifndef USE_EXPERIMENT
free(fAreas); free(fAreas);
#endif
} }

View File

@ -81,7 +81,7 @@ m_protocol.o: ../config.h ../lib/mbselib.h ../paths.h screen.h mutil.h ledit.h s
m_ticarea.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h grlist.h m_global.h m_node.h m_fgroup.h m_farea.h m_archive.h m_ticarea.h m_ticarea.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h grlist.h m_global.h m_node.h m_fgroup.h m_farea.h m_archive.h m_ticarea.h
mbsetup.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h screen.h mutil.h ledit.h m_global.h m_bbs.h m_farea.h m_fgroup.h m_mail.h m_mgroup.h m_hatch.h m_tic.h m_ticarea.h m_magic.h m_fido.h m_lang.h m_archive.h m_virus.h m_tty.h m_limits.h m_users.h m_node.h m_fdb.h m_new.h m_ol.h m_bbslist.h m_protocol.h m_ff.h m_modem.h m_marea.h m_ngroup.h m_service.h m_domain.h m_task.h m_route.h mbsetup.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h screen.h mutil.h ledit.h m_global.h m_bbs.h m_farea.h m_fgroup.h m_mail.h m_mgroup.h m_hatch.h m_tic.h m_ticarea.h m_magic.h m_fido.h m_lang.h m_archive.h m_virus.h m_tty.h m_limits.h m_users.h m_node.h m_fdb.h m_new.h m_ol.h m_bbslist.h m_protocol.h m_ff.h m_modem.h m_marea.h m_ngroup.h m_service.h m_domain.h m_task.h m_route.h
ledit.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h screen.h mutil.h ledit.h ledit.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h screen.h mutil.h ledit.h
m_farea.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h m_global.h m_fgroup.h m_archive.h m_farea.h m_fgroup.h m_ngroup.h m_farea.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h screen.h mutil.h ledit.h m_global.h m_fgroup.h m_archive.h m_farea.h m_fgroup.h m_ngroup.h
m_fido.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_global.h m_fido.h m_fido.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_global.h m_fido.h
m_limits.o: ../config.h ../lib/mbselib.h ../lib/users.h screen.h mutil.h ledit.h stlist.h m_global.h m_limits.h m_limits.o: ../config.h ../lib/mbselib.h ../lib/users.h screen.h mutil.h ledit.h stlist.h m_global.h m_limits.h
m_menu.o: ../config.h ../lib/mbselib.h mutil.h screen.h ledit.h m_lang.h m_global.h m_menu.h m_menu.o: ../config.h ../lib/mbselib.h mutil.h screen.h ledit.h m_lang.h m_global.h m_menu.h
@ -90,7 +90,7 @@ m_service.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_gl
m_tty.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_modem.h m_global.h m_tty.h m_tty.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_modem.h m_global.h m_tty.h
mutil.o: ../config.h ../lib/mbselib.h ../lib/diesel.h screen.h ledit.h mutil.h mutil.o: ../config.h ../lib/mbselib.h ../lib/diesel.h screen.h ledit.h mutil.h
m_archive.o: ../config.h ../lib/mbselib.h ../paths.h screen.h mutil.h ledit.h stlist.h m_global.h m_archive.h m_archive.o: ../config.h ../lib/mbselib.h ../paths.h screen.h mutil.h ledit.h stlist.h m_global.h m_archive.h
m_fdb.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h m_global.h m_farea.h m_fdb.h m_fdb.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h screen.h mutil.h ledit.h m_global.h m_farea.h m_fdb.h
m_global.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h m_node.h m_marea.h m_ticarea.h m_new.h m_fgroup.h m_mgroup.h m_limits.h m_global.h m_global.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h m_node.h m_marea.h m_ticarea.h m_new.h m_fgroup.h m_mgroup.h m_limits.h m_global.h
m_magic.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_ticarea.h m_global.h m_magic.h m_magic.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_ticarea.h m_global.h m_magic.h
m_mgroup.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_global.h m_node.h m_marea.h m_mgroup.h m_mgroup.o: ../config.h ../lib/mbselib.h screen.h mutil.h ledit.h stlist.h m_global.h m_node.h m_marea.h m_mgroup.h

View File

@ -30,6 +30,8 @@
#include "../config.h" #include "../config.h"
#include "../lib/mbselib.h" #include "../lib/mbselib.h"
#include "../lib/users.h"
#include "../lib/mbsedb.h"
#include "screen.h" #include "screen.h"
#include "mutil.h" #include "mutil.h"
#include "ledit.h" #include "ledit.h"
@ -244,7 +246,7 @@ void FileScreen(void)
*/ */
int EditFileRec(int Area) int EditFileRec(int Area)
{ {
FILE *fil, *fp; FILE *fil;
char mfile[PATH_MAX], *temp, tpath[65], frpath[81], topath[81]; char mfile[PATH_MAX], *temp, tpath[65], frpath[81], topath[81];
long offset; long offset;
unsigned long crc, crc1; unsigned long crc, crc1;
@ -252,6 +254,11 @@ int EditFileRec(int Area)
DIR *dp; DIR *dp;
struct dirent *de; struct dirent *de;
struct stat stb; struct stat stb;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *fp;
#endif
clr_index(); clr_index();
working(1, 0, 0); working(1, 0, 0);
@ -370,6 +377,17 @@ int EditFileRec(int Area)
/* /*
* Attempt to disable this area, but check first. * Attempt to disable this area, but check first.
*/ */
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
fseek(fdb_area->fp, 0, SEEK_END);
files = ((ftell(fdb_area->fp) - fdbhdr.hdrsize) / fdbhdr.recsize);
if (files) {
errmsg("There are stil %d files in this area", files);
Available = TRUE;
}
mbsedb_CloseFDB(fdb_area);
}
#else
if ((fp = fopen(temp, "r"))) { if ((fp = fopen(temp, "r"))) {
if (fread(&fdbhdr, sizeof(fdbhdr), 1, fp) == 1) { if (fread(&fdbhdr, sizeof(fdbhdr), 1, fp) == 1) {
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
@ -381,6 +399,7 @@ int EditFileRec(int Area)
} }
fclose(fp); fclose(fp);
} }
#endif
if (!Available) { if (!Available) {
if (yes_no((char *)"Are you sure you want to delete this area") == 0) if (yes_no((char *)"Are you sure you want to delete this area") == 0)
Available = TRUE; Available = TRUE;
@ -416,6 +435,10 @@ int EditFileRec(int Area)
} }
if (!area.Available && Available) { if (!area.Available && Available) {
area.Available = TRUE; area.Available = TRUE;
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(Area, 30)))
mbsedb_CloseFDB(fdb_area);
#else
if ((fp = fopen(temp, "a+")) == NULL) { if ((fp = fopen(temp, "a+")) == NULL) {
WriteError("$Can't create file database %s", temp); WriteError("$Can't create file database %s", temp);
} else { } else {
@ -425,6 +448,7 @@ int EditFileRec(int Area)
fclose(fp); fclose(fp);
} }
chmod(temp, 0660); chmod(temp, 0660);
#endif
} }
free(temp); free(temp);
break; break;

View File

@ -30,6 +30,8 @@
#include "../config.h" #include "../config.h"
#include "../lib/mbselib.h" #include "../lib/mbselib.h"
#include "../lib/users.h"
#include "../lib/mbsedb.h"
#include "screen.h" #include "screen.h"
#include "mutil.h" #include "mutil.h"
#include "ledit.h" #include "ledit.h"
@ -357,7 +359,10 @@ void InitFDB(void)
struct dirent *de; struct dirent *de;
struct OldFILERecord old; struct OldFILERecord old;
struct stat sb; struct stat sb;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#endif
records = CountFilearea(); records = CountFilearea();
if (records <= 0) if (records <= 0)
return; return;
@ -448,7 +453,17 @@ void InitFDB(void)
fclose(fp1); fclose(fp1);
sprintf(temp, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), Area); sprintf(temp, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), Area);
unlink(temp); unlink(temp);
} } // Old area type upgrade.
/*
* Current area, check
*/
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
WriteError("InitFDB(): database area %ld might be corrupt", Area);
else
mbsedb_CloseFDB(fdb_area);
#endif
} }
} }
fclose(fil); fclose(fil);