mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-27 07:29:29 +00:00
dos33: add debugging
chasing a weird corruption issue on DELETE
This commit is contained in:
parent
2c116d9f71
commit
0b52583de6
|
@ -66,7 +66,7 @@ dos33_vtoc_bitmap.o: dos33_vtoc_bitmap.c dos33.h
|
||||||
###
|
###
|
||||||
|
|
||||||
dos33_catalog.o: dos33_catalog.c dos33.h
|
dos33_catalog.o: dos33_catalog.c dos33.h
|
||||||
$(CC) $(CFLAGS) -c dos33_catalog.c
|
$(CC) $(CFLAGS) -g -c dos33_catalog.c
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
|
|
||||||
#include "dos33.h"
|
#include "dos33.h"
|
||||||
|
|
||||||
static int debug=0,ignore_errors=0;
|
int debug=1;
|
||||||
|
|
||||||
|
static int ignore_errors=0;
|
||||||
|
|
||||||
static unsigned char get_high_byte(int value) {
|
static unsigned char get_high_byte(int value) {
|
||||||
return (value>>8)&0xff;
|
return (value>>8)&0xff;
|
||||||
|
@ -684,6 +686,11 @@ static int dos33_delete_file(unsigned char *vtoc,int fd,int fsl) {
|
||||||
catalog_track=(fsl>>8)&0xff;
|
catalog_track=(fsl>>8)&0xff;
|
||||||
catalog_sector=(fsl&0xff);
|
catalog_sector=(fsl&0xff);
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
fprintf(stderr,"DELETE: deleting file T=%d S=%d E=%d\n",
|
||||||
|
catalog_track,catalog_sector,catalog_entry);
|
||||||
|
}
|
||||||
|
|
||||||
/* Load in the catalog table for the file */
|
/* Load in the catalog table for the file */
|
||||||
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
|
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
|
||||||
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
|
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
|
||||||
|
@ -705,9 +712,17 @@ static int dos33_delete_file(unsigned char *vtoc,int fd,int fsl) {
|
||||||
|
|
||||||
keep_deleting:
|
keep_deleting:
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
fprintf(stderr,"\tLoading T/S list T=%d S=%d\n",
|
||||||
|
ts_track,ts_sector);
|
||||||
|
}
|
||||||
|
|
||||||
/* load in the t/s list info */
|
/* load in the t/s list info */
|
||||||
lseek(fd,DISK_OFFSET(ts_track,ts_sector),SEEK_SET);
|
lseek(fd,DISK_OFFSET(ts_track,ts_sector),SEEK_SET);
|
||||||
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
|
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
|
||||||
|
if (result<0) {
|
||||||
|
fprintf(stderr,"delete: error reading catalog\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* Free each sector listed by t/s list */
|
/* Free each sector listed by t/s list */
|
||||||
for(i=0;i<TSL_MAX_NUMBER;i++) {
|
for(i=0;i<TSL_MAX_NUMBER;i++) {
|
||||||
|
@ -716,6 +731,11 @@ keep_deleting:
|
||||||
(catalog_buffer[TSL_LIST+2*i+1]==0)) {
|
(catalog_buffer[TSL_LIST+2*i+1]==0)) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (debug) {
|
||||||
|
fprintf(stderr,"\tfreeing T=%d S=%d\n",
|
||||||
|
catalog_buffer[TSL_LIST+2*i],
|
||||||
|
catalog_buffer[TSL_LIST+2*i+1]);
|
||||||
|
}
|
||||||
dos33_free_sector(vtoc,fd,catalog_buffer[TSL_LIST+2*i],
|
dos33_free_sector(vtoc,fd,catalog_buffer[TSL_LIST+2*i],
|
||||||
catalog_buffer[TSL_LIST+2*i+1]);
|
catalog_buffer[TSL_LIST+2*i+1]);
|
||||||
}
|
}
|
||||||
|
@ -723,11 +743,20 @@ keep_deleting:
|
||||||
|
|
||||||
/* free the t/s list */
|
/* free the t/s list */
|
||||||
dos33_free_sector(vtoc,fd,ts_track,ts_sector);
|
dos33_free_sector(vtoc,fd,ts_track,ts_sector);
|
||||||
|
if (debug) {
|
||||||
|
fprintf(stderr,"\tfreeing T/S list T=%d S=%d\n",
|
||||||
|
ts_track,ts_sector);
|
||||||
|
}
|
||||||
|
|
||||||
/* Point to next t/s list */
|
/* Point to next t/s list */
|
||||||
ts_track=catalog_buffer[TSL_NEXT_TRACK];
|
ts_track=catalog_buffer[TSL_NEXT_TRACK];
|
||||||
ts_sector=catalog_buffer[TSL_NEXT_SECTOR];
|
ts_sector=catalog_buffer[TSL_NEXT_SECTOR];
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
fprintf(stderr,"\tNext T/S list T=%d S=%d\n",
|
||||||
|
ts_track,ts_sector);
|
||||||
|
}
|
||||||
|
|
||||||
/* If more tsl lists, keep looping */
|
/* If more tsl lists, keep looping */
|
||||||
if ((ts_track==0x0) && (ts_sector==0x0)) {
|
if ((ts_track==0x0) && (ts_sector==0x0)) {
|
||||||
}
|
}
|
||||||
|
@ -740,6 +769,9 @@ keep_deleting:
|
||||||
/* First reload proper catalog sector */
|
/* First reload proper catalog sector */
|
||||||
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
|
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
|
||||||
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
|
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
|
||||||
|
if (result<0) {
|
||||||
|
fprintf(stderr,"delete: error reading catalog\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* save track as last char of name, for undelete purposes */
|
/* save track as last char of name, for undelete purposes */
|
||||||
catalog_buffer[CATALOG_FILE_LIST+(catalog_entry*CATALOG_ENTRY_SIZE)+
|
catalog_buffer[CATALOG_FILE_LIST+(catalog_entry*CATALOG_ENTRY_SIZE)+
|
||||||
|
@ -748,13 +780,15 @@ keep_deleting:
|
||||||
|
|
||||||
/* Actually delete the file */
|
/* Actually delete the file */
|
||||||
/* by setting the track value to FF which indicates deleted file */
|
/* by setting the track value to FF which indicates deleted file */
|
||||||
catalog_buffer[CATALOG_FILE_LIST+(catalog_entry*CATALOG_ENTRY_SIZE)]=0xff;
|
catalog_buffer[CATALOG_FILE_LIST+(catalog_entry*CATALOG_ENTRY_SIZE)]=
|
||||||
|
0xff;
|
||||||
|
|
||||||
/* re seek to catalog position and write out changes */
|
/* re seek to catalog position and write out changes */
|
||||||
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
|
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
|
||||||
result=write(fd,catalog_buffer,BYTES_PER_SECTOR);
|
result=write(fd,catalog_buffer,BYTES_PER_SECTOR);
|
||||||
|
if (result<0) {
|
||||||
if (result<0) fprintf(stderr,"Error on I/O\n");
|
fprintf(stderr,"delete: error writing catalog\n");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,3 +74,6 @@ unsigned char dos33_file_type(int value);
|
||||||
/* dos33_dump.c */
|
/* dos33_dump.c */
|
||||||
int dos33_dump(unsigned char *vtoc, int fd);
|
int dos33_dump(unsigned char *vtoc, int fd);
|
||||||
int dos33_showfree(unsigned char *vtoc, int fd);
|
int dos33_showfree(unsigned char *vtoc, int fd);
|
||||||
|
|
||||||
|
|
||||||
|
extern int debug;
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
|
|
||||||
#include "dos33.h"
|
#include "dos33.h"
|
||||||
|
|
||||||
static int debug=0;
|
|
||||||
|
|
||||||
unsigned char dos33_file_type(int value) {
|
unsigned char dos33_file_type(int value) {
|
||||||
|
|
||||||
unsigned char result;
|
unsigned char result;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user