fatfs/src/ff.c
static DWORD clmt_clust (	/* <2:Error, >=2:Cluster number */
	FIL* fp,		/* Pointer to the file object */
	FSIZE_t ofs		/* File offset to be converted to cluster# */
)
{
	DWORD cl, ncl, *tbl;
	FATFS *fs = fp->obj.fs;


	tbl = fp->cltbl + 1;	/* Top of CLMT */
	cl = (DWORD)(ofs / SS(fs) / fs->csize);	/* Cluster order from top of the file */
	for (;;) {
		ncl = *tbl++;			/* Number of cluters in the fragment */
		if (ncl == 0) return 0;	/* End of table? (error) */
		if (cl < ncl) break;	/* In this fragment? */
		cl -= ncl; tbl++;		/* Next fragment */
	}
	return cl + *tbl;	/* Return the cluster number */
}
/*-----------------------------------------------------------------------*/
/* FAT handling - Convert offset into cluster with link map table        */
/*-----------------------------------------------------------------------*/
FAT handling - Convert offset into cluster with link map table
FAT handling - Convert offset into cluster with link map table
static DWORD clmt_clust (	
	FIL* fp,		
	FSIZE_t ofs		
)
{
	DWORD cl, ncl, *tbl;
	FATFS *fs = fp->obj.fs;
	tbl = fp->cltbl + 1;	
	cl = (DWORD)(ofs / SS(fs) / fs->csize);	
	for (;;) {
		ncl = *tbl++;			
		if (ncl == 0) return 0;	
		if (cl < ncl) break;	
		cl -= ncl; tbl++;		
	}
	return cl + *tbl;	
}
static DWORD clmt_clust ( FIL * fp , FSIZE_t ofs ) { DWORD cl , ncl , * tbl ; FATFS * fs = fp -> obj . fs ; tbl = fp -> cltbl + 1 ; cl = ( DWORD ) ( ofs / SS ( fs ) / fs -> csize ) ; for ( ; ; ) { ncl = * tbl ++ ; if ( ncl == 0 ) return 0 ; if ( cl < ncl ) break ; cl -= ncl ; tbl ++ ; } return cl + * tbl ; }
FAT handling - Convert offset into cluster with link map table
FAT handling - Convert offset into cluster with link map table
/* <2:Error, >=2:Cluster number */ /* Pointer to the file object */ /* File offset to be converted to cluster# */ /* Top of CLMT */ /* Cluster order from top of the file */ /* Number of cluters in the fragment */ /* End of table? (error) */ /* In this fragment? */ /* Next fragment */ /* Return the cluster number */