Page 1 of 1

VFS Mapping

Posted: Mon Jul 14, 2003 1:28 am
by Therx
My device manager contains functions to add/remove mappings from a table. This table contains two pointers; one to a string of the virtual path and one to the string of the real path. Currently the open function will only map if the path is exact ie.

Entry maps /test to /dev1/obj1

But I would also like it to be able to map the following from just that entry

/test/hello to /dev1/obj1/hello

How to I check like this from my table and also how do I make it so if I have two entries:-

/test => /dev1/obj1
/test/hello => /dev2/obj1

That it will find the second entry and map /test/hello to /dev2/obj1 instead of to /dev1/obj1/hello

Thanks for any ideas

Pete

Re:VFS Mapping

Posted: Mon Jul 14, 2003 2:58 am
by Pype.Clicker
basically, what you need is a kind of "longest prefix match". Rather than stopping the search at the first matching string, you have to keep the matching string that has the longest size.

make sure you get a sneak peek at D. E. Knuth's algorithms (searching and sorting) if you also need something efficient, like binary search, etc.