status = CH378FileOpen("/");
SectorSize1 = 1< /* 当前U盘每个扇区大小 */
printf( "SectorSize: %ld\n", (UINT32)SectorSize1 );
SecPreClus = CH378ReadVar8( VAR8_SEC_PER_CLUS ); /* 逻辑盘的每簇扇区数 */
printf( "SecPreClus: %d\n", (UINT16)SecPreClus );
DiskStartLBA = CH378ReadVar32(VAR32_DSK_START_LBA); /* 逻辑盘的起始绝对扇区号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);
以上是那个格式化的代码,我在电脑上面进行格式化的
图为就是那个我选择的分配单元大小是需要选择8192还是512呢?因为我现在出现了以下问题,
我在格式化之前的:总磁盘容量为:15028M剩余容量为:9662M 但是我格式化以后的总磁盘容量和剩余容量和之前是一样的,请问原因是什么呢?