status = CH378FileOpen("/");
SectorSize1 = 1< /* 當(dāng)前U盤每個扇區(qū)大小 */?
printf( "SectorSize: %ld\n", (UINT32)SectorSize1 );
SecPreClus = CH378ReadVar8( VAR8_SEC_PER_CLUS ); /* 邏輯盤的每簇扇區(qū)數(shù) */
printf( "SecPreClus: %d\n", (UINT16)SecPreClus );
DiskStartLBA = CH378ReadVar32(VAR32_DSK_START_LBA); /* 邏輯盤的起始絕對扇區(qū)號LBA,DBR */?
printf( "DiskStartLBA: %lx\n", (UINT32)DiskStartLBA );
CH378DiskReadSec( BUF, DiskStartLBA, 1 );
resvSec = (UINT16)BUF[0x0f]<<8|BUF[0x0e];
printf( "resvSec: %d\n", (UINT16)resvSec );
fatnum ?= BUF[0x10];printf( "fatnum: %d\n", (UINT16)fatnum );
FATTablSize = (UINT32)BUF[0x27]<<24|(UINT32)BUF[0x26]<<16|(UINT16)BUF[0x25]<<8|BUF[0x24];
printf( "FATTablSize: %ld\n", (UINT32)FATTablSize );
FATTablLBA = DiskStartLBA + resvSec;printf( "FATTablLBA: %lx\n", (UINT32)FATTablLBA );
RootDirLBA = FATTablLBA + fatnum*FATTablSize ;printf( "RootDirLBA: %lx\n", (UINT32)RootDirLBA );?
/* ?格式化U盤 */
/* 將FAT表全部寫0 */
for(i=0;i
{
fatSecsize = FATTablSize;
memset(BUF, 0, 512);
memset(BUF, 0xff, 12);
BUF[0] = 0xf8;BUF[3] = 0x0f;BUF[11] = 0x0f;
CH378DiskWriteSec(BUF, FATTablLBA++, 1);printf( "%lx\n", (UINT32)FATTablLBA );
memset(BUF, 0, 12);
while(--fatSecsize)
{
CH378DiskWriteSec(BUF, FATTablLBA++, 1);printf( "%lx\n", (UINT32)FATTablLBA );
}
}
/* 將根目錄的第一個簇全部寫0 */
memset(BUF, 0, 512);
for(i=0;i
CH378DiskWriteSec(BUF, RootDirLBA++, 1);
以上是那個格式化的代碼,我在電腦上面進(jìn)行格式化的
圖為就是那個我選擇的分配單元大小是需要選擇8192還是512呢?因?yàn)槲椰F(xiàn)在出現(xiàn)了以下問題,
我在格式化之前的:總磁盤容量為:15028M剩余容量為:9662M ?但是我格式化以后的總磁盤容量和剩余容量和之前是一樣的,請問原因是什么呢?