On Sat, May 18, 2002 at 08:51:11PM -0500, Adam Heath wrote: > Not all filesystems have sane st_dev and st_inode numbers.
Mmmh, well they should, it's required by POSIX[1]. From looking at the code, Linux 2.4 behaves a lot better on this than previous versions, and the Hurd got it right forever (do I dare to add "of course"? No, I don't ;). I don't know about BSD, though (or other operating systems). It's a pity that st_dev is so underrated, it is very useful for these things. Maybe there is something more reliable but OS specific we can use? The Hurd has an io_identity call you can use to match up two ports (think filedescriptor if you are not familiar with ports) and see if they refer to the same file[2]. If something similar exists in the Linux kernel, it might be worth to go for st_* on systems where it is safe, fall back to the reliable OS specific implementation if it exists, and otherwise fall back to realpath, at the cost that it is really much slower than a simple stat (for the normal operation, the bottleneck will probably be the database search, but for things like */copyright I would estimate that realpath becomes noticably slower.). Actually, it will be trivial to make tests when the code is there, so we don't need to decide this now at all. [1] The draft 7 (which was the last draft before the latest version was released) has in description of sys/stat.h: "The st_ino and st_dev fields taken together uniquely identify the file within the system." [2] If you wonder if this isn't redundant, then it might interest you that this call can be made on any I/O object, including a pipe or a socket, and it will work reliably, while st_* will only work reliably on files. > > > * 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. :) I might have a crunch at the code (assuming dpkg-search isn't written in python ;). I will have a look at the code and tell you how it goes. Thanks, Marcus -- `Rhubarb is no Egyptian god.' Debian http://www.debian.org [EMAIL PROTECTED] Marcus Brinkmann GNU http://www.gnu.org [EMAIL PROTECTED] [EMAIL PROTECTED] http://www.marcus-brinkmann.de -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

