diff --git a/lib/dbfdb.c b/lib/dbfdb.c index dcdb642d..67c1305a 100644 --- a/lib/dbfdb.c +++ b/lib/dbfdb.c @@ -219,7 +219,7 @@ int mbsedb_InsertFDB(struct _fdbarea *fdb_area, struct FILE_record frec, int Add * No records yet, simply append this first record. */ Syslog('f', "append first record"); - fwrite(&frec, sizeof(frec), 1, fdb_area->fp); + fwrite(&frec, fdbhdr.recsize, 1, fdb_area->fp); mbsedb_UnlockFDB(fdb_area); return TRUE; } @@ -260,7 +260,7 @@ int mbsedb_InsertFDB(struct _fdbarea *fdb_area, struct FILE_record frec, int Add * Copy entries untill the insert point. */ for (i = 0; i < Insert; i++) { - fread(&fdb, fdbhdr.hdrsize, 1, fdb_area->fp); + fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp); /* * If we see a magic that is the new magic, remove * the old one. diff --git a/mbfido/mbfutil.c b/mbfido/mbfutil.c index 31ad99f5..27e8156e 100644 --- a/mbfido/mbfutil.c +++ b/mbfido/mbfutil.c @@ -304,9 +304,14 @@ int UnpackFile(char *File) */ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, char *LinkPath) { - char *temp1, *temp2; + int rc; +#ifdef USE_EXPERIMENT + struct _fdbarea *fdb_area = NULL; +#else + int i, Insert, Done = FALSE, Found = FALSE; FILE *fp1, *fp2; - int i, rc, Insert, Done = FALSE, Found = FALSE; + char *temp1, *temp2; +#endif /* * Copy file to the final destination and make a hard link with the @@ -338,6 +343,17 @@ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, c } } +#ifdef USE_EXPERIMENT + if ((fdb_area = mbsedb_OpenFDB(Area, 30))) { + Syslog('f', "opened"); + rc = mbsedb_InsertFDB(fdb_area, f_db, TRUE); + mbsedb_CloseFDB(fdb_area); + return rc; + } else { + Syslog('f', "not opened"); + return FALSE; + } +#else temp1 = calloc(PATH_MAX, sizeof(char)); temp2 = calloc(PATH_MAX, sizeof(char)); sprintf(temp1, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area); @@ -432,6 +448,7 @@ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, c free(temp1); free(temp2); return TRUE; +#endif }