From: Beman Dawes (bdawes_at_[hidden])
Date: 2004-02-01 22:38:56
At 05:51 PM 2/1/2004, Jeremy Maitin-Shepard wrote:
>> Question 2: What if neither exist? Only one exists? My initial thought
>> is that these are likely to be errors, so treat them as such. It could
>> be argued that if either or both don't exist, they can't be
>> equivalent, so return false.
>I would suggest that the function throw an exception if either file
>does not exist. The exception would allow the user to determine
>exactly which paths exist or do not exist. Any other behavior, given
>that the function can return only true or false, would in some
>circumstances give the user less information than desired.
Regardless of what the function does, the user can always call exists()
beforehand if a complete understanding of what is present and what isn't is
>> Question 3: The implementation on Windows (see below) leaves a small
>> hole in that duplicated media (such as two CD's) mounted on devices
>> with the same device id on two different networked machines would be
>> reported as equivalent.
>Does Windows actually assign networked devices device ids which are also
>used for local devices?
Yes, and I confirmed that by testing. The device id is just an ordinal
number corresponding to the drive letter. a=0, b=1, c=2, etc. So two
networked machines have the same device id for their c: drives.
>> POSIX logic: same device id AND same physical location on disk AND
>> same modification time. The modification time is in theory redundant,
>> but is an added protection in case the device id on networked devices
>> failed to meet the POSIX specs.
>As with Windows, do you know of any POSIX platforms that sometimes give
>two devices the same device id?
Not for sure, but knowing the history of device id's and volume serial
numbers, it wouldn't surprise me if that happened when Unix was first
ported to mainframes. In a world where there may be dozens of mounts per
second, performed by robotic tape librarians on a drive available basis,
only volume serial numbers are seen as reliable to establish media
identity, while device id's are seen as physical hardware addresses which
should be accurately reported. Networking hadn't been invented yet. If that
happened, then that existing practice could have been preserved right to
>Note: the sample code I posted incorrectly used stat(2) instead of
>fstat(2) -- fstat should be used to ensure that the file identifier
>remains valid, and that the file is not removed, changed, etc.
Interesting. I'll give that some thought.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk