dos33: fix disk corruption on DELETE

was using &vtoc where it should have just been vtoc so writing the
pointer value rather than the buffer.  urgh
This commit is contained in:
Vince Weaver 2021-08-24 18:15:00 -04:00
parent 0b52583de6
commit 6b5c3612b0
4 changed files with 19 additions and 6 deletions

View File

@ -1,5 +1,7 @@
include ../../Makefile.inc
CFLAGS := $(CFLAGS) -g
all: dos33 mkdos33fs make_b \
dos33_raw \
dos33_text2ascii char2hex
@ -23,7 +25,7 @@ dos33: dos33.o \
dos33_vtoc_bitmap.o $(LFLAGS)
dos33.o: dos33.c dos33.h
$(CC) $(CFLAGS) -g -c dos33.c
$(CC) $(CFLAGS) -c dos33.c
###
@ -31,7 +33,7 @@ dos33_raw: dos33_raw.o
$(CC) -o dos33_raw dos33_raw.o $(LFLAGS)
dos33_raw.o: dos33_raw.c
$(CC) $(CFLAGS) -g -c dos33_raw.c
$(CC) $(CFLAGS) -c dos33_raw.c
###
@ -66,7 +68,7 @@ dos33_vtoc_bitmap.o: dos33_vtoc_bitmap.c dos33.h
###
dos33_catalog.o: dos33_catalog.c dos33.h
$(CC) $(CFLAGS) -g -c dos33_catalog.c
$(CC) $(CFLAGS) -c dos33_catalog.c
###

View File

@ -11,7 +11,7 @@
#include "dos33.h"
int debug=1;
int debug=0;
static int ignore_errors=0;
@ -120,10 +120,10 @@ static int dos33_free_sector(unsigned char *vtoc,int fd,int track,int sector) {
/* write modified VTOC back out */
lseek(fd,DISK_OFFSET(VTOC_TRACK,VTOC_SECTOR),SEEK_SET);
result=write(fd,&vtoc,BYTES_PER_SECTOR);
result=write(fd,vtoc,BYTES_PER_SECTOR);
if (result<0) {
fprintf(stderr,"Error on I/O\n");
fprintf(stderr,"dos33_free_sector: error writing VTOC\n");
}
return 0;
@ -767,6 +767,10 @@ keep_deleting:
/* Erase file from catalog entry */
/* First reload proper catalog sector */
if (debug) {
fprintf(stderr,"\treloading T=%d S=%d\n",
catalog_track,catalog_sector);
}
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
if (result<0) {

View File

@ -62,6 +62,11 @@ int dos33_vtoc_free_space(unsigned char *vtoc) {
/* free a sector from the sector bitmap */
void dos33_vtoc_free_sector(unsigned char *vtoc, int track, int sector) {
if (debug) {
fprintf(stderr,"vtoc_free: freeing T=%d S=%d\n",
track,sector);
}
/* each bitmap is 32 bits. With 16-sector tracks only first 16 used */
/* 1 indicates free, 0 indicates used */
if (sector<8) {

View File

@ -9,6 +9,8 @@
#include "dos33.h"
int debug=0;
static void usage(char *binary,int help) {
printf("\n%s - version %s\n",binary,VERSION);