fat32mountvolumeid.c

来自「这个是非常不错的mp3源码」· C语言 代码 · 共 42 行

C
42
字号
#ifndef _FAT32_DEFINE
 #include "FAT32.c"
#endif

BYTE FAT32MountVolumeID(BYTE Partition);

BYTE FAT32MountVolumeID(BYTE Partition)
{
	register BYTE i;

	#ifdef DEBUG
		printf("Mount FAT32 volume ID...%bd\n",Partition);
	#endif

	if (Partition>=HDD.TotalPartitions) return(FAT32_ERR_PARTITION_NOT_FOUND);	//没找到指定扇区

	IDEReadSector(sDPT[Partition].LBABegin);		//读FAT32 VolumeID扇区
	//检查VolumeID扇区标记
 	if (DiskBuffer[510] != 0x55||DiskBuffer[511] != 0xaa)
		return(FAT32_ERR_MBR_FLAG);			//不正常的引导扇区标志

	//检查分区类型
	HDD.CurrentPartition = Partition;							//当前分区号
//	HDD.BytesPerSec = BOOTSEC->BPB_BytesPerSec;					//每扇区字节数
	FAT32.SecPerClus = BOOTSEC->BPB_SecPerClus;					//每簇扇区数
	FAT32.RsvdSecCnt = MEMSwap16(BOOTSEC->BPB_RsvdSecCnt);		//保留扇区数
	FAT32.NumFATs = BOOTSEC->BPB_NumFATs;						//FAT表个数
	FAT32.FATSz = MEMSwap32(BOOTSEC->FAT.F32.BPB_FATSz32);		//FAT表达小(扇区)
	FAT32.RootClus = MEMSwap32(BOOTSEC->FAT.F32.BPB_RootClus);	//根目录簇号
	FAT32.CurrentDirectory = FAT32.RootClus;					//当前目录入口(簇号)
	FAT32.FATSec = sDPT[HDD.CurrentPartition].LBABegin + FAT32.RsvdSecCnt;		//FAT表开始的扇区号
	FAT32.ClusSec = sDPT[HDD.CurrentPartition].LBABegin + FAT32.RsvdSecCnt + (FAT32.NumFATs * FAT32.FATSz);		//簇开始的扇区
	FAT32.FSISec = MEMSwap16(BOOTSEC->FAT.F32.BPB_FSInfo) + sDPT[Partition].LBABegin;		//FAT32扩展信息扇区号

	//加载第一个FAT表
	IDEReadSector(FAT32.FATSec);
	for(i=0;i<128;i++)				
		FAT.FAT[i]=((DWORD *)&DiskBuffer)[i];
	FAT.Sector=0;
	return(0);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?