TempleOSCD_150216.ISO
This commit is contained in:
1 parent
64f679eeb9
commit
401601816c
531 files changed
+23341
-22071
No files matched your search
+47
-51
@@ -11,32 +11,30 @@ Bool ChkDskConfirm(Bool *_fix,Bool *_confirm)
|
||||
return *_fix;
|
||||
}
|
||||
|
||||
I64 RedSeaFSChkDskLst(CDirEntry *tempde1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
|
||||
I64 RedSeaChkDskLst(CDrv *dv,CDirEntry *tempde1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
|
||||
{
|
||||
CDirEntry *tempde2;
|
||||
I64 i,j,errs=0;
|
||||
while (tempde1) {
|
||||
tempde2=tempde1->next;
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
if (tempde1->sub)
|
||||
errs+=RedSeaFSChkDskLst(tempde1->sub,bits,bits2,size,bpc);
|
||||
}
|
||||
if (tempde1->attr & RS_ATTR_DIR && tempde1->sub)
|
||||
errs+=RedSeaChkDskLst(dv,tempde1->sub,bits,bits2,size,bpc);
|
||||
j=(tempde1->size+bpc-1)/bpc;
|
||||
for (i=0;i<j;i++) {
|
||||
if (i+tempde1->cluster>size) {
|
||||
if (i+tempde1->cluster-dv->data_area>size) {
|
||||
PrintErr("Invalid Cluster:%s Cluster:%X\n",tempde1->full_name,
|
||||
i+tempde1->cluster);
|
||||
i+tempde1->cluster);
|
||||
errs++;
|
||||
break;
|
||||
}
|
||||
if (LBts(bits,i+tempde1->cluster)) {
|
||||
if (LBts(bits,i+tempde1->cluster-dv->data_area)) {
|
||||
PrintErr("Dbl Alloc:%s Cluster:%X\n",tempde1->full_name,
|
||||
i+tempde1->cluster);
|
||||
i+tempde1->cluster);
|
||||
errs++;
|
||||
}
|
||||
if (!LBtr(bits2,i+tempde1->cluster)) {
|
||||
if (!LBtr(bits2,i+tempde1->cluster-dv->data_area)) {
|
||||
PrintErr("UnAlloc:%s Cluster:%X\n",tempde1->full_name,
|
||||
i+tempde1->cluster);
|
||||
i+tempde1->cluster);
|
||||
errs++;
|
||||
}
|
||||
}
|
||||
@@ -46,74 +44,72 @@ I64 RedSeaFSChkDskLst(CDirEntry *tempde1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
|
||||
return errs;
|
||||
}
|
||||
|
||||
I64 RedSeaFSChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
|
||||
I64 RedSeaChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
|
||||
{
|
||||
I64 i,j,bpc,size,errs=0;
|
||||
CPrt *p=Drv2Prt(drv_let),*old_prt=Fs->cur_prt;
|
||||
U8 *files_find_mask=MStrPrint("%c:/*",Prt2Drv(p)),
|
||||
CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
|
||||
U8 *files_find_mask=MStrPrint("%c:/*",Drv2Let(dv)),
|
||||
*old_dir=StrNew(Fs->cur_dir),
|
||||
*bits,*bits2;
|
||||
CDirEntry *ptr,*ptr2;
|
||||
|
||||
Drv(drv_let);
|
||||
"Scanning...\n";
|
||||
size=(p->size-(p->data-p->offset))/p->spc;
|
||||
bpc=p->spc<<BLK_SIZE_BITS;
|
||||
size=(dv->size-(dv->data_area-dv->base_offset))/dv->spc;
|
||||
bpc=dv->spc<<BLK_SIZE_BITS;
|
||||
bits=CAlloc((size+7)>>3);
|
||||
bits2=CAlloc((size+7)>>3+BLK_SIZE);
|
||||
RBlks(p,bits2,p->map1,((size+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
RBlks(dv,bits2,dv->map1,((size+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
|
||||
//Get Root Dir size
|
||||
ptr2=MAlloc(bpc);
|
||||
RClusters(p,ptr2,p->root_cluster,1);
|
||||
RBlks(dv,ptr2,dv->root_cluster,1);
|
||||
ptr=ptr2(U8 *)-offset(CDirEntry.start);
|
||||
j=(ptr->size+bpc-1)/bpc;
|
||||
Free(ptr2);
|
||||
|
||||
for (i=0;i<j;i++) {
|
||||
if (i+p->root_cluster>size) {
|
||||
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",i+p->root_cluster);
|
||||
if (i+dv->root_cluster-dv->data_area>size) {
|
||||
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",i+dv->root_cluster);
|
||||
errs++;
|
||||
break;
|
||||
}
|
||||
if (LBts(bits,i+p->root_cluster)) {
|
||||
PrintErr("Dbl Alloc: RootDir Cluster:%X\n",i+p->root_cluster);
|
||||
if (LBts(bits,i+dv->root_cluster-dv->data_area)) {
|
||||
PrintErr("Dbl Alloc: RootDir Cluster:%X\n",i+dv->root_cluster);
|
||||
errs++;
|
||||
}
|
||||
if (!LBtr(bits2,i+p->root_cluster)) {
|
||||
PrintErr("UnAlloc: RootDir Cluster:%X\n",i+p->root_cluster);
|
||||
if (!LBtr(bits2,i+dv->root_cluster-dv->data_area)) {
|
||||
PrintErr("UnAlloc: RootDir Cluster:%X\n",i+dv->root_cluster);
|
||||
errs++;
|
||||
}
|
||||
}
|
||||
|
||||
errs+=RedSeaFSChkDskLst(FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
|
||||
errs+=RedSeaChkDskLst(dv,FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
|
||||
for (i=1;i<size;i++)
|
||||
if (Bt(bits2,i)) {
|
||||
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i);
|
||||
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i+dv->data_area);
|
||||
errs++;
|
||||
if (ChkDskConfirm(_fix,_confirm))
|
||||
RedSeaFSFreeClusters(p,i,1);
|
||||
RedSeaFreeClusters(dv,i+dv->data_area,1);
|
||||
}
|
||||
|
||||
Free(files_find_mask);
|
||||
Free(bits);
|
||||
Free(bits2);
|
||||
Drv(Prt2Drv(old_prt));
|
||||
Drv(Drv2Let(old_dv));
|
||||
Cd(old_dir);
|
||||
Free(old_dir);
|
||||
return errs;
|
||||
}
|
||||
|
||||
I64 FAT32ChkDskLst(CPrt *p,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 bpc)
|
||||
I64 FAT32ChkDskLst(CDrv *dv,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 bpc)
|
||||
{
|
||||
CDirEntry *tempde2;
|
||||
I64 i,c,errs=0;
|
||||
while (tempde1) {
|
||||
tempde2=tempde1->next;
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
if (tempde1->sub)
|
||||
errs+=FAT32ChkDskLst(p,tempde1->sub,bits,bits2,size,bpc);
|
||||
}
|
||||
if (tempde1->attr & RS_ATTR_DIR && tempde1->sub)
|
||||
errs+=FAT32ChkDskLst(dv,tempde1->sub,bits,bits2,size,bpc);
|
||||
i=0;
|
||||
c=tempde1->cluster;
|
||||
while (0<c<0x0FFFFFF8) {
|
||||
@@ -131,17 +127,17 @@ I64 FAT32ChkDskLst(CPrt *p,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 b
|
||||
errs++;
|
||||
} else
|
||||
bits2[c]=0;
|
||||
c=ClusterNumNext(p,c);
|
||||
c=ClusterNumNext(dv,c);
|
||||
i++;
|
||||
}
|
||||
if (!(tempde1->attr & RS_ATTR_DIR)) {
|
||||
i*=bpc;
|
||||
if (tempde1->size>i) {
|
||||
PrintErr("Allocated File Too Short:%s\n",tempde1->full_name);
|
||||
PrintErr("Alloced File Too Short:%s\n",tempde1->full_name);
|
||||
errs++;
|
||||
}
|
||||
if (i>tempde1->size+bpc-1) {
|
||||
PrintWarn("Allocated File Too Long:%s\n",tempde1->full_name);
|
||||
PrintWarn("Alloced File Too Long:%s\n",tempde1->full_name);
|
||||
errs++;
|
||||
}
|
||||
}
|
||||
@@ -154,20 +150,20 @@ I64 FAT32ChkDskLst(CPrt *p,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 b
|
||||
I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
|
||||
{
|
||||
I64 i,bpc,size,c,errs=0;
|
||||
CPrt *p=Drv2Prt(drv_let),*old_prt=Fs->cur_prt;
|
||||
U8 *files_find_mask=MStrPrint("%c:/*",Prt2Drv(p)),
|
||||
CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
|
||||
U8 *files_find_mask=MStrPrint("%c:/*",Drv2Let(dv)),
|
||||
*old_dir=StrNew(Fs->cur_dir),
|
||||
*bits;
|
||||
U32 *bits2;
|
||||
Drv(drv_let);
|
||||
"Scanning...\n";
|
||||
size=(p->size-(p->data-p->offset))/p->spc;
|
||||
bpc=p->spc<<BLK_SIZE_BITS;
|
||||
size=(dv->size-(dv->data_area-dv->base_offset))/dv->spc;
|
||||
bpc=dv->spc<<BLK_SIZE_BITS;
|
||||
bits=CAlloc((size+7)>>3);
|
||||
bits2=CAlloc(size*4+BLK_SIZE);
|
||||
RBlks(p,bits2,p->map1,(size*4+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
RBlks(dv,bits2,dv->map1,(size*4+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
|
||||
c=p->root_cluster;
|
||||
c=dv->root_cluster;
|
||||
while (0<c<0x0FFFFFF8) {
|
||||
if (c>size) {
|
||||
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",c);
|
||||
@@ -183,10 +179,10 @@ I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
|
||||
errs++;
|
||||
} else
|
||||
bits2[c]=0;
|
||||
c=ClusterNumNext(p,c);
|
||||
c=ClusterNumNext(dv,c);
|
||||
}
|
||||
|
||||
errs+=FAT32ChkDskLst(p,FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
|
||||
errs+=FAT32ChkDskLst(dv,FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
|
||||
|
||||
bits2[1]=0; //See $LK,"FAT32Fmt",A="MN:FAT32Fmt"$()
|
||||
for (i=1;i<size;i++)
|
||||
@@ -194,12 +190,12 @@ I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
|
||||
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i);
|
||||
errs++;
|
||||
if (ChkDskConfirm(_fix,_confirm))
|
||||
FAT32FreeClusters(p,i);
|
||||
FAT32FreeClusters(dv,i);
|
||||
}
|
||||
Free(files_find_mask);
|
||||
Free(bits);
|
||||
Free(bits2);
|
||||
Drv(Prt2Drv(old_prt));
|
||||
Drv(Drv2Let(old_dv));
|
||||
Cd(old_dir);
|
||||
Free(old_dir);
|
||||
return errs;
|
||||
@@ -209,12 +205,12 @@ public I64 ChkDsk(U8 drv_let=0,Bool fix=FALSE,Bool confirm=TRUE)
|
||||
{//Check disk for allocation errors and, optionally, fix.
|
||||
//You probably want to reformat and reinstall.
|
||||
I64 errs=0;
|
||||
CPrt *p=Drv2Prt(drv_let);
|
||||
switch (p->type) {
|
||||
case PT_REDSEA:
|
||||
errs=RedSeaFSChkDsk(drv_let,&fix,&confirm);
|
||||
CDrv *dv=Let2Drv(drv_let);
|
||||
switch (dv->type) {
|
||||
case DVT_REDSEA:
|
||||
errs=RedSeaChkDsk(drv_let,&fix,&confirm);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
case DVT_FAT32:
|
||||
errs=FAT32ChkDsk(drv_let,&fix,&confirm);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in new issue
Block a user