fatfs/src/ff.c
static BYTE check_fs (	/* 0:FAT, 1:exFAT, 2:Valid BS but not FAT, 3:Not a BS, 4:Disk error */
	FATFS* fs,			/* Filesystem object */
	DWORD sect			/* Sector# (lba) to load and check if it is an FAT-VBR or not */
)
{
	fs->wflag = 0; fs->winsect = 0xFFFFFFFF;		/* Invaidate window */
	if (move_window(fs, sect) != FR_OK) return 4;	/* Load boot record */

	if (ld_word(fs->win + BS_55AA) != 0xAA55) return 3;	/* Check boot record signature (always here regardless of the sector size) */

#if FF_FS_EXFAT
	if (!mem_cmp(fs->win + BS_JmpBoot, "\xEB\x76\x90" "EXFAT   ", 11)) return 1;	/* Check if exFAT VBR */
#endif
	if (fs->win[BS_JmpBoot] == 0xE9 || fs->win[BS_JmpBoot] == 0xEB || fs->win[BS_JmpBoot] == 0xE8) {	/* Valid JumpBoot code? */
		if (!mem_cmp(fs->win + BS_FilSysType, "FAT", 3)) return 0;		/* Is it an FAT VBR? */
		if (!mem_cmp(fs->win + BS_FilSysType32, "FAT32", 5)) return 0;	/* Is it an FAT32 VBR? */
	}
	return 2;	/* Valid BS but not FAT */
}
/*-----------------------------------------------------------------------*/
/* Load a sector and check if it is an FAT VBR                           */
/*-----------------------------------------------------------------------*/
Load a sector and check if it is an FAT VBR
Load a sector and check if it is an FAT VBR
static BYTE check_fs (	
	FATFS* fs,			
	DWORD sect			
)
{
	fs->wflag = 0; fs->winsect = 0xFFFFFFFF;		
	if (move_window(fs, sect) != FR_OK) return 4;	
	if (ld_word(fs->win + BS_55AA) != 0xAA55) return 3;	
#if FF_FS_EXFAT
	if (!mem_cmp(fs->win + BS_JmpBoot, "\xEB\x76\x90" "EXFAT   ", 11)) return 1;	
#endif
	if (fs->win[BS_JmpBoot] == 0xE9 || fs->win[BS_JmpBoot] == 0xEB || fs->win[BS_JmpBoot] == 0xE8) {	
		if (!mem_cmp(fs->win + BS_FilSysType, "FAT", 3)) return 0;		
		if (!mem_cmp(fs->win + BS_FilSysType32, "FAT32", 5)) return 0;	
	}
	return 2;	
}
static BYTE check_fs ( FATFS * fs , DWORD sect ) { fs -> wflag = 0 ; fs -> winsect = 0xFFFFFFFF ; if ( move_window ( fs , sect ) != FR_OK ) return 4 ; if ( ld_word ( fs -> win + BS_55AA ) != 0xAA55 ) return 3 ; #if FF_FS_EXFAT if ( ! mem_cmp ( fs -> win + BS_JmpBoot , " \xEB \x76 \x90 " " " , 11 ) ) return 1 ; #endif if ( fs -> win [ BS_JmpBoot ] == 0xE9 || fs -> win [ BS_JmpBoot ] == 0xEB || fs -> win [ BS_JmpBoot ] == 0xE8 ) { if ( ! mem_cmp ( fs -> win + BS_FilSysType , " " , 3 ) ) return 0 ; if ( ! mem_cmp ( fs -> win + BS_FilSysType32 , " " , 5 ) ) return 0 ; } return 2 ; }
Load a sector and check if it is an FAT VBR
Load a sector and check if it is an FAT VBR
/* 0:FAT, 1:exFAT, 2:Valid BS but not FAT, 3:Not a BS, 4:Disk error */ /* Filesystem object */ /* Sector# (lba) to load and check if it is an FAT-VBR or not */ /* Invaidate window */ /* Load boot record */ /* Check boot record signature (always here regardless of the sector size) */ /* Check if exFAT VBR */ /* Valid JumpBoot code? */ /* Is it an FAT VBR? */ /* Is it an FAT32 VBR? */ /* Valid BS but not FAT */