system/drivers/fatfs/format.c
/*
 * The FSB will contain the partition size even if the BPB
 * is not a valid FAT.
 * Need a bit to indicate whether the disk is in a valid state or not on return.
 */
The FSB will contain the partition size even if the BPB
is not a valid FAT.
Need a bit to indicate whether the disk is in a valid state or not on return.
The FSB will contain the partition size even if the BPB is not a valid FAT . Need a bit to indicate whether the disk is in a valid state or not on return .
int FatFormat (char *label, uint32_t flags, uint32_t cluster_size)
{	
	struct FatDirEntry label_dirent;
	KLog ("FatFormat()");
	if (label == NULL)
	{
		if (FatASCIIZToDirEntry (&label_dirent, "NO NAME") != 0)
			return -1;
	}
	else if (FatASCIIZToDirEntry (&label_dirent, label) != 0)
	{
		return -1;
	}
	else
	{
		return -1;
	}
	if (InitializeFatSB (&label_dirent, flags, cluster_size) == 0)
	{
		KLog ("InitializeFatSB OK");
		if (FatEraseDisk (flags) == 0)
		{
			KLog ("FatEraseDisk OK");
			if (FatWriteBootRecord() == 0)	
			{
				KLog ("FatWriteBootRecord OK");
				if (FatInitFATs() == 0)
				{
					KLog ("FatInitFATs OK");
					if (FatInitRootDirectory (&label_dirent) == 0)
					{
						KLog ("FatInitRootDirectory OK");
						return 0;
					}
				}
			}
		}
	}
	return -1;
}
int FatFormat ( char * label , uint32_t flags , uint32_t cluster_size ) { struct FatDirEntry label_dirent ; KLog ( " " ) ; if ( label == NULL ) { if ( FatASCIIZToDirEntry ( & label_dirent , " " ) != 0 ) return -1 ; } else if ( FatASCIIZToDirEntry ( & label_dirent , label ) != 0 ) { return -1 ; } else { return -1 ; } if ( InitializeFatSB ( & label_dirent , flags , cluster_size ) == 0 ) { KLog ( " " ) ; if ( FatEraseDisk ( flags ) == 0 ) { KLog ( " " ) ; if ( FatWriteBootRecord ( ) == 0 ) { KLog ( " " ) ; if ( FatInitFATs ( ) == 0 ) { KLog ( " " ) ; if ( FatInitRootDirectory ( & label_dirent ) == 0 ) { KLog ( " " ) ; return 0 ; } } } } } return -1 ; }
The FSB will contain the partition size even if the BPB
 is not a valid FAT.
The FSB will contain the partition size even if the BPB is not a valid FAT .
//		SetError (EINVAL); /* Might crash here if invalidated */ //	FatInvalidate(); /* Can include the backups */ //	SetError (ENOSYS);