- yaffsfs_DeviceConfiguration *cfg = yaffsfs_configurationList;
- const YCHAR *leftOver;
- const YCHAR *p;
- struct yaffs_dev *retval = NULL;
- int thisMatchLength;
- int longestMatch = -1;
-
- /*
- * Check all configs, choose the one that:
- * 1) Actually matches a prefix (ie /a amd /abc will not match
- * 2) Matches the longest.
- */
- while(cfg && cfg->prefix && cfg->dev){
- leftOver = path;
- p = cfg->prefix;
- thisMatchLength = 0;
-
- while(*p && /* unmatched part of prefix */
- !(yaffsfs_IsPathDivider(*p) && (p[1] == 0)) &&
- *leftOver && yaffsfs_Match(*p,*leftOver)){
- p++;
- leftOver++;
- thisMatchLength++;
- }
-
-
- if((!*p || (yaffsfs_IsPathDivider(*p) && (p[1] == 0))) && /* end of prefix */
- (!*leftOver || yaffsfs_IsPathDivider(*leftOver)) && /* no more in this path name part */
- (thisMatchLength > longestMatch)){
- /* Matched prefix */
- *restOfPath = (YCHAR *)leftOver;
- retval = cfg->dev;
- longestMatch = thisMatchLength;
- }
- cfg++;