+ const YCHAR *leftOver;
+ const YCHAR *p;
+ yaffs_Device *retval = NULL;
+ int thisMatchLength;
+ int longestMatch = -1;
+ int matching;
+
+ // 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;
+ matching = 1;
+
+
+ while(matching && *p && *leftOver){
+ // Skip over any /s
+ while(yaffsfs_IsPathDivider(*p))
+ p++;
+
+ // Skip over any /s
+ while(yaffsfs_IsPathDivider(*leftOver))
+ leftOver++;
+
+ // Now match the text part
+ while(matching &&
+ *p && !yaffsfs_IsPathDivider(*p) &&
+ *leftOver && !yaffsfs_IsPathDivider(*leftOver)){
+ if(yaffsfs_Match(*p,*leftOver)){
+ p++;
+ leftOver++;
+ thisMatchLength++;
+ } else {
+ matching = 0;
+ }
+ }
+ }
+
+ // Skip over any /s in leftOver
+ while(yaffsfs_IsPathDivider(*leftOver))
+ leftOver++;
+
+
+ if( matching && (thisMatchLength > longestMatch)){
+ // Matched prefix
+ *restOfPath = (YCHAR *)leftOver;
+ retval = cfg->dev;
+ longestMatch = thisMatchLength;
+ }
+
+ cfg++;
+ }
+ return retval;
+}
+
+#if 0
+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;
+
+ // 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){