/*-----------------------------------------------------------------------*/
02
/* Load a sector and check if it is an FAT Volume Boot Record */
03
/*-----------------------------------------------------------------------*/
04
05
static
06
BYTE check_fs ( /* 0:FAT-VBR, 1:Valid BR but not FAT, 2:Not a BR, 3:Disk error */
07
FATFS *fs, /* File system object */
08
DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */
09
)
10
{
11
if (disk_read(fs->drv, fs->win, sect, 1) != RES_OK) /* Load boot record */
12
return 3;
13
if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature (always placed at offset 510 even if the sector size is >512) */
14
return 2;
15
16
if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */
17
return 0;
18
if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146)
19
return 0;
20
21
return 1;
22
}
走了这步之后if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55)
就return 2了;最终返回是FR_NO_FILESYSTEM,没有有效的FAT卷?
|