VFS Mapping

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Therx

VFS Mapping

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:VFS Mapping

Post 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.
Post Reply