Hal feature request
David Zeuthen
david at fubar.dk
Wed Mar 24 14:31:04 EET 2004
On Wed, Mar 24, 2004 at 11:21:06AM +0100, Alexander Larsson wrote:
> As posted by Linus on linux-kernel, major minor numbers are not
> guaranteed to be stable over reboots:
>
> http://seclists.org/lists/linux-kernel/2004/Jan/1000.html
>
Right, yeah - the major/minor number is only to be considered a cookie
passed between the kernel and userspace. There was some discussion on
linux-hotplug I recall about having the kernel generate random major/minor
numbers just to test that userspace doesn't rely on it.
> Also, there are apparently some crappy usb devices with non-unique
> serial numbers (although i think these are mostly mice and suchlike). At
> least i've seen this being mentioned on linux-kernel.
>
True - I've got a USB Lexar CF card reader without an unique serial number.
> Furthermore, since things like scsi ids, major minor, etc are not stable
> over boots some filesystems have UUIDs stored on disk, so you always
> have a unique identifier for them. I know ext2/3 has this, and
> mount/mtab even allows mount-by-UUID. Using something like this it might
> even be possible to have unique identifiers for the removable media in a
> removable media device.
>
The way I go about this in hal is to *try* to give a stable UDI - for USB
devices, for instance, this is computed by using the vendor_id, product_id
and serial number (if available) - if the UDI is not unique I just smack
an arbitrary number on the back of it. Data not to use includes slot/port
number as well as other parameters known to change if the user re-arranges
his device.
But, no, in general you cannot guarantee unique identifiers, but then again
I'm not sure about how important it is to desktop environments other than
storing the position of a file-manager window for a block device, the name
of the device presented to the user (e.g. "Dad's camera") etc. I haven't
given it much thought though.
David
More information about the xdg
mailing list