On Sat, 18 May 2002, Marcus Brinkmann wrote: > > 1: dpkg is asked to search for a pattern in it's file database. > > 2: the pattern is split into a file pattern and dir pattern(split on '/') > > 3: a file pattern search is done. > > 4: for all matches from (3), get the realpath(3) of the file. > > 5: use the dir pattern from (1) to search this new directory list. > > This will work very well. Faster than a realpath() is to do a stat() > and compare the st_dev and st_inode numbers. Both together uniquely > identify a file in the system. Of course, as with realpath, you can not > cache the values in the database, but at least it reduces the cost to one > stat for each file result. If you look for files like changelog.gz or > copyright, there will be a lot of files to compare against, but for the vast > majority of file names the number of results from (3) should be quite small.
Not all filesystems have sane st_dev and st_inode numbers. > > The one thing I can't decide upon, is when listing the matches, is if the > > real > > path of the file should be shown, or the path as stored in the dpkg > > database. > > [snip] interesting talk about which path to output Interesting food for thought, we shall have to keep this in mind. > > * Much more complex search algorithm. > > It's a bit more complex, but it should refactor nicely (eg, what you need in > (3) above should be possible to do with the current code, and then the > filter has to be added on top of it). So, now just have to con someone to write the patch. :) > Ah, this sounds nice, I am looking forward to it. I have to admit that > currently I am trained to just use grep on /var/lib/dpkg/info/*.list if > I need it right quick. For instance, one could break each path on '/', and then index all the parts in a hash. Then, when give a pattern to search on, break it on '/' as well, and combine the unique search results. Doing something like this in perl would be simplistic. C is more complex, of course. I may be able to use my debbugs index generators(in perl) for this task. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

