yaffsfs.c
// yaffsfs_FindDevice
// yaffsfs_FindRoot
// Scan the configuration list to find the root.
// Curveballs: Should match paths that end in '/' too
// Curveball2 Might have "/x/ and "/x/y". Need to return the longest match
yaffsfs_FindDevice
yaffsfs_FindRoot
Scan the configuration list to find the root.
yaffsfs_FindDevice yaffsfs_FindRoot Scan the configuration list to find the root .
static yaffs_Device *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
{
	yaffsfs_DeviceConfiguration *cfg = yaffsfs_configurationList;
	const YCHAR *leftOver;
	const YCHAR *p;
	yaffs_Device *retval = NULL;
	int thisMatchLength;
	int longestMatch = -1;
	while(cfg && cfg->prefix && cfg->dev)
	{
		leftOver = path;
		p = cfg->prefix;
		thisMatchLength = 0;
		while(yaffsfs_IsPathDivider(*p))
			p++;
		while(yaffsfs_IsPathDivider(*leftOver))
			leftOver++;
		while(*p && *leftOver &&
		      yaffsfs_Match(*p,*leftOver))
		{
			p++;
			leftOver++;
			thisMatchLength++;
			while(yaffsfs_IsPathDivider(*p) &&
			      (yaffsfs_IsPathDivider(*(p+1)) || !(*(p+1))))
			      p++;
			while(yaffsfs_IsPathDivider(*leftOver) &&
			      yaffsfs_IsPathDivider(*(leftOver+1)))
			      leftOver++;
		}
		if((!*p ) &&
		   (!*leftOver || yaffsfs_IsPathDivider(*leftOver)) && 
		   (thisMatchLength > longestMatch))
		{
			*restOfPath = (YCHAR *)leftOver;
			retval = cfg->dev;
			longestMatch = thisMatchLength;
		}
		cfg++;
	}
	return retval;
}
static yaffs_Device * yaffsfs_FindDevice ( const YCHAR * path , YCHAR * * restOfPath ) { yaffsfs_DeviceConfiguration * cfg = yaffsfs_configurationList ; const YCHAR * leftOver ; const YCHAR * p ; yaffs_Device * retval = NULL ; int thisMatchLength ; int longestMatch = -1 ; while ( cfg && cfg -> prefix && cfg -> dev ) { leftOver = path ; p = cfg -> prefix ; thisMatchLength = 0 ; while ( yaffsfs_IsPathDivider ( * p ) ) p ++ ; while ( yaffsfs_IsPathDivider ( * leftOver ) ) leftOver ++ ; while ( * p && * leftOver && yaffsfs_Match ( * p , * leftOver ) ) { p ++ ; leftOver ++ ; thisMatchLength ++ ; while ( yaffsfs_IsPathDivider ( * p ) && ( yaffsfs_IsPathDivider ( * ( p + 1 ) ) || ! ( * ( p + 1 ) ) ) ) p ++ ; while ( yaffsfs_IsPathDivider ( * leftOver ) && yaffsfs_IsPathDivider ( * ( leftOver + 1 ) ) ) leftOver ++ ; } if ( ( ! * p ) && ( ! * leftOver || yaffsfs_IsPathDivider ( * leftOver ) ) && ( thisMatchLength > longestMatch ) ) { * restOfPath = ( YCHAR * ) leftOver ; retval = cfg -> dev ; longestMatch = thisMatchLength ; } cfg ++ ; } return retval ; }
yaffsfs_FindDevice
yaffsfs_FindRoot
Scan the configuration list to find the root.
yaffsfs_FindDevice yaffsfs_FindRoot Scan the configuration list to find the root .
// Check all configs, choose the one that: // 1) Actually matches a prefix (ie /a amd /abc will not match // 2) Matches the longest. // Strip off any leading /'s // Skip over any multiple /'s to treat them as one or // skip over a trailling / in the prefix, but not the matching string // Only skip over multiple /'s // no more in this path name part // Matched prefix