Thanks to Trent Lillehaugen for new algorithm:
Let's say I have two yaffs partitions: "/" and "/foo".
If I call, yaffs_mkdir("/foobar", 0), yaffsfs_FindDevice will match the path
with the "/foo" partition. I would expect it to match "/" instead.
It will also match "/fo/o/bar" with "/foo", again I think it should match
with "/".
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
thisMatchLength = 0;
matching = 1;
thisMatchLength = 0;
matching = 1;
- while (matching && *p && *leftOver) {
- /* Skip over any /s */
- while (yaffsfs_IsPathDivider(*p))
- p++;
+ /* Skip over any leading /s */
+ while (yaffsfs_IsPathDivider(*p))
+ p++;
+ while (yaffsfs_IsPathDivider(*leftOver))
+ leftOver++;
- /* Skip over any /s */
- while (yaffsfs_IsPathDivider(*leftOver))
- leftOver++;
+ while (matching && *p && *leftOver) {
/* Now match the text part */
while (matching &&
/* Now match the text part */
while (matching &&
+
+ if ((*p && !yaffsfs_IsPathDivider(*p)) ||
+ (*leftOver && !yaffsfs_IsPathDivider(*leftOver)))
+ matching = 0;
+ else {
+ while (yaffsfs_IsPathDivider(*p))
+ p++;
+ while (yaffsfs_IsPathDivider(*leftOver))
+ leftOver++;
+ }
}
/* Skip over any /s in leftOver */
}
/* Skip over any /s in leftOver */
retval = dev;
longestMatch = thisMatchLength;
}
retval = dev;
longestMatch = thisMatchLength;
}