TempleOSCD_150216.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:15 +02:00
1 parent 64f679eeb9
commit 401601816c
531 files changed
+23341 -22071

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
#include "Dsk2a"
#include "Dsk2b"
#include "ADskA"
#include "ADskB"
#include "ChkDsk"
#include "FileMgr"
+52 -33
View File
@@ -7,13 +7,13 @@ public U8 *DBlk(I64 blk,Bool write=FALSE)
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
U8 *buf=MAlloc(BLK_SIZE);
RBlks(Fs->cur_prt,buf,blk,1);
RBlks(Fs->cur_dv,buf,blk,1);
DocD(buf,BLK_SIZE);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
WBlks(Fs->cur_prt,buf,blk,1);
WBlks(Fs->cur_dv,buf,blk,1);
}
}
return buf;
@@ -25,16 +25,35 @@ public U8 *DCluster(I64 c,Bool write=FALSE,I64 num=0)
//be written when you press <ESC>.
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
//Do $LK,"Dir",A="MN:Dir"$("*",TRUE); to get cluster numbers of files.
U8 *buf=MAlloc(Fs->cur_prt->spc<<BLK_SIZE_BITS);
c=ClusterNumNext(Fs->cur_prt,c,num);
RClusters(Fs->cur_prt,buf,c,1);
U8 *buf=MAlloc(Fs->cur_dv->spc<<BLK_SIZE_BITS);
c=ClusterNumNext(Fs->cur_dv,c,num);
RClusters(Fs->cur_dv,buf,c,1);
"Cluster:%X\n",c;
DocD(buf,Fs->cur_prt->spc<<BLK_SIZE_BITS);
DocD(buf,Fs->cur_dv->spc<<BLK_SIZE_BITS);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
WClusters(Fs->cur_prt,buf,c,1);
WClusters(Fs->cur_dv,buf,c,1);
}
}
return buf;
}
public U8 *Dump(U8 *filename,Bool write=FALSE)
{//Dump file. Optionally, write.
//If you set write to TRUE, the file will
//be written when you press <ESC>.
U8 *buf;
I64 size;
if (buf=FileRead(filename,&size)) {
DocD(buf,size);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
FileWrite(filename,buf,size);
}
}
}
return buf;
@@ -218,7 +237,7 @@ public I64 DelTree(U8 *files_find_mask,U8 *fu_flags=NULL)
U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
{
CPrt *p=Drv2Prt(*filename);
CDrv *dv=Let2Drv(*filename);
CDirEntry de;
U8 *cur_dir=StrNew(filename),
buf[136];
@@ -236,7 +255,7 @@ U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
de.datetime=Now;
else
de.datetime=cdt;
DirNew(p,cur_dir,&de,FALSE);
DirNew(dv,cur_dir,&de,FALSE);
}
} else
PrintErr("File not found.\n");
@@ -279,69 +298,69 @@ public I64 FF(U8 *files_find_mask,U8 *fu_flags=NULL)
return cnt;
}
public U0 SetDrvTextAttr(U8 drv_let,U8 attr)
public U0 DrvTextAttrSet(U8 drv_let,U8 attr)
{//Set color of the window border text
//for when this drive is the current drive.
CPrt *p;
CDrv *dv;
try {
p=Drv2Prt(drv_let);
p->text_attr=attr;
dv=Let2Drv(drv_let);
dv->text_attr=attr;
} catch
Fs->catch_except=TRUE;
}
I64 RedSeaFSUnusedDrvSpace(U8 drv_let=0)
I64 RedSeaUnusedDrvSpace(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
CDrv *dv=Let2Drv(drv_let);
I64 result=0,i,l;
U8 *bitmap;
try {
l=(p->size+p->spc-1)/p->spc;
l=(dv->size+dv->spc-1)/dv->spc;
i=((l+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i);
RBlks(dv,bitmap,dv->map1,i);
for (i=0;i<l;i++)
if (!Bt(bitmap,i))
result++;
Free(bitmap);
} catch
PrtUnlock(p);
return result*BLK_SIZE*p->spc;
DrvUnlock(dv);
return result*BLK_SIZE*dv->spc;
}
I64 FAT32UnusedDrvSpace(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
CDrv *dv=Let2Drv(drv_let);
I64 result=0,i,l;
U32 *bitmap;
try {
l=(p->size+p->spc-1)/p->spc;
l=(dv->size+dv->spc-1)/dv->spc;
i=(l*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i);
RBlks(dv,bitmap,dv->map1,i);
for (i=0;i<l;i++)
if (!bitmap[i])
result++;
Free(bitmap);
} catch
PrtUnlock(p);
return result*BLK_SIZE*p->spc;
DrvUnlock(dv);
return result*BLK_SIZE*dv->spc;
}
public I64 UnusedDrvSpace(U8 drv_let=0)
{//Returns unused size in bytes.
CPrt *p=Drv2Prt(drv_let),*p_old=Fs->cur_prt;
CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
U8 *old_dir=StrNew(Fs->cur_dir);
I64 result=0;
Drv(drv_let);
switch (p->type) {
case PT_REDSEA:
result=RedSeaFSUnusedDrvSpace(drv_let);
switch (dv->type) {
case DVT_REDSEA:
result=RedSeaUnusedDrvSpace(drv_let);
break;
case PT_FAT32:
case DVT_FAT32:
result=FAT32UnusedDrvSpace(drv_let);
break;
default:
PrintErr("File System Not Supported\n");
}
Drv(Prt2Drv(p_old));
Drv(Drv2Let(old_dv));
Cd(old_dir);
Free(old_dir);
return result;
@@ -352,12 +371,12 @@ I64 Size1(CDirEntry *tempde,I64 *_fuf_flags,I64 round_to)
{
U8 buf[BLK_SIZE];
I64 result=0,i;
CPrt *p;
CDrv *dv;
while (tempde) {
if ((i=tempde->size) && Bt(_fuf_flags,FUf_EXPAND) &&
!(tempde->attr&RS_ATTR_DIR) && FileAttr(tempde->name)&RS_ATTR_COMPRESSED) {
p=Drv2Prt(*tempde->full_name);
RBlks(p,buf,Cluster2Blk(p,tempde->cluster),1);
dv=Let2Drv(*tempde->full_name);
RBlks(dv,buf,Cluster2Blk(dv,tempde->cluster),1);
i=(&buf)(CArcCompress *)->expanded_size;
}
if (round_to)
+53 -53
View File
@@ -62,25 +62,25 @@ public CDirEntry *DirTreeUnserialize(U8 *src)
#help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically)"
#define ROUND_PRT_TO (63*255)
#define PRT_HEADER 63
#define ROUND_DRV_TO (63*255)
#define DRV_HEADER 63
class CPlannedPrt
class CPlannedDrv
{
CPlannedPrt *next,*last;
CPlannedDrv *next,*last;
I64 size;
Bool pri;
};
//Available to assist in writing scripts.
I64 prt_dsk_dsk_size;
I64 drv_dsk_dsk_size;
public U0 PrtDsk(U8 drv_let=0)
{//Partition the disk containing partition drv_let.
//drv_let=0 means add new drive that
//is not already mounted.
CBlkDev *bdev;
CPlannedPrt root,*temppp;
CBlkDev *bd;
CPlannedDrv root,*temppp;
CMasterBoot mbr;
Bool pri=TRUE;
I64 ext_base,drv_let2,pri_cnt=0,
@@ -99,7 +99,7 @@ public U0 PrtDsk(U8 drv_let=0)
if (drv_let)
try
Drv2BlkDev(drv_let);
Let2BlkDev(drv_let);
catch {
drv_let=0;
Fs->catch_except=TRUE;
@@ -110,18 +110,18 @@ public U0 PrtDsk(U8 drv_let=0)
return;
}
bdev=Drv2BlkDev(drv_let);
if (!bdev || bdev->type!=BDT_ATA)
bd=Let2BlkDev(drv_let);
if (!bd || bd->type!=BDT_ATA)
return;
prt_dsk_dsk_size=bdev->max_blk+1;
drv_dsk_dsk_size=bd->max_blk+1;
QueInit(&root);
drv_let2=bdev->first_drv_let;
remaining=FloorU64(bdev->max_blk+1,ROUND_PRT_TO);
while (FloorU64(remaining,ROUND_PRT_TO)>=ROUND_PRT_TO) {
temppp=MAlloc(sizeof(CPlannedPrt));
drv_let2=bd->first_drv_let;
remaining=FloorU64(bd->max_blk+1,ROUND_DRV_TO);
while (FloorU64(remaining,ROUND_DRV_TO)>=ROUND_DRV_TO) {
temppp=MAlloc(sizeof(CPlannedDrv));
do {
"$$RED$$Partition %C$$FG$$\n",drv_let2;
temppp->pri=FALSE;
@@ -136,10 +136,10 @@ public U0 PrtDsk(U8 drv_let=0)
pri=FALSE;
}
"Blocks Remaining:%d (0x%X)\n",
remaining-PRT_HEADER,remaining-PRT_HEADER;
remaining-DRV_HEADER,remaining-DRV_HEADER;
temppp->size=CeilU64(GetI64("Size in Blocks :",
remaining-PRT_HEADER)+PRT_HEADER,ROUND_PRT_TO);
} while (!(ROUND_PRT_TO<=temppp->size<=FloorU64(remaining,ROUND_PRT_TO)));
remaining-DRV_HEADER)+DRV_HEADER,ROUND_DRV_TO);
} while (!(ROUND_DRV_TO<=temppp->size<=FloorU64(remaining,ROUND_DRV_TO)));
QueIns(temppp,root.last);
remaining-=temppp->size;
drv_let2++;
@@ -147,7 +147,7 @@ public U0 PrtDsk(U8 drv_let=0)
"\n\n!!! Repartition Drive !!!\n\n";
temppp=root.next;
drv_let2=bdev->first_drv_let;
drv_let2=bd->first_drv_let;
while (temppp!=&root) {
"Drive %C:%08X ",drv_let2,temppp->size;
if (temppp->pri)
@@ -160,7 +160,7 @@ public U0 PrtDsk(U8 drv_let=0)
if (!AreYouSure)
goto pd_done;
remaining=FloorU64(bdev->max_blk+1,ROUND_PRT_TO)-ROUND_PRT_TO;
remaining=FloorU64(bd->max_blk+1,ROUND_DRV_TO)-ROUND_DRV_TO;
temppp=root.next;
MemSet(&mbr,0,BLK_SIZE);
mbr.signature=0xAA55;
@@ -172,8 +172,8 @@ public U0 PrtDsk(U8 drv_let=0)
mbr.p[i].type=1; //Will get set different.
mbr.p[i].end_head=0xFE;
mbr.p[i].end_cyl=0xFFFF;
mbr.p[i].offset=PRT_HEADER+offset;
mbr.p[i].size=temppp->size-PRT_HEADER;
mbr.p[i].offset=DRV_HEADER+offset;
mbr.p[i].size=temppp->size-DRV_HEADER;
offset+=temppp->size;
remaining-=temppp->size;
temppp=temppp->next;
@@ -190,7 +190,7 @@ public U0 PrtDsk(U8 drv_let=0)
mbr.p[i].size=remaining;
ext_base=offset;
}
ATAWriteBlks(bdev,&mbr,0,1);
ATAWriteBlks(bd,&mbr,0,1);
while (temppp!=&root) {
start_offset=offset;
@@ -203,8 +203,8 @@ public U0 PrtDsk(U8 drv_let=0)
mbr.p[0].type=1; //Will get set different.
mbr.p[0].end_head=0xFE;
mbr.p[0].end_cyl=0xFFFF;
mbr.p[0].offset=PRT_HEADER;
mbr.p[0].size=temppp->size-PRT_HEADER;
mbr.p[0].offset=DRV_HEADER;
mbr.p[0].size=temppp->size-DRV_HEADER;
offset+=temppp->size;
temppp=temppp->next;
if (temppp!=&root) {
@@ -217,12 +217,12 @@ public U0 PrtDsk(U8 drv_let=0)
mbr.p[1].offset=offset-ext_base;
mbr.p[1].size=temppp->size;
}
ATAWriteBlks(bdev,&mbr,start_offset,1);
ATAWriteBlks(bd,&mbr,start_offset,1);
}
bdev->flags&=~(BDF_INITIALIZED | BDF_INIT_IN_PROGRESS);
BlkDevAdd(bdev,FALSE,TRUE);
for (i=bdev->first_drv_let;i<drv_let2;i++)
bd->flags&=~(BDF_INITIALIZED | BDF_INIT_IN_PROGRESS);
BlkDevAdd(bd,FALSE,TRUE);
for (i=bd->first_drv_let;i<drv_let2;i++)
Fmt(i,,FALSE);
pd_done:
@@ -235,15 +235,15 @@ pd_done:
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically)"
U0 RedSeaFSDrvView(U8 drv_let=0)
U0 RedSeaDrvView(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
CDrv *dv=Let2Drv(drv_let);
I64 lohi,c1,i,x,y,l,s;
U8 *bitmap;
CDC *dc=DCAlias;
l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1),
s=(p->size+p->spc-1)/p->spc;
s=(dv->size+dv->spc-1)/dv->spc;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
@@ -253,7 +253,7 @@ U0 RedSeaFSDrvView(U8 drv_let=0)
try {
i=((s+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i);
RBlks(dv,bitmap,dv->map1,i);
i=0;
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
if (ScanKey)
@@ -271,7 +271,7 @@ U0 RedSeaFSDrvView(U8 drv_let=0)
}
Free(bitmap);
} catch
PrtUnlock(p);
DrvUnlock(dv);
GetChar;
SettingsPop;
@@ -280,12 +280,12 @@ U0 RedSeaFSDrvView(U8 drv_let=0)
}
U0 FAT32DrvView(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
CDrv *dv=Let2Drv(drv_let);
I64 lohi,c1,i,x,y,l,s;
U32 *bitmap;
CDC *dc=DCAlias;
l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1),
s=(p->size+p->spc-1)/p->spc;
s=(dv->size+dv->spc-1)/dv->spc;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
@@ -295,7 +295,7 @@ U0 FAT32DrvView(U8 drv_let=0)
try {
i=(s*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i);
RBlks(dv,bitmap,dv->map1,i);
i=0;
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
if (ScanKey)
@@ -313,7 +313,7 @@ U0 FAT32DrvView(U8 drv_let=0)
}
Free(bitmap);
} catch
PrtUnlock(p);
DrvUnlock(dv);
GetChar;
SettingsPop;
@@ -322,19 +322,19 @@ U0 FAT32DrvView(U8 drv_let=0)
}
public U0 DrvView(U8 drv_let=0)
{//Drive view. Graph the allocation map's fragmentation.
CPrt *p=Drv2Prt(drv_let),*p_old=Fs->cur_prt;
CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
Drv(drv_let);
switch (p->type) {
case PT_REDSEA:
RedSeaFSDrvView(drv_let);
switch (dv->type) {
case DVT_REDSEA:
RedSeaDrvView(drv_let);
break;
case PT_FAT32:
case DVT_FAT32:
FAT32DrvView(drv_let);
break;
default:
PrintErr("File System Not Supported\n");
}
Drv(Prt2Drv(p_old));
Drv(Drv2Let(old_dv));
}
public U0 DskView(U8 drv_let=0)
@@ -343,8 +343,8 @@ public U0 DskView(U8 drv_let=0)
h=Fs->pix_width,
v=Fs->pix_height,
radius;
CPrt *p;
CBlkDev *bdev=Drv2BlkDev(drv_let);
CDrv *dv;
CBlkDev *bd=Let2BlkDev(drv_let);
CDC *dc=DCAlias;
F64 sect_start,sect_end;
@@ -360,11 +360,11 @@ public U0 DskView(U8 drv_let=0)
GrCircle(dc,h>>1,v>>1,radius);
j=1;
for (i=0;i<NUM_PRTS;i++) {
p=&dsk.prts[i];
if (bdev==p->bdev && p->type) {
sect_start=-(p->offset*2*ã/(bdev->max_blk+1));
sect_end =-((p->offset+p->size)*2*ã/(bdev->max_blk+1));
for (i=0;i<NUM_DRVS;i++) {
dv=&dsk.drvs[i];
if (bd==dv->bd && dv->type) {
sect_start=-(dv->base_offset*2*ã/(bd->max_blk+1));
sect_end =-((dv->base_offset+dv->size)*2*ã/(bd->max_blk+1));
dc->color=BLACK;
GrLine(dc,h>>1,v>>1,
h>>1+radius*Cos(sect_start),
@@ -374,8 +374,8 @@ public U0 DskView(U8 drv_let=0)
v>>1+radius*Sin(sect_end));
dc->color=j;
GrPrint(dc,0,v-FONT_HEIGHT*j,"%C %-8Z",Prt2Drv(p),
p->type.u16[0],"ST_PRT_TYPES");
GrPrint(dc,0,v-FONT_HEIGHT*j,"%C %-8Z",Drv2Let(dv),
dv->type.u16[0],"ST_DRV_TYPES");
GrFloodFill(dc,
h>>1+(radius-4)*Cos((sect_start+sect_end)/2),
v>>1+(radius-4)*Sin((sect_start+sect_end)/2),FALSE);
+47 -51
View File
@@ -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:
+24 -24
View File
@@ -140,7 +140,7 @@ CDirEntry *FMRebuildDocDrv(U8 drv_let,CDoc *doc,CDirEntry **_root,Bool init)
U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
{
CPrt *p;
CDrv *dv;
I64 i;
CDoc *doc=*_doc,*doc2=sys_clipboard_doc,*parent_doc;
CFMUncollapsedLst *tempc=NULL;
@@ -211,15 +211,15 @@ U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
break;
}
DocPrint(doc,"$$LTBLUE$$");
for (i=0;i<NUM_PRTS;i++) {
p=&dsk.prts[i];
if (p->type==PT_REDSEA||p->type==PT_FAT32)
FMRebuildDocDrv(Prt2Drv(p),doc,_root,TRUE);
else if (p->type==PT_ISO9660) {
if (p->bdev->flags&BDF_INITIALIZED)
tempde=FMRebuildDocDrv(Prt2Drv(p),doc,_root,TRUE);
for (i=0;i<NUM_DRVS;i++) {
dv=&dsk.drvs[i];
if (dv->type==DVT_REDSEA||dv->type==DVT_FAT32)
FMRebuildDocDrv(Drv2Let(dv),doc,_root,TRUE);
else if (dv->type==DVT_ISO9660) {
if (dv->bd->flags&BDF_INITIALIZED)
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_root,TRUE);
else {
tempde=FMRebuildDocDrv(Prt2Drv(p),doc,_root,FALSE);
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_root,FALSE);
tempde->flags|=DEF_NOT_INITIALIZED;
}
tempde->flags|=DEF_REMOVABLE;
@@ -248,7 +248,7 @@ U0 FMRename(CDoc *doc)
Cd(parent->full_name);
StrCpy(fn.name,tempde->name);
if (DocFormDo(&fn)) {
Silent(ON);
Silent;
Move(tempde->name,fn.name);
Silent(OFF);
}
@@ -260,7 +260,7 @@ U0 FMRename(CDoc *doc)
StrCpy(fn.name,tempde->name);
if (DocFormDo(&fn)) {
if (StrCmp(tempde->name,fn.name)) {
Silent(ON);
Silent;
if (CopyTree(tempde->name,fn.name))
DelTree(tempde->name);
Silent(OFF);
@@ -281,7 +281,7 @@ U0 FMMkDir(CDoc *doc)
if (parent=tempde->parent) {
Cd(parent->full_name);
if (DocFormDo(&fn)) {
Silent(ON);
Silent;
MkDir(fn.name);
Silent(OFF);
}
@@ -290,7 +290,7 @@ U0 FMMkDir(CDoc *doc)
tempde=doc_e->user_data;
Cd(tempde->full_name);
if (DocFormDo(&fn)) {
Silent(ON);
Silent;
MkDir(fn.name);
Silent(OFF);
}
@@ -304,7 +304,7 @@ U0 FMDelete(CDoc *doc)
CDirEntry *tempde;
if (doc_ce->type_u8==DOCT_MENU_VAL) {
tempde=doc_ce->user_data;
Silent(ON);
Silent;
st=MStrPrint("Delete: %s",tempde->full_name);
if (PopUpCancelOk(st))
Del(tempde->full_name);
@@ -312,7 +312,7 @@ U0 FMDelete(CDoc *doc)
Silent(OFF);
} else if (doc_ce->type_u8==DOCT_TREE) {
tempde=doc_ce->user_data;
Silent(ON);
Silent;
st=MStrPrint("Delete: %s",tempde->full_name);
if (PopUpCancelOk(st))
DelTree(tempde->full_name);
@@ -332,7 +332,7 @@ U0 FMMount(CDoc *doc)
if (tempde) {
while (tempde->parent)
tempde=tempde->parent;
Silent(ON);
Silent;
ChgDsk(*tempde->full_name);
Silent(OFF);
}
@@ -352,7 +352,7 @@ U0 FMFmtDrv(CDoc *doc)
tempde=tempde->parent;
st=MStrPrint("Format Drive '%c'?\nAre You Sure?\n",*tempde->full_name);
if (PopUpCancelOk(st)) {
Silent(ON);
Silent;
Fmt(*tempde->full_name,,FALSE);
Silent(OFF);
}
@@ -373,7 +373,7 @@ U0 FMMakeISO(CDoc *doc)
if (doc_ce->type_u8==DOCT_MENU_VAL)
tempde=tempde->parent;
if (tempde && *tempde->full_name) {
Silent(ON);
Silent;
if (tempde->full_name[StrLen(tempde->full_name)-1]=='/')
st=MStrPrint("%s*",tempde->full_name);
else
@@ -396,7 +396,7 @@ U0 FMBurnISO(CDoc *doc)
if (tempde) {
while (tempde->parent)
tempde=tempde->parent;
Silent(ON);
Silent;
CDImageWrite(*tempde->full_name);
Silent(OFF);
}
@@ -423,7 +423,7 @@ U0 FMCopy(CDoc *doc)
tempde->flags|=DEF_PROCESSED;
tempde2=tempde->parent;
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
Silent(ON);
Silent;
Copy(tempde->full_name,tempde1->full_name);
Silent(OFF);
}
@@ -432,7 +432,7 @@ U0 FMCopy(CDoc *doc)
tempde->flags|=DEF_PROCESSED;
tempde2=tempde->parent;
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
Silent(ON);
Silent;
if (*tempde1->name)
st=MStrPrint("%s/%s",tempde1->full_name,tempde->name);
else
@@ -581,7 +581,7 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
case MSG_IP_L_UP:
if (doc_ce) {
gr.fp_final_screen_update=fp_old_final_screen_update;
if (SetCursorPos(Fs,a1/FONT_WIDTH+Fs->win_left+Fs->scroll_x/FONT_WIDTH,a2/FONT_HEIGHT+Fs->win_top+Fs->scroll_y/FONT_HEIGHT,TRUE)) {
if (WinCursorPosSet(Fs,a1/FONT_WIDTH+Fs->win_left+Fs->scroll_x/FONT_WIDTH,a2/FONT_HEIGHT+Fs->win_top+Fs->scroll_y/FONT_HEIGHT,TRUE)) {
doc_e=doc->cur_entry;
if (doc_e!=doc_ce) {
st2=NULL;
@@ -595,7 +595,7 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
}
if (st2 && doc_ce->type_u8==DOCT_MENU_VAL) {
tempde=doc_ce->user_data;
Silent(ON);
Silent;
Move(tempde->full_name,st2);
Silent(OFF);
FMRebuildDoc(&doc,&root,mode);
@@ -617,7 +617,7 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
else
st=MStrPrint("%s%s",tempde1->full_name,tempde->name);
if (StrCmp(tempde->full_name,st)) {
Silent(ON);
Silent;
CopyTree(tempde->full_name,st);
DelTree(tempde->full_name);
Silent(OFF);